getSerializedTransactionType
Determines the transaction type from a serialized transaction
Loading...
Determines the transaction type from a serialized transaction
Determines the transaction type from a serialized transaction hex string by examining the type prefix.
import "github.com/ChefBingbong/viem-go/utils/transaction"import "github.com/ChefBingbong/viem-go/utils/transaction"
// Get type from serialized transactiontxType, err := transaction.GetSerializedTransactionType("0x02ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0")if err != nil { log.Fatal(err)}fmt.Printf("Type: %s", txType)// Type: eip1559(transaction.TransactionType, error)The transaction type: "legacy", "eip2930", "eip1559", "eip4844", or "eip7702".
stringThe serialized transaction hex string.
txType, _ := transaction.GetSerializedTransactionType("0x02ef0182031184773594008477359400809470997970c51812dc3a010c7d01b50e0d17dc79c8880de0b6b3a764000080c0")The transaction type is determined from the first byte(s) of the serialized transaction:
0x01 prefix0x02 prefix0x03 prefix0x04 prefixGetTransactionType instead