Documentation ¶
Index ¶
- Constants
- func EncodeFunctionCall(abiData, funcName string, args ...string) ([]byte, bool, error)
- func EncodeFunctionCallFromFile(abiFileName, abiPath, funcName string, args []string) ([]byte, bool, error)
- func GetPackingTypes(args []Argument) []interface{}
- func Pack(argSpec []Argument, args ...interface{}) ([]byte, error)
- func PackIntoStruct(argSpec []Argument, st interface{}) ([]byte, error)
- func Signature(name string, args []Argument) (sig string)
- func Unpack(argSpec []Argument, data []byte, args ...interface{}) error
- func UnpackEvent(eventSpec *EventSpec, topics []burrow_binary.Word256, data []byte, ...) error
- func UnpackIntoStruct(argSpec []Argument, data []byte, st interface{}) error
- func UnpackRevert(data []byte) (message *string, err error)
- type AbiSpec
- type AbiSpecJSON
- type Argument
- type ArgumentJSON
- type EVMAddress
- type EVMBool
- type EVMBytes
- type EVMFixed
- type EVMInt
- type EVMString
- type EVMType
- type EVMUint
- type EventID
- type EventSpec
- type FunctionID
- type FunctionSpec
- type Variable
Constants ¶
const ElementSize = 32
EVM Solidity calls and return values are packed into pieces of 32 bytes, including a bool (wasting 255 out of 256 bits)
const EventIDSize = 32
const FunctionIDSize = 4
Variables ¶
This section is empty.
Functions ¶
func EncodeFunctionCall ¶ added in v0.24.0
EncodeFunctionCall ABI encodes a function call based on ABI in string abiData and the arguments specified as strings. The fname specifies which function should called, if it doesn't exist exist the fallback function will be called. If fname is the empty string, the constructor is called. The arguments must be specified in args. The count must match the function being called. Returns the ABI encoded function call, whether the function is constant according to the ABI (which means it does not modified contract state)
func EncodeFunctionCallFromFile ¶ added in v0.24.0
func EncodeFunctionCallFromFile(abiFileName, abiPath, funcName string, args []string) ([]byte, bool, error)
EncodeFunctionCallFromFile ABI encodes a function call based on ABI in file, and the arguments specified as strings. The abiFileName specifies the name of the ABI file, and abiPath the path where it can be found. The fname specifies which function should called, if it doesn't exist exist the fallback function will be called. If fname is the empty string, the constructor is called. The arguments must be specified in args. The count must match the function being called. Returns the ABI encoded function call, whether the function is constant according to the ABI (which means it does not modified contract state)
func GetPackingTypes ¶ added in v0.20.1
func GetPackingTypes(args []Argument) []interface{}
func PackIntoStruct ¶ added in v0.20.1
func UnpackEvent ¶ added in v0.22.0
func UnpackEvent(eventSpec *EventSpec, topics []burrow_binary.Word256, data []byte, args ...interface{}) error
* Given a eventSpec, get all the fields (topic fields or not)
func UnpackIntoStruct ¶ added in v0.20.1
func UnpackRevert ¶ added in v0.22.0
UnpackRevert decodes the revert reason if a contract called revert. If no reason was given, message will be nil else it will point to the string
Types ¶
type AbiSpec ¶ added in v0.20.1
type AbiSpec struct { Constructor FunctionSpec Fallback FunctionSpec Functions map[string]FunctionSpec Events map[string]EventSpec EventsById map[EventID]EventSpec }
var RevertAbi *AbiSpec
RevertAbi exists to decode reverts. Any contract function call fail using revert(), assert() or require(). If a function exits this way, the this hardcoded ABI will be used.
func MergeAbiSpec ¶ added in v0.23.0
MergeAbiSpec takes multiple AbiSpecs and merges them into once structure. Note that the same function name or event name can occur in different abis, so there might be some information loss.
func ReadAbiSpec ¶ added in v0.20.1
func ReadAbiSpecFile ¶ added in v0.20.1
func (*AbiSpec) Pack ¶ added in v0.20.1
Pack ABI encodes a function call. The fname specifies which function should called, if it doesn't exist exist the fallback function will be called. If fname is the empty string, the constructor is called. The arguments must be specified in args. The count must match the function being called. Returns the ABI encoded function call, whether the function is constant according to the ABI (which means it does not modified contract state)
func (*AbiSpec) UnpackWithID ¶ added in v0.22.0
type AbiSpecJSON ¶ added in v0.20.1
type AbiSpecJSON struct { Name string Type string Inputs []ArgumentJSON Outputs []ArgumentJSON Constant bool Payable bool StateMutability string Anonymous bool }
type Argument ¶ added in v0.20.1
type Argument struct { Name string EVM EVMType IsArray bool Indexed bool Hashed bool ArrayLength uint64 }
func EVMTypeFromReflect ¶ added in v0.20.1
type ArgumentJSON ¶ added in v0.20.1
type ArgumentJSON struct { Name string Type string Components []ArgumentJSON Indexed bool }
type EVMAddress ¶ added in v0.20.1
type EVMAddress struct { }
func (EVMAddress) Dynamic ¶ added in v0.24.0
func (e EVMAddress) Dynamic() bool
func (EVMAddress) GetSignature ¶ added in v0.20.1
func (e EVMAddress) GetSignature() string
type EVMBool ¶ added in v0.20.1
type EVMBool struct { }
func (EVMBool) GetSignature ¶ added in v0.20.1
type EVMBytes ¶ added in v0.20.1
type EVMBytes struct {
M uint64
}
func (EVMBytes) GetSignature ¶ added in v0.20.1
type EVMFixed ¶ added in v0.20.1
type EVMFixed struct {
N, M uint64
// contains filtered or unexported fields
}
func (EVMFixed) GetSignature ¶ added in v0.20.1
type EVMInt ¶ added in v0.20.1
type EVMInt struct {
M uint64
}
func (EVMInt) GetSignature ¶ added in v0.20.1
type EVMString ¶ added in v0.20.1
type EVMString struct { }
func (EVMString) GetSignature ¶ added in v0.20.1
type EVMUint ¶ added in v0.20.1
type EVMUint struct {
M uint64
}
func (EVMUint) GetSignature ¶ added in v0.20.1
type FunctionID ¶
type FunctionID [FunctionIDSize]byte
func GetFunctionID ¶ added in v0.20.1
func GetFunctionID(signature string) (id FunctionID)
func (FunctionID) Bytes ¶ added in v0.20.1
func (fs FunctionID) Bytes() []byte
type FunctionSpec ¶ added in v0.20.1
type FunctionSpec struct { FunctionID FunctionID Constant bool Inputs []Argument Outputs []Argument }
func SpecFromFunctionReflect ¶ added in v0.20.1
func SpecFromFunctionReflect(fname string, v reflect.Value, skipIn, skipOut int) *FunctionSpec
func SpecFromStructReflect ¶ added in v0.20.1
SpecFromStructReflect generates a FunctionSpec where the arguments and return values are described a struct. Both args and rets should be set to the return value of reflect.TypeOf() with the respective struct as an argument.
func (*FunctionSpec) SetFunctionID ¶ added in v0.20.1
func (functionSpec *FunctionSpec) SetFunctionID(functionName string)