getTransactionReceipt
Returns the transaction receipt given a transaction hash
Import
Import the public actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/public"Usage
An example showing how to construct a public client and retrieve a transaction receipt.
import ( "context" "log"
"github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public" "github.com/ChefBingbong/viem-go/client" "github.com/ChefBingbong/viem-go/client/transport" "github.com/ChefBingbong/viem-go/chain/definitions")
ctx := context.Background()
publicClient, err := client.CreatePublicClient(client.PublicClientConfig{ Chain: definitions.Mainnet, Transport: transport.HTTP("https://eth.llamarpc.com"),})if err != nil { log.Fatal(err)}defer func() { _ = publicClient.Close() }()
txHash := common.HexToHash("0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d")receipt, err := public.GetTransactionReceipt(ctx, publicClient, public.GetTransactionReceiptParameters{ Hash: txHash,})if err != nil { log.Fatal(err)}log.Printf("Transaction status: %s", receipt.Status)Returns
*types.Receipt
The transaction receipt.
Parameters
Configuration options accepted by this action.
Hash
- Type:
common.Hash - Required
A transaction hash.
import ( "github.com/ethereum/go-ethereum/common" "github.com/ChefBingbong/viem-go/actions/public")
txHash := common.HexToHash("0x4ca7ee652d57678f26e887c149ab0735f41de37bcad58c9f6d3ed5824f15b74d")receipt, err := public.GetTransactionReceipt(ctx, publicClient, public.GetTransactionReceiptParameters{ Hash: txHash,})JSON-RPC Method
Underlying JSON-RPC method used by this action.