parseTransaction
Parses a serialized RLP-encoded transaction into a structured transaction
Parses a serialized RLP-encoded transaction into a structured transaction
Parses a serialized RLP-encoded transaction into a structured Transaction. Supports signed and unsigned transactions of types: Legacy, EIP-2930, EIP-1559, EIP-4844, and EIP-7702.
import "github.com/ChefBingbong/viem-go/utils/transaction"import "github.com/ChefBingbong/viem-go/utils/transaction"
// Parse an EIP-1559 transactiontx, err := transaction.ParseTransaction("0x02ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0")if err != nil { log.Fatal(err)}
fmt.Printf("Type: %s", tx.Type)// Type: eip1559
fmt.Printf("Chain ID: %d", tx.ChainId)// Chain ID: 1
fmt.Printf("To: %s", tx.To)// To: 0x70997970C51812dc3A010C7d01b50e0D17dc79C8(*transaction.Transaction, error)The parsed transaction object with all fields populated based on the transaction type.
stringThe serialized RLP-encoded transaction hex string. Must start with a transaction type prefix (0x00 for legacy, 0x01 for EIP-2930, 0x02 for EIP-1559, 0x03 for EIP-4844, 0x04 for EIP-7702).
tx, _ := transaction.ParseTransaction("0x02ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0")Parses legacy transactions without type prefix.
Parses EIP-2930 transactions with access lists.
Parses EIP-1559 transactions with maxFeePerGas and maxPriorityFeePerGas.
Parses EIP-4844 blob transactions with blob-related fields.
Parses EIP-7702 transactions with authorization lists.