Documentation ¶
Index ¶
- Variables
- func ABIEncodeMethodCalldata(methodSig string, argValues []interface{}) ([]byte, error)
- func ABIEncodeMethodCalldataFromStringValues(methodSig string, argStringValues []string) ([]byte, error)
- func ABIEncodeMethodCalldataFromStringValuesAny(methodSig string, argStringValues []any) ([]byte, error)
- func ABIMarshalStringValues(argTypes []string, input []byte) ([]string, error)
- func ABIPackArguments(argTypes []string, argValues []interface{}) ([]byte, error)
- func ABIPackArgumentsHex(argTypes []string, argValues []interface{}) (string, error)
- func ABIUnmarshalStringValues(argTypes []string, stringValues []string) ([]any, error)
- func ABIUnmarshalStringValuesAny(argTypes []string, stringValues []any) ([]any, error)
- func ABIUnpack(exprSig string, input []byte, argValues []interface{}) error
- func ABIUnpackAndStringify(exprSig string, input []byte) ([]string, error)
- func ABIUnpackArguments(argTypes []string, input []byte) ([]interface{}, error)
- func ABIUnpackArgumentsByRef(argTypes []string, input []byte, outArgValues []interface{}) error
- func AbiCoder(argTypes []string, argValues []interface{}) ([]byte, error)deprecated
- func AbiCoderHex(argTypes []string, argValues []interface{}) (string, error)deprecated
- func AbiDecodeExpr(expr string, input []byte, argValues []interface{}) errordeprecated
- func AbiDecodeExprAndStringify(expr string, input []byte) ([]string, error)deprecated
- func AbiDecoder(argTypes []string, input []byte, outArgValues []interface{}) errordeprecated
- func AbiDecoderWithReturnedValues(argTypes []string, input []byte) ([]interface{}, error)deprecated
- func AbiEncodeMethodCalldata(methodExpr string, argValues []interface{}) ([]byte, error)deprecated
- func AbiEncodeMethodCalldataFromStringValues(methodExpr string, argStringValues []string) ([]byte, error)deprecated
- func AbiEncodeMethodCalldataFromStringValuesAny(methodSig string, argStringValues []any) ([]byte, error)deprecated
- func AbiMarshalStringValues(argTypes []string, input []byte) ([]string, error)deprecated
- func AbiUnmarshalStringValues(argTypes []string, stringValues []string) ([]any, error)deprecated
- func BytesToBytes32(slice []byte) [32]byte
- func EncodeContractCall(callDef ContractCallDef) (string, error)
- func EventTopicHash(event string) (ethkit.Hash, string, error)
- func FunctionSignature(functionExpr string) string
- func HexDecode(h string) ([]byte, error)
- func HexDecodeBigIntArray(bigNumsHex []string) ([]*big.Int, error)
- func HexDecodeBytes32(h string) ([32]byte, error)
- func HexEncode(h []byte) string
- func HexEncodeBigIntArray(bigNums []*big.Int) ([]string, error)
- func HexTrimLeadingZeros(hex string) (string, error)
- func Keccak256(input []byte) []byte
- func Keccak256Hash(input []byte) common.Hash
- func MustHexDecode(h string) []byte
- func MustNewArrayTypeTuple(components []abi.ArgumentMarshaling) abi.Type
- func MustNewType(str string) abi.Type
- func PadZeros(array []byte, totalLength int) ([]byte, error)
- func PaddedAddress(address string) string
- func SHA3(input []byte) common.Hash
- func SolidityPack(argTypes []string, argValues []interface{}) ([]byte, error)
- func SolidityPackHex(argTypes []string, argValues []interface{}) (string, error)
- func StringifyValues(values []any) ([]string, error)
- func ValidateEventSig(eventSig string) (bool, error)
- type ABI
- func (d *ABI) AddABIBySigOrJSON(abiSigOrJSON string, isEvent bool) ([]string, error)
- func (d *ABI) AddABIFromJSON(abiJSON string) error
- func (d *ABI) AddABISignature(abiSig ABISignature, isEvent bool) (string, error)
- func (d *ABI) AddEvent(eventSig string) (string, error)
- func (d *ABI) AddMethod(methodSig string) (string, error)
- func (d *ABI) EncodeMethodCalldata(methodName string, argValues []interface{}) ([]byte, error)
- func (d *ABI) EncodeMethodCalldataFromStringValues(methodName string, argStringValues []string) ([]byte, error)
- func (d *ABI) EncodeMethodCalldataFromStringValuesAny(methodName string, argStringValues []any) ([]byte, error)
- func (d *ABI) GetEventABI(eventName string) (abi.Event, bool)
- func (d *ABI) GetEventABISignature(eventName string) (ABISignature, bool)
- func (d *ABI) GetMethodABI(methodName string) (abi.Method, bool)
- func (d *ABI) GetMethodABISignature(methodName string) (ABISignature, bool)
- func (d *ABI) RawABI() abi.ABI
- func (d *ABI) SetABI(rawABI abi.ABI) error
- type ABISignature
- func DecodeTransactionLogByContractABI(txnLog types.Log, contractABI abi.ABI) (ABISignature, []interface{}, bool, error)
- func DecodeTransactionLogByContractABIAsHex(txnLog types.Log, contractABI abi.ABI) (ABISignature, []string, bool, error)
- func DecodeTransactionLogByContractABIJSON(txnLog types.Log, contractABIJSON string) (ABISignature, []interface{}, bool, error)
- func DecodeTransactionLogByEventSig(txnLog types.Log, eventSig string) (ABISignature, []interface{}, bool, error)
- func DecodeTransactionLogByEventSigAsHex(txnLog types.Log, eventSig string) (ABISignature, []string, bool, error)
- func ParseABISignature(abiSignature string) (ABISignature, error)
- type ContractCallDef
- type EventDecoder
- func (d *EventDecoder) DecodeLog(log types.Log) (ABISignature, []interface{}, bool, error)
- func (d *EventDecoder) DecodeLogAsHex(log types.Log) (ABISignature, []string, bool, error)
- func (d *EventDecoder) EventDefList() []ABISignature
- func (d *EventDecoder) RegisterContractABI(contractABI abi.ABI, eventNames ...string) error
- func (d *EventDecoder) RegisterContractABIJSON(contractABIJSON string, eventNames ...string) error
- func (d *EventDecoder) RegisterEventSig(eventSig ...string) error
- func (d *EventDecoder) TopicsList() []string
- func (d *EventDecoder) TopicsMap() map[string]struct{}
- type MerkleTree
- type Options
- type Proof
- type TypedData
- func (t *TypedData) Encode() ([]byte, []byte, error)
- func (t *TypedData) EncodeDigest() ([]byte, error)
- func (t *TypedData) HashStruct(primaryType string, data map[string]interface{}) ([]byte, error)
- func (t *TypedData) MarshalJSON() ([]byte, error)
- func (t *TypedData) UnmarshalJSON(data []byte) error
- type TypedDataArgument
- type TypedDataDomain
- type TypedDataTypes
Constants ¶
This section is empty.
Variables ¶
var DefaultMerkleTreeOptions = Options{ SortLeaves: true, SortPairs: true, }
Functions ¶
func ABIEncodeMethodCalldata ¶ added in v1.28.0
func ABIEncodeMethodCalldataFromStringValues ¶ added in v1.28.0
func ABIEncodeMethodCalldataFromStringValuesAny ¶ added in v1.28.0
func ABIMarshalStringValues ¶ added in v1.28.0
func ABIPackArguments ¶ added in v1.28.0
func ABIPackArgumentsHex ¶ added in v1.28.0
func ABIUnmarshalStringValues ¶ added in v1.28.0
AbiUnmarshalStringValues will take an array of ethereum types as string values, and decode the string values to runtime objects. This allows simple string value input from an app or user, and converts them to the appropriate runtime objects.
The common use for this method is to pass a JSON object of string values for an abi method and have it properly encode to the native abi types.
func ABIUnmarshalStringValuesAny ¶ added in v1.28.0
AbiUnmarshalStringValuesAny will take an array of ethereum types as string values, and decode the string values to runtime objects. This allows simple string value input from an app or user, and converts them to the appropriate runtime objects.
NOTE: this is a variant of AbiUnmarshalStringValues but the `stringValues` argument type is []any, in order to support input types of array of strings for abi types like `address[]` and tuples.
For example, some valid inputs:
- AbiUnmarshalStringValuesAny([]string{"address","uint256"}, []any{"0x1234...", "543"}) returns []interface{}{common.HexToAddress("0x1234..."), big.NewInt(543)}
- AbiUnmarshalStringValuesAny([]string{"address[]", []any{[]string{"0x1234...", "0x5678..."}}) returns []interface{}{[]common.Address{common.HexToAddress("0x1234..."), common.HexToAddress("0x5678...")}}
- AbiUnmarshalStringValuesAny([]string{"(address,uint256)"}, []any{[]any{"0x1234...", "543"}}) returns []interface{}{[]interface{}{common.HexToAddress("0x1234..."), big.NewInt(543)}}
The common use for this method is to pass a JSON object of string values for an abi method and have it properly encode to the native abi types.
func ABIUnpackAndStringify ¶ added in v1.28.0
TODO: change expr argument to abiXX like abiExprOrJSON
func ABIUnpackArguments ¶ added in v1.28.0
func ABIUnpackArgumentsByRef ¶ added in v1.28.0
func AbiCoderHex
deprecated
func AbiDecodeExpr
deprecated
func AbiDecodeExprAndStringify
deprecated
func AbiDecoder
deprecated
func AbiDecoderWithReturnedValues
deprecated
func AbiEncodeMethodCalldata
deprecated
func AbiEncodeMethodCalldataFromStringValues
deprecated
func AbiEncodeMethodCalldataFromStringValuesAny
deprecated
added in
v1.28.0
func AbiMarshalStringValues
deprecated
func AbiUnmarshalStringValues
deprecated
AbiUnmarshalStringValues will take an array of ethereum types as string values, and decode the string values to runtime objects. This allows simple string value input from an app or user, and converts them to the appropriate runtime objects.
The common use for this method is to pass a JSON object of string values for an abi method and have it properly encode to the native abi types.
Deprecated: use ABIUnmarshalStringValues instead
func BytesToBytes32 ¶
func EncodeContractCall ¶ added in v1.28.0
func EncodeContractCall(callDef ContractCallDef) (string, error)
EncodeContractCall encodes a contract call as a hex encoded calldata.
func EventTopicHash ¶ added in v1.24.11
EventTopicHash returns the keccak256 hash of the event signature
e.g. "Transfer(address indexed from, address indexed to, uint256 value)" will return 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef
func FunctionSignature ¶
func HexDecodeBytes32 ¶
func HexTrimLeadingZeros ¶
func Keccak256Hash ¶ added in v1.17.0
func MustHexDecode ¶
func MustNewArrayTypeTuple ¶ added in v1.4.1
func MustNewArrayTypeTuple(components []abi.ArgumentMarshaling) abi.Type
func MustNewType ¶ added in v1.4.1
func PaddedAddress ¶ added in v1.28.0
func SolidityPack ¶
func SolidityPackHex ¶
func StringifyValues ¶
func ValidateEventSig ¶ added in v1.26.3
Types ¶
type ABI ¶ added in v1.28.0
type ABI struct {
// contains filtered or unexported fields
}
func (*ABI) AddABIBySigOrJSON ¶ added in v1.28.0
func (*ABI) AddABIFromJSON ¶ added in v1.28.0
func (*ABI) AddABISignature ¶ added in v1.28.0
func (d *ABI) AddABISignature(abiSig ABISignature, isEvent bool) (string, error)
func (*ABI) EncodeMethodCalldata ¶ added in v1.28.0
EncodeMethodCalldata encodes the abi method arguments into calldata bytes. It's expected that `argValues` are runtime types, ie. common.Address, or big.Int, etc.
func (*ABI) EncodeMethodCalldataFromStringValues ¶ added in v1.28.0
func (d *ABI) EncodeMethodCalldataFromStringValues(methodName string, argStringValues []string) ([]byte, error)
EncodeMethodCalldataFromStringValues decodes the abi method argument string values into runtime types, and then encodes the abi method arguments into calldata bytes.
The difference between this method and EncodeMethodCalldataFromStringValuesAny are just argument types for convenience.
func (*ABI) EncodeMethodCalldataFromStringValuesAny ¶ added in v1.28.0
func (d *ABI) EncodeMethodCalldataFromStringValuesAny(methodName string, argStringValues []any) ([]byte, error)
EncodeMethodCalldataFromStringValuesAny decodes the abi method argument string values into runtime types, and then encodes the abi method arguments into calldata bytes.
NOTE: also see the EncodeContractCall() function, which has more capabilities and supports nested encoding.
func (*ABI) GetEventABI ¶ added in v1.28.0
func (*ABI) GetEventABISignature ¶ added in v1.28.0
func (d *ABI) GetEventABISignature(eventName string) (ABISignature, bool)
func (*ABI) GetMethodABI ¶ added in v1.28.0
func (*ABI) GetMethodABISignature ¶ added in v1.28.0
func (d *ABI) GetMethodABISignature(methodName string) (ABISignature, bool)
type ABISignature ¶ added in v1.28.0
type ABISignature struct { Name string // the method or event name, ie. Transfer Signature string // the abi signature string, ie. Transfer(address,address,uint256) Hash string // the method/event topic hash, ie. 0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef ArgTypes []string // the method/event arg types, ie. [address, address, uint256] ArgNames []string // the method/event arg names, ie. [from, to, value] or ["","",""] ArgIndexed []bool // the event arg indexed flag, ie. [true, false, true] NumIndexed int }
func DecodeTransactionLogByContractABI ¶ added in v1.26.2
func DecodeTransactionLogByContractABIAsHex ¶ added in v1.26.5
func DecodeTransactionLogByContractABIJSON ¶ added in v1.26.2
func DecodeTransactionLogByContractABIJSON(txnLog types.Log, contractABIJSON string) (ABISignature, []interface{}, bool, error)
..
func DecodeTransactionLogByEventSig ¶ added in v1.26.2
func DecodeTransactionLogByEventSigAsHex ¶ added in v1.26.5
func ParseABISignature ¶ added in v1.28.0
func ParseABISignature(abiSignature string) (ABISignature, error)
func (ABISignature) String ¶ added in v1.28.0
func (e ABISignature) String() string
type ContractCallDef ¶ added in v1.28.0
type ContractCallDef struct { // ABI can be an abi signature ie. "transfer(address,uint256)" // or it can be a JSON encoded ABI string ABI string `json:"abi"` // Func is the name of the function / method in the call. // NOTE: this is optional if the abi signature is used, or if the abi // only has one method. Func string `json:"func"` // Args is the arguments to the call, which can be nested. Args []any `json:"args"` }
ContractCallDef is a definition for a contract call. It can be used to encode a contract call as a hex encoded string.
type EventDecoder ¶ added in v1.26.5
type EventDecoder struct {
// contains filtered or unexported fields
}
func NewEventDecoder ¶ added in v1.26.5
func NewEventDecoder() *EventDecoder
func (*EventDecoder) DecodeLog ¶ added in v1.26.5
func (d *EventDecoder) DecodeLog(log types.Log) (ABISignature, []interface{}, bool, error)
func (*EventDecoder) DecodeLogAsHex ¶ added in v1.26.5
func (d *EventDecoder) DecodeLogAsHex(log types.Log) (ABISignature, []string, bool, error)
func (*EventDecoder) EventDefList ¶ added in v1.27.2
func (d *EventDecoder) EventDefList() []ABISignature
func (*EventDecoder) RegisterContractABI ¶ added in v1.26.5
func (d *EventDecoder) RegisterContractABI(contractABI abi.ABI, eventNames ...string) error
func (*EventDecoder) RegisterContractABIJSON ¶ added in v1.26.5
func (d *EventDecoder) RegisterContractABIJSON(contractABIJSON string, eventNames ...string) error
func (*EventDecoder) RegisterEventSig ¶ added in v1.26.5
func (d *EventDecoder) RegisterEventSig(eventSig ...string) error
func (*EventDecoder) TopicsList ¶ added in v1.27.2
func (d *EventDecoder) TopicsList() []string
func (*EventDecoder) TopicsMap ¶ added in v1.27.2
func (d *EventDecoder) TopicsMap() map[string]struct{}
type MerkleTree ¶ added in v1.26.0
type MerkleTree[TLeaf any] struct { // contains filtered or unexported fields }
func NewMerkleTree ¶ added in v1.26.0
func NewMerkleTree[TLeaf any](leaves []TLeaf, hashFn *func(TLeaf) ([]byte, error), options *Options) *MerkleTree[TLeaf]
func (*MerkleTree[TLeaf]) GetHexProof ¶ added in v1.26.0
func (mt *MerkleTree[TLeaf]) GetHexProof(leaf TLeaf) [][]byte
func (*MerkleTree[TLeaf]) GetProof ¶ added in v1.26.0
func (mt *MerkleTree[TLeaf]) GetProof(leaf TLeaf) ([]Proof, error)
func (*MerkleTree[TLeaf]) GetRoot ¶ added in v1.26.0
func (mt *MerkleTree[TLeaf]) GetRoot() []byte
type TypedData ¶
type TypedData struct { Types TypedDataTypes `json:"types"` PrimaryType string `json:"primaryType"` Domain TypedDataDomain `json:"domain"` Message map[string]interface{} `json:"message"` }
func TypedDataFromJSON ¶ added in v1.30.0
func (*TypedData) Encode ¶ added in v1.30.0
Encode returns the digest of the typed data and the fully encoded EIP712 typed data message.
NOTE: * the digest is the hash of the fully encoded EIP712 message * the encoded message is the fully encoded EIP712 message (0x1901 + domain + hashStruct(message))
func (*TypedData) EncodeDigest ¶
EncodeDigest returns the digest of the typed data message.
func (*TypedData) HashStruct ¶ added in v1.3.4
func (*TypedData) MarshalJSON ¶ added in v1.30.6
func (*TypedData) UnmarshalJSON ¶ added in v1.30.0
type TypedDataArgument ¶
type TypedDataDomain ¶
type TypedDataDomain struct { Name string `json:"name,omitempty"` Version string `json:"version,omitempty"` ChainID *big.Int `json:"chainId,omitempty"` VerifyingContract *common.Address `json:"verifyingContract,omitempty"` Salt *common.Hash `json:"salt,omitempty"` }
func (TypedDataDomain) Map ¶
func (t TypedDataDomain) Map() map[string]interface{}
type TypedDataTypes ¶
type TypedDataTypes map[string][]TypedDataArgument
func (TypedDataTypes) EncodeType ¶
func (t TypedDataTypes) EncodeType(primaryType string) (string, error)