signTransaction
Signs a transaction with the Account's private key
Loading...
Signs a transaction with the Account's private key
eth_signTransaction RPC method.Import the wallet actions package so you can call this action.
import "github.com/ChefBingbong/viem-go/actions/wallet"See how to construct a wallet client and call this action.
import ( "context" "log" "math/big"
"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() }()
signed, err := wallet.SignTransaction(ctx, walletClient, wallet.SignTransactionParameters{ To: "0x70997970c51812dc3a010c7d01b50e0d17dc79c8", Value: big.NewInt(1000000000000000000),})if err != nil { log.Fatal(err)}log.Printf("Signed transaction: %s", signed)string
The signed transaction as a hex string.
Configuration options accepted by this action.
Type: Account
Optional
The account to sign with. If nil, uses the client's account.
Type: *chain.Chain
Optional
The target chain. If there is a mismatch between the wallet's current chain & the target chain, an error will be thrown.
Type: bool
Optional
When true, skips the chain ID mismatch assertion.
All transaction fields from sendTransaction are supported:
To - The transaction recipientValue - Value in weiData - Contract call dataGas - Gas limitGasPrice - Gas price (Legacy transactions)MaxFeePerGas - Max fee per gas (EIP-1559)MaxPriorityFeePerGas - Max priority fee per gas (EIP-1559)Nonce - Transaction nonceType - Transaction typeAccessList - Access list (EIP-2930)AuthorizationList - Authorization list (EIP-7702)Blobs - Blobs (EIP-4844)BlobVersionedHashes - Blob versioned hashes (EIP-4844)MaxFeePerBlobGas - Max fee per blob gas (EIP-4844)eth_signTransaction