abi

package
v0.1.8 Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 7 Imported by: 6

Documentation

Overview

ABI encoding/decoding

Implementation based on the ABI Spec.

Index

Constants

This section is empty.

Variables

View Source
var (
	NoTopics      = errors.New("no data in topics")
	SigMismatch   = errors.New("event signature doesn't match topics[0]")
	IndexMismatch = errors.New("num indexed inputs doesn't match len(topics)")
)

Functions

func Encode

func Encode(item *Item) []byte

ABI encoding. Not packed.

Types

type Item

type Item struct {
	schema.Type
	// contains filtered or unexported fields
}

func Address

func Address(a [20]byte) *Item

func Array

func Array(items ...*Item) *Item

func ArrayK

func ArrayK(items ...*Item) *Item

func BigInt

func BigInt(i big.Int) *Item

func Bool

func Bool(b bool) *Item

func Bytes

func Bytes(d []byte) *Item

func Bytes32

func Bytes32(d [32]byte) *Item

func Bytes4

func Bytes4(d [4]byte) *Item

func Decode

func Decode(input []byte, t schema.Type) (*Item, int, error)

Decodes ABI encoded bytes into an Item according to the 'schema' defined by t. For example:

Decode(b, schema.Tuple(schema.Dynamic(), schema.Static()))

Returns the item and the number of bytes read from input

func String

func String(s string) *Item

func Tuple

func Tuple(items ...*Item) *Item

func Uint16

func Uint16(i uint16) *Item

func Uint256

func Uint256(i uint256.Int) *Item

func Uint32

func Uint32(i uint32) *Item

func Uint64

func Uint64(i uint64) *Item

func Uint8

func Uint8(i uint8) *Item

func (*Item) Address

func (item *Item) Address() [20]byte

func (*Item) At

func (it *Item) At(i int) *Item

func (*Item) BigInt

func (item *Item) BigInt() *big.Int

func (*Item) Bool

func (item *Item) Bool() bool

func (*Item) Bytes

func (it *Item) Bytes() []byte

func (*Item) Bytes32

func (item *Item) Bytes32() [32]byte

func (*Item) Bytes4

func (item *Item) Bytes4() [4]byte

func (*Item) Done

func (item *Item) Done()

func (*Item) Equal

func (item *Item) Equal(other *Item) bool

func (*Item) Len

func (it *Item) Len() int

Returns length of list, tuple, or bytes depending on how the item was constructed.

func (*Item) String

func (item *Item) String() string

func (*Item) Uint16

func (item *Item) Uint16() uint16

func (*Item) Uint256

func (item *Item) Uint256() uint256.Int

func (*Item) Uint32

func (item *Item) Uint32() uint32

func (*Item) Uint64

func (item *Item) Uint64() uint64

func (*Item) Uint8

func (item *Item) Uint8() uint8

type Log

type Log struct {
	Address [20]byte
	Topics  [][32]byte
	Data    []byte
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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