Documentation
¶
Overview ¶
Package eip3009 implements EIP-3009 transferWithAuthorization typed data building and signing for USDC gasless transfers.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func EncodeCalldata ¶
func EncodeCalldata(auth *Authorization) []byte
EncodeCalldata ABI-encodes the transferWithAuthorization call for on-chain submission. Layout: selector(4) + from(32) + to(32) + value(32) + validAfter(32) + validBefore(32) + nonce(32) + v(32) + r(32) + s(32).
func TypedDataHash ¶
TypedDataHash computes the EIP-712 hash to be signed for a transferWithAuthorization on the given chain and USDC contract.
Types ¶
type Authorization ¶
type Authorization struct {
From common.Address
To common.Address
Value *big.Int
ValidAfter *big.Int
ValidBefore *big.Int
Nonce [32]byte
V uint8
R, S [32]byte
}
Authorization is a fully signed EIP-3009 transferWithAuthorization.
func Sign ¶
func Sign( ctx context.Context, wallet WalletSigner, auth *UnsignedAuth, chainID int64, usdcAddr common.Address, ) (*Authorization, error)
Sign computes the typed data hash and signs it with the provided wallet.
type UnsignedAuth ¶
type UnsignedAuth struct {
From common.Address
To common.Address
Value *big.Int
ValidAfter *big.Int
ValidBefore *big.Int
Nonce [32]byte
}
UnsignedAuth holds the authorization parameters before signing.
func NewUnsigned ¶
NewUnsigned creates an unsigned EIP-3009 authorization with a random nonce. validAfter is set to now; validBefore is set to the given deadline.
type WalletSigner ¶
type WalletSigner interface {
// SignTransaction signs raw bytes (no additional hashing).
SignTransaction(ctx context.Context, rawTx []byte) ([]byte, error)
// SignMessage signs an arbitrary message (applies keccak256 before signing).
SignMessage(ctx context.Context, message []byte) ([]byte, error)
Address(ctx context.Context) (string, error)
}
WalletSigner abstracts wallet signing to avoid direct wallet package imports.