Querying Transactions
Loop through the transactions in the block, you can get transaction details.
Import the types packages:
import (
"github.com/PhoenixGlobal/Phoenix-Chain-SDK/ethereum/core/types"
)Query transaction details:
for _, trans := range block.Transactions() {
fmt.Println(trans.Hash().Hex()) // get transaction hash
fmt.Println(trans.Value().String()) // get transaction value
chianID, err := client.ChainID(context.Background())
if err != nil{
fmt.Println(err)
}
msg, err := trans.AsMessage(types.NewEIP155Signer(chianID))
if err != nil{
fmt.Println(err)
} else{
fmt.Println(msg.From().Hex()) // get from address
}
fmt.Println(trans.To().Hex()) // get to address
}Or get transaction details directly by transaction hash:
You can also get the transaction receipt by a transaction hash:
Last updated