Documentation
¶
Overview ¶
Package transaction provides types and functions for working with Tempo Transactions.
TempoTransactions are Tempo's native account abstraction transaction type that support:
- Batched calls: Execute multiple contract calls in a single transaction
- 2D nonce system: Use sequence keys (nonceKey) for parallel transaction processing
- Fee abstraction: Pay gas fees in stablecoins (e.g., AlphaUSD) instead of native tokens
- Fee payer pattern: Allow third-party fee payers to sponsor transaction gas costs
- Time-based validity: Set activation (validAfter) and expiration (validBefore) times
Basic Usage ¶
Create and serialize a transaction:
tx := transaction.New()
tx.Gas = 100000
tx.AddCall(common.HexToAddress("0x..."), big.NewInt(0), []byte{})
// Sign the transaction
signer, _ := signer.NewSigner("0x...")
transaction.SignTransaction(tx, signer)
// Serialize to hex string
serialized, _ := transaction.Serialize(tx, nil)
// Returns: "0x76..." (ready to broadcast)
Deserialize a transaction:
tx, err := transaction.Deserialize("0x76...")
if err != nil {
log.Fatal(err)
}
Fee Payer Pattern ¶
The fee payer pattern allows a third party to pay gas fees:
// 1. User signs their transaction userTx := transaction.New() // ... configure transaction ... transaction.SignTransaction(userTx, userSigner) // 2. Fee payer adds their signature transaction.AddFeePayerSignature(userTx, feePayerSigner) // 3. Broadcast dual-signed transaction serialized, _ := transaction.Serialize(userTx, nil) // Broadcast to network...
2D Nonce System
Use nonceKey to enable parallel transactions:
// Transaction 1 with sequence A tx1 := transaction.New() tx1.NonceKey = big.NewInt(1) // Sequence A tx1.Nonce = 0 // First in sequence // Transaction 2 with sequence B (can be processed in parallel) tx2 := transaction.New() tx2.NonceKey = big.NewInt(2) // Sequence B tx2.Nonce = 0 // First in sequence
Time-Based Validity ¶
Set transaction validity windows:
tx := transaction.New() tx.ValidAfter = uint64(time.Now().Unix()) // Activate now tx.ValidBefore = uint64(time.Now().Add(1 * time.Hour).Unix()) // Expire in 1 hour
For more details on the TempoTransaction specification, see the Tempo documentation.
Example (BatchTransaction) ¶
Example_batchTransaction demonstrates creating a transaction with multiple calls.
package main
import (
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/tempoxyz/tempo-go/pkg/transaction"
)
func main() {
tx := transaction.NewBuilder(big.NewInt(transaction.ChainIdMainnet)).
SetGas(200000).
SetMaxFeePerGas(big.NewInt(1000000000)).
AddCall(
common.HexToAddress("0x1111111111111111111111111111111111111111"),
big.NewInt(0),
[]byte{},
).
AddCall(
common.HexToAddress("0x2222222222222222222222222222222222222222"),
big.NewInt(0),
[]byte{},
).
AddCall(
common.HexToAddress("0x3333333333333333333333333333333333333333"),
big.NewInt(0),
[]byte{},
).
Build()
fmt.Printf("Transaction has %d calls\n", len(tx.Calls))
}
Output:
Example (ClientUsage) ¶
Example_clientUsage demonstrates using the RPC client.
package main
import (
"context"
"fmt"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/tempoxyz/tempo-go/pkg/client"
"github.com/tempoxyz/tempo-go/pkg/signer"
"github.com/tempoxyz/tempo-go/pkg/transaction"
)
func main() {
rpcClient := client.New(transaction.RpcUrlMainnet)
sgn, _ := signer.NewSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
tx := transaction.NewBuilder(big.NewInt(transaction.ChainIdMainnet)).
SetGas(100000).
SetMaxFeePerGas(big.NewInt(1000000000)).
AddCall(
common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
big.NewInt(0),
[]byte{},
).
Build()
transaction.SignTransaction(tx, sgn)
serialized, _ := transaction.Serialize(tx, nil)
// Send to network (would fail in this example without a real node)
ctx := context.Background()
_, err := rpcClient.SendRawTransaction(ctx, serialized)
// In a real application, check for errors
fmt.Printf("Would send transaction, got error: %v\n", err != nil)
}
Output: Would send transaction, got error: true
Example (FeePayerTransaction) ¶
Example_feePayerTransaction demonstrates the fee payer pattern where a third party pays gas fees.
package main
import (
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/tempoxyz/tempo-go/pkg/signer"
"github.com/tempoxyz/tempo-go/pkg/transaction"
)
func main() {
sender, _ := signer.NewSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
feePayer, _ := signer.NewSigner("0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d")
tx := transaction.NewBuilder(big.NewInt(transaction.ChainIdMainnet)).
SetGas(100000).
SetMaxFeePerGas(big.NewInt(1000000000)).
AddCall(
common.HexToAddress("0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC"),
big.NewInt(0),
[]byte{},
).
Build()
transaction.SignTransaction(tx, sender)
transaction.AddFeePayerSignature(tx, feePayer)
recoveredSender, recoveredFeePayer, err := transaction.VerifyDualSignatures(tx)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Sender: %s, Fee Payer: %s\n",
recoveredSender.Hex()[:10]+"...",
recoveredFeePayer.Hex()[:10]+"...")
}
Output:
Example (SimpleTransaction) ¶
Example_simpleTransaction demonstrates creating, signing, and sending a simple transaction.
package main
import (
"fmt"
"log"
"math/big"
"github.com/ethereum/go-ethereum/common"
"github.com/tempoxyz/tempo-go/pkg/signer"
"github.com/tempoxyz/tempo-go/pkg/transaction"
)
func main() {
sgn, err := signer.NewSigner("0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80")
if err != nil {
log.Fatal(err)
}
tx := transaction.NewBuilder(big.NewInt(transaction.ChainIdMainnet)).
SetGas(100000).
SetMaxFeePerGas(big.NewInt(1000000000)).
SetMaxPriorityFeePerGas(big.NewInt(1000000)).
AddCall(
common.HexToAddress("0x70997970C51812dc3A010C7d01b50e0d17dc79C8"),
big.NewInt(0),
[]byte{},
).
Build()
err = transaction.SignTransaction(tx, sgn)
if err != nil {
log.Fatal(err)
}
serialized, err := transaction.Serialize(tx, nil)
if err != nil {
log.Fatal(err)
}
fmt.Printf("Transaction serialized: %s\n", serialized[:20]+"...")
}
Output:
Index ¶
- Constants
- Variables
- func AddFeePayerSignature(tx *Tx, sgn *signer.Signer) error
- func ComputeHash(serialized string) (common.Hash, error)
- func EncodeTIP20BurnAtData(from common.Address, amount *big.Int) ([]byte, error)
- func EncodeTIP20TransferData(recipient common.Address, amount *big.Int) ([]byte, error)
- func EncodeTIP20TransferWithMemoData(recipient common.Address, amount *big.Int, memo []byte) ([]byte, error)
- func ExpiringNonceKey() *big.Int
- func GetFeePayerSignPayload(tx *Tx, sender common.Address) (common.Hash, error)
- func GetSignPayload(tx *Tx) (common.Hash, error)
- func ParseTopicAddress(topic string) common.Address
- func RecoverSigner(tx *Tx) (signer.RecoveredSigner, error)
- func Serialize(tx *Tx, opts *SerializeOptions) (string, error)
- func SerializeForFeePayerSigning(tx *Tx, sender common.Address) (string, error)
- func SerializeForSigning(tx *Tx) (string, error)
- func SignTransaction(tx *Tx, sgn *signer.Signer) error
- func SignTransactionWith(tx *Tx, s signer.EnvelopeSigner) error
- func VerifyDualSignatures(tx *Tx) (sender, feePayer common.Address, err error)
- func VerifyFeePayerSignature(tx *Tx, sender common.Address) (common.Address, error)
- func VerifySignature(tx *Tx) (common.Address, error)
- type AccessList
- type AccessTuple
- type Builder
- func (b *Builder) AddAccessListEntry(address common.Address, storageKeys []common.Hash) *Builder
- func (b *Builder) AddCall(to common.Address, value *big.Int, data []byte) *Builder
- func (b *Builder) AddContractCreation(value *big.Int, data []byte) *Builder
- func (b *Builder) Build() *Tx
- func (b *Builder) BuildAndValidate() (*Tx, error)
- func (b *Builder) SetExpiringNonce(nonce uint64) *Builder
- func (b *Builder) SetFeeToken(token common.Address) *Builder
- func (b *Builder) SetGas(gas uint64) *Builder
- func (b *Builder) SetMaxFeePerGas(maxFee *big.Int) *Builder
- func (b *Builder) SetMaxPriorityFeePerGas(maxPriorityFee *big.Int) *Builder
- func (b *Builder) SetNonce(nonce uint64) *Builder
- func (b *Builder) SetNonceKey(nonceKey *big.Int) *Builder
- func (b *Builder) SetSponsored(sponsored bool) *Builder
- func (b *Builder) SetValidAfter(validAfter uint64) *Builder
- func (b *Builder) SetValidBefore(validBefore uint64) *Builder
- type Call
- type SerializeFormat
- type SerializeOptions
- type Tx
- func (tx *Tx) Clone() *Tx
- func (tx *Tx) HasFeePayerSignature() bool
- func (tx *Tx) Hash() (common.Hash, error)
- func (tx *Tx) IsActive(currentTime uint64) bool
- func (tx *Tx) IsExpired(currentTime uint64) bool
- func (tx *Tx) IsExpiringNonce() bool
- func (tx *Tx) String() string
- func (tx *Tx) Validate() error
Examples ¶
Constants ¶
const ( // TIP20TransferSelector is the transfer(address,uint256) selector without a 0x prefix. TIP20TransferSelector = "a9059cbb" // TIP20ApproveSelector is the approve(address,uint256) selector without a 0x prefix. TIP20ApproveSelector = "095ea7b3" // TIP20TransferWithMemoSelector is the transferWithMemo(address,uint256,bytes32) selector without a 0x prefix. TIP20TransferWithMemoSelector = "95777d59" // TIP20BurnAtSelector is the burnAt(address,uint256) selector without a 0x prefix. // burnAt is available from T12 (TIP-1006). TIP20BurnAtSelector = "9803f216" )
const ( // SignatureTypeSecp256k1 is the signature type for standard ECDSA signatures SignatureTypeSecp256k1 = "secp256k1" // SignatureTypeP256 is the signature type for P256 signatures SignatureTypeP256 = "p256" // SignatureTypeWebAuthn is the signature type for WebAuthn signatures SignatureTypeWebAuthn = "webauthn" // ChainIdMainnet is the chain ID for Tempo mainnet. ChainIdMainnet = 4217 // ChainIdModerato is the chain ID for the Tempo Moderato testnet. ChainIdModerato = 42431 // ChainIdDevnet is the chain ID for the Tempo devnet. ChainIdDevnet = 31318 // RpcUrlMainnet is the RPC URL for Tempo mainnet. RpcUrlMainnet = "https://rpc.tempo.xyz" // RpcUrlModerato is the RPC URL for the Tempo Moderato testnet. RpcUrlModerato = "https://rpc.moderato.tempo.xyz" // DefaultNonceKey is the standard nonce key for sequential transactions. DefaultNonceKey = 0 )
Constants
Variables ¶
var ( // ErrNoSignature is returned when a transaction has no sender signature. ErrNoSignature = errors.New("transaction has no signature") // ErrNoFeePayerSignature is returned when a transaction has no fee payer signature. ErrNoFeePayerSignature = errors.New("transaction has no fee payer signature") // ErrMissingSenderSignature is returned when attempting to add a fee payer signature // to a transaction that doesn't have a sender signature yet. ErrMissingSenderSignature = errors.New("transaction must have sender signature before adding fee payer signature") // ErrInvalidTransaction is returned when a transaction cannot be parsed or is malformed. ErrInvalidTransaction = errors.New("invalid transaction") // ErrInvalidTransactionType is returned when a transaction has an unexpected type prefix. ErrInvalidTransactionType = errors.New("invalid transaction type") // ErrUnsupportedSignatureType is returned when attempting to verify a signature type // that cannot be verified via ecrecover (e.g., P256, WebAuthn, Keychain). ErrUnsupportedSignatureType = errors.New("unsupported signature type for verification") // ErrInvalidSignatureType is returned when a signature type is not allowed for the operation. // For example, fee payer signatures must be secp256k1. ErrInvalidSignatureType = errors.New("invalid signature type") )
Sentinel errors for common error conditions. Use errors.Is() to check for specific error types.
var ( // PathUSDAddress is Tempo's native fee token address. PathUSDAddress = common.HexToAddress("0x20c0000000000000000000000000000000000000") // FeeManagerAddress is the fee manager precompile. FeeManagerAddress = common.HexToAddress("0xfeec000000000000000000000000000000000000") // StablecoinDEXAddress is the stablecoin DEX precompile. StablecoinDEXAddress = common.HexToAddress("0xdec0000000000000000000000000000000000000") // AccountKeychainAddress is the account keychain precompile. AccountKeychainAddress = common.HexToAddress("0xaaaaaaaa00000000000000000000000000000000") // TIP20TransferTopic is the Transfer(address,address,uint256) event topic. TIP20TransferTopic = crypto.Keccak256Hash([]byte("Transfer(address,address,uint256)")) // TIP20TransferWithMemoTopic is the TransferWithMemo(address,address,uint256,bytes32) event topic. TIP20TransferWithMemoTopic = crypto.Keccak256Hash([]byte("TransferWithMemo(address,address,uint256,bytes32)")) // TIP20BurnAtRole is the BURN_AT_ROLE identifier required to call burnAt (T12+). TIP20BurnAtRole = crypto.Keccak256Hash([]byte("BURN_AT_ROLE")) )
Common Tempo token and precompile addresses.
var ( // AlphaUSDAddress is the address of the AlphaUSD stablecoin on Tempo. AlphaUSDAddress = common.HexToAddress("0x20c0000000000000000000000000000000000001") // NonceManagerAddress is the address of the Tempo Nonce Manager contract. // Used for querying nonces in the 2D nonce system. NonceManagerAddress = common.HexToAddress("0x4e4F4E4345000000000000000000000000000000") )
Common Tempo contract addresses.
Functions ¶
func AddFeePayerSignature ¶
AddFeePayerSignature adds the fee payer signature to a transaction. The transaction must already have a sender signature.
func ComputeHash ¶
ComputeHash computes the Keccak256 hash of a serialized transaction. This is useful for verifying transaction hashes or implementing custom signing logic.
func EncodeTIP20BurnAtData ¶ added in v0.6.1
EncodeTIP20BurnAtData encodes TIP-20 burnAt(address,uint256) calldata. The caller must hold BURN_AT_ROLE on the token; burnAt is available from T12 (TIP-1006).
func EncodeTIP20TransferData ¶ added in v0.4.1
EncodeTIP20TransferData encodes TIP-20 transfer(address,uint256) calldata.
func EncodeTIP20TransferWithMemoData ¶ added in v0.4.1
func EncodeTIP20TransferWithMemoData(recipient common.Address, amount *big.Int, memo []byte) ([]byte, error)
EncodeTIP20TransferWithMemoData encodes TIP-20 transferWithMemo(address,uint256,bytes32) calldata.
func ExpiringNonceKey ¶ added in v0.6.1
ExpiringNonceKey returns a copy of the nonce key that marks an expiring nonce transaction (TIP-1009): 2^256 - 1. Expiring nonce transactions use validBefore for replay protection instead of sequential nonce state.
func GetFeePayerSignPayload ¶
GetFeePayerSignPayload computes the hash that the fee payer should sign. This uses a different serialization format (0x78 prefix) and includes the sender address.
func GetSignPayload ¶
GetSignPayload computes the hash that the sender should sign.
func ParseTopicAddress ¶ added in v0.4.1
ParseTopicAddress extracts the indexed address stored in an event topic. Invalid topics return the zero address.
func RecoverSigner ¶ added in v0.7.0
func RecoverSigner(tx *Tx) (signer.RecoveredSigner, error)
RecoverSigner verifies the sender signature of any type and returns its signer. For a Keychain signature, Account is the user address and KeyID the access key: whether the account authorized that key is on-chain state the caller must check (the AccountKeychain precompile).
func Serialize ¶
func Serialize(tx *Tx, opts *SerializeOptions) (string, error)
Serialize serializes a TempoTransaction to hex string. Returns a string starting with TempoTransaction prefix "0x76" or "0x78" (if fee payer format).
func SerializeForFeePayerSigning ¶
SerializeForFeePayerSigning serializes a transaction for fee payer signing. This uses the 0x78 prefix and includes the sender address. IMPORTANT: Must remove BOTH sender and fee payer signatures (per tempo.ts reference).
func SerializeForSigning ¶
SerializeForSigning serializes a transaction for sender signing (without signatures). Per Tempo Transaction spec (https://docs.tempo.xyz/protocol/transactions/spec-tempo-transaction):
- fee_token is SKIPPED (encoded as 0x80) when fee payer is involved
- fee_token is INCLUDED when no fee payer (self-paid transaction)
- feePayerSignatureOrSender field encoding:
- If AwaitingFeePayer=true or FeePayerSignature is set: uses 0x00 marker
- Otherwise: uses empty bytes (0x80)
This allows the fee payer to specify the fee token without invalidating the sender's signature.
func SignTransaction ¶
SignTransaction signs a transaction with the sender's private key. This creates the sender signature envelope and adds it to the transaction.
func SignTransactionWith ¶ added in v0.7.0
func SignTransactionWith(tx *Tx, s signer.EnvelopeSigner) error
SignTransactionWith signs a transaction with any envelope signer: a secp256k1 Signer, a P256Signer or a WebAuthnSigner. The sender is the signer's address.
func VerifyDualSignatures ¶
VerifyDualSignatures verifies both sender and fee payer signatures. Returns sender address, fee payer address, and any error.
func VerifyFeePayerSignature ¶
VerifyFeePayerSignature verifies the fee payer signature on a transaction. Per Tempo Transaction spec, fee payer signatures MUST be secp256k1. This is enforced by the type system: FeePayerSignature is *signer.Signature (not SignatureEnvelope).
func VerifySignature ¶
VerifySignature verifies the sender signature on a transaction and returns the sender: the recovered secp256k1 address, or the address of the public key of a P256 or WebAuthn signature. Keychain (access key) signatures are rejected with ErrUnsupportedSignatureType: verify them with RecoverSigner or keychain.VerifyAccessKeySignature, then check the key's authorization on chain.
Types ¶
type AccessTuple ¶
type AccessTuple struct {
Address common.Address `json:"address"`
StorageKeys []common.Hash `json:"storageKeys"`
}
AccessTuple represents a single entry in an access list.
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
Builder provides a fluent interface for constructing transactions. This makes it easier to build complex transactions with many optional fields.
Example usage:
tx := transaction.NewBuilder().
SetGas(100000).
AddCall(toAddress, big.NewInt(0), data).
SetFeeToken(transaction.AlphaUSDAddress).
Build()
func NewBuilder ¶
NewBuilder creates a new transaction builder. Defaults to Tempo mainnet. An optional chain ID can be provided to target a different network.
func (*Builder) AddAccessListEntry ¶
AddAccessListEntry adds an entry to the access list.
func (*Builder) AddCall ¶
AddCall adds a call to the transaction. The to address can be nil for contract creation. Value and data can be nil, they will be converted to empty bytes/zero.
func (*Builder) AddContractCreation ¶
AddContractCreation adds a contract creation call to the transaction.
func (*Builder) Build ¶
Build returns the constructed transaction. Note: This does not validate the transaction. Call Validate() separately if needed.
func (*Builder) BuildAndValidate ¶
BuildAndValidate returns the constructed transaction after validating it. This is a convenience method that ensures the transaction is valid before returning. Returns an error if validation fails.
func (*Builder) SetExpiringNonce ¶ added in v0.6.1
SetExpiringNonce marks the transaction as an expiring nonce transaction and sets its nonce discriminator. Pair it with SetValidBefore.
From T12 (TIP-1106), the nonce of an expiring nonce transaction is an opaque uint64 discriminator: distinct values let otherwise identical transactions be submitted in parallel within the same validity window. The SDK does not generate or track discriminators: callers choose the values and must keep them distinct for transactions that should not deduplicate. Before T12 the network requires nonce == 0.
func (*Builder) SetFeeToken ¶
SetFeeToken sets the token to use for paying gas fees.
func (*Builder) SetMaxFeePerGas ¶
SetMaxFeePerGas sets the maximum fee per gas.
func (*Builder) SetMaxPriorityFeePerGas ¶
SetMaxPriorityFeePerGas sets the maximum priority fee per gas.
func (*Builder) SetNonceKey ¶
SetNonceKey sets the nonce key (sequence key) for 2D nonce system.
func (*Builder) SetSponsored ¶ added in v0.2.1
SetSponsored marks this transaction as sponsored (awaiting a fee payer signature). Per the Tempo Transaction spec, sponsored transactions encode fee_token as empty and fee_payer_signature field as 0x00 in the sender's signing payload. This MUST be called before SignTransaction if a fee payer will be added later.
func (*Builder) SetValidAfter ¶
SetValidAfter sets the activation timestamp for the transaction.
func (*Builder) SetValidBefore ¶
SetValidBefore sets the expiration timestamp for the transaction.
type Call ¶
type Call struct {
To *common.Address `json:"to"` // Target address (nil for contract creation)
Value *big.Int `json:"value"` // Amount to send in wei
Data []byte `json:"data"` // Call data
}
Call represents a single call within a TempoTransaction. Transactions can batch multiple calls together.
type SerializeFormat ¶
type SerializeFormat int
SerializeFormat specifies the serialization format for a transaction.
const ( // FormatNormal uses TempoTransaction prefix (0x76) for standard signing (default). FormatNormal SerializeFormat = iota // FormatFeePayer uses TempoTransaction fee payer prefix (0x78) for fee payer signing. FormatFeePayer )
func (SerializeFormat) String ¶
func (f SerializeFormat) String() string
String returns a human-readable representation of the serialize format. Implements the fmt.Stringer interface.
type SerializeOptions ¶
type SerializeOptions struct {
// Format specifies the serialization format.
// FormatNormal (default) uses TempoTransaction prefix (0x76) for standard signing.
// FormatFeePayer uses TempoTransaction fee payer prefix (0x78) for fee payer signing.
Format SerializeFormat
// Sender is the sender address, required when Format is FormatFeePayer.
Sender common.Address
// ForSigning indicates this is for computing a signing hash (not final broadcast).
// When true and fee payer is involved, fee_token is skipped per Tempo spec.
ForSigning bool
}
SerializeOptions contains options for serializing a transaction.
type Tx ¶
type Tx struct {
// Core transaction fields
ChainID *big.Int `json:"chainId"`
MaxPriorityFeePerGas *big.Int `json:"maxPriorityFeePerGas"`
MaxFeePerGas *big.Int `json:"maxFeePerGas"`
Gas uint64 `json:"gas"`
Calls []Call `json:"calls"`
AccessList AccessList `json:"accessList"`
NonceKey *big.Int `json:"nonceKey"` // uint256 nonce key: 2D sequence key, or ExpiringNonceKey for expiring nonces
Nonce uint64 `json:"nonce"` // Current value of the sequence key
ValidBefore uint64 `json:"validBefore"` // Optional expiration timestamp
ValidAfter uint64 `json:"validAfter"` // Optional activation timestamp
FeeToken common.Address `json:"feeToken"` // Stablecoin address for fees (e.g., AlphaUSD)
// KeyAuthorization holds the decoded RLP keyAuthorization tuple for access key
// transactions. Preserved as-is for re-serialization. Nil when not present.
KeyAuthorization []interface{} `json:"keyAuthorization,omitempty"`
// Signatures
Signature *signer.SignatureEnvelope `json:"signature"` // Sender signature
FeePayerSignature *signer.Signature `json:"feePayerSignature"` // Fee payer signature (nil if not signed)
// AwaitingFeePayer indicates the transaction was marked for fee payer sponsorship.
// When true, serialization uses 0x00 marker
// This is set when deserializing a transaction with feePayerSignature=null marker.
AwaitingFeePayer bool `json:"-"`
From common.Address `json:"from,omitempty"` // Sender address (recovered from signature)
}
Tx represents a Tempo Transaction
func Deserialize ¶
Deserialize parses a serialized TempoTransaction. The serialized transaction must start with TempoTransaction prefix "0x76".
RLP Structure: [
chainId, // 0 maxPriorityFeePerGas, // 1 maxFeePerGas, // 2 gas, // 3 calls, // 4 Array of [to, value, data] tuples accessList, // 5 Array of [address, [storageKeys]] tuples nonceKey, // 6 nonce, // 7 validBefore, // 8 validAfter, // 9 feeToken, // 10 feePayerSignatureOrSender, // 11 Signature [yParity, r, s] or "0x00" or empty authorizationList, // 12 Empty array (reserved for EIP-7702) keyAuthorizationOrSignature, // 13 (optional) keyAuthorization (list) or signatureEnvelope (bytes) maybeSignature, // 14 (optional) signatureEnvelope when field 13 is keyAuthorization
]
Field counts:
- 13 fields: unsigned (no keyAuthorization, no signature)
- 14 fields: signed (no keyAuthorization) OR unsigned with keyAuthorization
- 15 fields: signed with keyAuthorization (access keys)
func NewDefault ¶
NewDefault creates a new transaction with default values for the given chain ID.
func (*Tx) Clone ¶
Clone creates a deep copy of the transaction. This is useful when you want to create variations of a transaction without modifying the original. Note that signatures are intentionally NOT copied since they are tied to specific transaction state.
Example usage:
template := transaction.NewDefault(transaction.ChainIdMainnet) // or omit for mainnet
template.SetGas(100000)
// Create variations for different recipients
tx1 := template.Clone()
tx1.Calls = []transaction.Call{{To: &recipient1, Value: amount1}}
tx2 := template.Clone()
tx2.Calls = []transaction.Call{{To: &recipient2, Value: amount2}}
func (*Tx) HasFeePayerSignature ¶
HasFeePayerSignature returns true if the transaction has a fee payer signature.
func (*Tx) Hash ¶
Hash computes the hash of a fully signed transaction. This returns the transaction hash that would appear on-chain: keccak256 of the serialized bytes, with secp256k1 recovery ids encoded as 27/28 as the node does. The transaction must be signed before calling this method.
func (*Tx) IsExpiringNonce ¶ added in v0.6.1
IsExpiringNonce reports whether the transaction uses the expiring nonce key.