evmutils

package
v1.5.1 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2022 License: Apache-2.0 Imports: 8 Imported by: 12

Documentation

Index

Constants

View Source
const (
	AddressLength = 20
)

Variables

View Source
var (
	BlankHash = make([]byte, hashLength)
	ZeroHash  = Keccak256(nil)
)

Functions

func EVMIntToHashBytes

func EVMIntToHashBytes(i *Int) [hashLength]byte

EVMIntToHashBytes returns the absolute value of x as a big-endian fixed length byte slice.

func FromHex

func FromHex(s string) ([]byte, error)

func GetDataFrom

func GetDataFrom(src []byte, offset uint64, size uint64) []byte

func Has0xPrefix

func Has0xPrefix(str string) bool

func Keccak256

func Keccak256(data []byte) []byte

func LeftPadBytes

func LeftPadBytes(slice []byte, l int) []byte

LeftPadBytes zero-pads slice to the left up to length l.

func LeftPaddingSlice

func LeftPaddingSlice(src []byte, toSize int) []byte

func MarshalPublicKey

func MarshalPublicKey(pk crypto.PublicKey) (pkBytes []byte, err error)

MarshalPublicKey serialize pk to bytes

func MinI

func MinI(i, j int64) int64

func RightPaddingSlice

func RightPaddingSlice(src []byte, toSize int) []byte

Types

type Address

type Address [AddressLength]byte

func BigToAddress

func BigToAddress(b *Int) Address

BigToAddress math.bigInt to evm address

func BytesToAddress

func BytesToAddress(b []byte) Address

BytesToAddress any byte set to an evm address

func HexToAddress

func HexToAddress(s string) (Address, error)

HexToAddress direct convert hex to an evm address,直接将十六进制字符串转换为Address类型

func MakeHexToAddress

func MakeHexToAddress(s string) (Address, error)

MakeHexToAddress 基于十六进制数据,经过Hash计算获得一个EVM地址 @param s @return Address @return error

func StringToAddress

func StringToAddress(s string) (Address, error)

StringToAddress any string make an evm address

func (*Address) SetBytes

func (a *Address) SetBytes(b []byte)

func (*Address) String

func (a *Address) String() string

type Int

type Int struct {
	*big.Int
}

func BytesDataToEVMIntHash

func BytesDataToEVMIntHash(data []byte) *Int

BytesDataToEVMIntHash fixed length bytes

func EthHashBytesToEVMInt

func EthHashBytesToEVMInt(hash [hashLength]byte) (*Int, error)

EthHashBytesToEVMInt EVMIntToHashBytes reverse

func FromBigInt

func FromBigInt(i *big.Int) *Int

func FromDecimalString

func FromDecimalString(s string) *Int

FromString from fmt data Int.String()

func FromHexString

func FromHexString(s string) *Int

FromString from fmt data hex.encodeToString([]byte(Int.AsStringKey))

func FromString

func FromString(ss string) *Int

FromString from fmt data Int.AsStringKey

func HashBytesToEVMInt

func HashBytesToEVMInt(hash []byte) (*Int, error)

HashBytesToEVMInt byte to bigInt

func MakeAddress

func MakeAddress(data []byte) *Int

MakeAddress any byte make an evm.Int

func MakeAddressFromHex

func MakeAddressFromHex(str string) (*Int, error)

MakeAddressFromHex any hex str make an evm.Int

func MakeAddressFromString

func MakeAddressFromString(str string) (*Int, error)

MakeAddressFromString any str make an evm.Int

func MinInt

func MinInt(i, j *Int) *Int

func New

func New(i int64) *Int

func (*Int) Add

func (i *Int) Add(y *Int) *Int

func (*Int) AddMod

func (i *Int) AddMod(y *Int, m *Int) *Int

func (*Int) And

func (i *Int) And(y *Int) *Int

func (*Int) AsStringKey

func (i *Int) AsStringKey() string

func (*Int) ByteAt

func (i *Int) ByteAt(n int) byte

func (Int) Clone

func (i Int) Clone() *Int

func (*Int) Div

func (i *Int) Div(y *Int) *Int

func (*Int) EQ

func (i *Int) EQ(y *Int) bool

func (*Int) Exp

func (i *Int) Exp(e *Int) *Int

func (*Int) GT

func (i *Int) GT(y *Int) bool

func (*Int) GetSigned

func (i *Int) GetSigned() *Int

func (*Int) IsZero

func (i *Int) IsZero() bool

func (*Int) LT

func (i *Int) LT(y *Int) bool

func (*Int) Mod

func (i *Int) Mod(m *Int) *Int

func (*Int) Mul

func (i *Int) Mul(y *Int) *Int

func (*Int) MulMod

func (i *Int) MulMod(y *Int, m *Int) *Int

func (*Int) Not

func (i *Int) Not(y *Int) *Int

func (*Int) Or

func (i *Int) Or(y *Int) *Int

func (*Int) SAR

func (i *Int) SAR(n uint64) *Int

func (*Int) SDiv

func (i *Int) SDiv(y *Int) *Int

func (*Int) SGT

func (i *Int) SGT(y *Int) bool

func (*Int) SHL

func (i *Int) SHL(n uint64) *Int

func (*Int) SHR

func (i *Int) SHR(n uint64) *Int

func (*Int) SLT

func (i *Int) SLT(y *Int) bool

func (*Int) SMod

func (i *Int) SMod(m *Int) *Int

func (*Int) SignExtend

func (i *Int) SignExtend(baseBytes *Int) *Int

func (*Int) Sub

func (i *Int) Sub(y *Int) *Int

func (*Int) XOr

func (i *Int) XOr(y *Int) *Int

Directories

Path Synopsis
abi

Jump to

Keyboard shortcuts

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