abi

package
v0.0.0-...-5d85a61 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 12, 2023 License: GPL-3.0 Imports: 14 Imported by: 0

Documentation

Index

Examples

Constants

View Source
const (
	IntTy byte = iota
	UintTy
	BoolTy
	StringTy
	SliceTy
	ArrayTy
	TupleTy
	AddressTy
	FixedBytesTy
	BytesTy
	HashTy
	FixedPointTy
	FunctionTy
)

Variables

View Source
var (
	MaxUint256 = big.NewInt(0).Add(
		big.NewInt(0).Exp(big.NewInt(2), big.NewInt(256), nil),
		big.NewInt(-1))

	MaxInt256 = big.NewInt(0).Add(
		big.NewInt(0).Exp(big.NewInt(2), big.NewInt(255), nil),
		big.NewInt(-1))
)

Functions

func ReadFixedBytes

func ReadFixedBytes(t Type, word []byte) (interface{}, error)

func ReadInteger

func ReadInteger(typ byte, kind reflect.Kind, b []byte) interface{}

func ToCamelCase

func ToCamelCase(input string) string

func U256

func U256(n *big.Int) []byte

Types

type ABI

type ABI struct {
	Constructor Method
	Methods     map[string]Method
	Events      map[string]Event
}

func JSON

func JSON(reader io.Reader) (ABI, error)
Example
const definition = `[{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"isBar","outputs":[{"name":"","type":"bool"}],"type":"function"}]`

abi, err := JSON(strings.NewReader(definition))
if err != nil {
	panic(err)
}
out, err := abi.Pack("isBar", common.HexToAddress("01"))
if err != nil {
	panic(err)
}

fmt.Printf("%x\n", out)
Output:

func (*ABI) EventByID

func (abi *ABI) EventByID(topic common.Hash) (*Event, error)

func (*ABI) MethodById

func (abi *ABI) MethodById(sigdata []byte) (*Method, error)

func (ABI) Pack

func (abi ABI) Pack(name string, args ...interface{}) ([]byte, error)

func (*ABI) UnmarshalJSON

func (abi *ABI) UnmarshalJSON(data []byte) error

func (ABI) Unpack

func (abi ABI) Unpack(v interface{}, name string, data []byte) (err error)

func (ABI) UnpackIntoMap

func (abi ABI) UnpackIntoMap(v map[string]interface{}, name string, data []byte) (err error)

func (ABI) UnpackMethodInputs

func (abi ABI) UnpackMethodInputs(v interface{}, name string, input []byte) (err error)

type Argument

type Argument struct {
	Name    string
	Type    Type
	Indexed bool
}

func (*Argument) UnmarshalJSON

func (argument *Argument) UnmarshalJSON(data []byte) error

type ArgumentMarshaling

type ArgumentMarshaling struct {
	Name         string
	Type         string
	InternalType string
	Components   []ArgumentMarshaling
	Indexed      bool
}

type Arguments

type Arguments []Argument

func (Arguments) LengthNonIndexed

func (arguments Arguments) LengthNonIndexed() int

func (Arguments) NonIndexed

func (arguments Arguments) NonIndexed() Arguments

func (Arguments) Pack

func (arguments Arguments) Pack(args ...interface{}) ([]byte, error)

func (Arguments) PackValues

func (arguments Arguments) PackValues(args []interface{}) ([]byte, error)

func (Arguments) Unpack

func (arguments Arguments) Unpack(v interface{}, data []byte) error

func (Arguments) UnpackIntoMap

func (arguments Arguments) UnpackIntoMap(v map[string]interface{}, data []byte) error

func (Arguments) UnpackValues

func (arguments Arguments) UnpackValues(data []byte) ([]interface{}, error)

type Event

type Event struct {
	Name string

	RawName   string
	Anonymous bool
	Inputs    Arguments
}

func (Event) ID

func (e Event) ID() common.Hash

func (Event) Sig

func (e Event) Sig() string

func (Event) String

func (e Event) String() string

type Method

type Method struct {
	Name string

	RawName string
	Const   bool
	Inputs  Arguments
	Outputs Arguments
}

func (Method) ID

func (method Method) ID() []byte

func (Method) Sig

func (method Method) Sig() string

func (Method) String

func (method Method) String() string

type Type

type Type struct {
	Elem *Type
	Kind reflect.Kind
	Type reflect.Type
	Size int
	T    byte

	TupleRawName  string
	TupleElems    []*Type
	TupleRawNames []string
	// contains filtered or unexported fields
}

func NewType

func NewType(t string, internalType string, components []ArgumentMarshaling) (typ Type, err error)

func (Type) String

func (t Type) String() (out string)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL