sendRawTransaction
Sends a signed transaction to the network
Import
Import the wallet actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/wallet"Usage
See how to construct a wallet client and call this action.
import ( "context" "log"
"github.com/ChefBingbong/viem-go/actions/wallet" "github.com/ChefBingbong/viem-go/client" "github.com/ChefBingbong/viem-go/client/transport" "github.com/ChefBingbong/viem-go/chain/definitions")
ctx := context.Background()
walletClient, err := client.CreateWalletClient(client.WalletClientConfig{ Chain: definitions.Mainnet, Transport: transport.HTTP("https://eth.llamarpc.com"),})if err != nil { log.Fatal(err)}defer func() { _ = walletClient.Close() }()
hash, err := wallet.SendRawTransaction(ctx, walletClient, wallet.SendRawTransactionParameters{ SerializedTransaction: "0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33",})if err != nil { log.Fatal(err)}log.Printf("Transaction hash: %s", hash)Returns
string
The transaction hash as a hex string.
Parameters
Configuration options accepted by this action.
SerializedTransaction
-
Type:
string -
Required
The signed serialized transaction hex string.
hash, err := wallet.SendRawTransaction(ctx, walletClient, wallet.SendRawTransactionParameters{ SerializedTransaction: "0x02f850018203118080825208808080c080a04012522854168b27e5dc3d5839bab5e6b39e1a0ffd343901ce1622e3d64b48f1a04e00902ae0502c4728cbf12156290df99c3ed7de85b1dbfe20b5c36931733a33",})JSON-RPC Method
-
The underlying JSON-RPC method invoked by this action.