assertRequest
Validates a transaction request and returns an error if invalid
Loading...
Validates a transaction request and returns an error if invalid
Validates a transaction request and returns an error if the request is invalid. Checks address validity and fee constraints.
import "github.com/ChefBingbong/viem-go/utils/transaction"import "math/big"import "github.com/ChefBingbong/viem-go/utils/transaction"import "math/big"
err := transaction.AssertRequest(transaction.AssertRequestParams{ Account: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", To: "0x1234567890123456789012345678901234567890", MaxFeePerGas: big.NewInt(1000000000), MaxPriorityFeePerGas: big.NewInt(100000000),})if err != nil { log.Fatal(err)}errorReturns nil if the request is valid, or an error describing the validation failure.
transaction.AssertRequestParamsThe transaction request parameters to validate.
params := transaction.AssertRequestParams{ Account: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", To: "0x1234567890123456789012345678901234567890", MaxFeePerGas: big.NewInt(1000000000), MaxPriorityFeePerGas: big.NewInt(100000000),}
err := transaction.AssertRequest(params)stringThe account address. Must be a valid Ethereum address format if provided.
params := transaction.AssertRequestParams{ Account: "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266", // ...}stringThe recipient address. Must be a valid Ethereum address format if provided.
params := transaction.AssertRequestParams{ To: "0x1234567890123456789012345678901234567890", // ...}*big.IntThe maximum fee per gas. Must not exceed max uint256, and must be >= MaxPriorityFeePerGas if both are provided.
params := transaction.AssertRequestParams{ MaxFeePerGas: big.NewInt(1000000000), // ...}*big.IntThe maximum priority fee per gas. Must not exceed MaxFeePerGas if both are provided.
params := transaction.AssertRequestParams{ MaxPriorityFeePerGas: big.NewInt(100000000), // ...}This function validates:
0x prefix (if provided)0x prefix (if provided)MaxPriorityFeePerGas must not exceed MaxFeePerGas (if both are provided)