Documentation ¶
Index ¶
- Constants
- Variables
- func AllZero(b []byte) bool
- func BigMax(x, y *big.Int) *big.Int
- func BigMin(x, y *big.Int) *big.Int
- func BigPow(a, b int64) *big.Int
- func BigUint64(v *big.Int) (uint64, bool)
- func Byte(bigint *big.Int, padlength, n int) byte
- func Bytes2Hex(b []byte) string
- func Bytes2HexTrim(b []byte) string
- func CopyBytes(b []byte) (copiedBytes []byte)
- func Exp(base, exponent *big.Int) *big.Int
- func FromHex(s string) []byte
- func GetData(data []byte, start uint64, size uint64) []byte
- func GetDataBig(data []byte, start *big.Int, size *big.Int) []byte
- func GetEvmAddressDriver() address.Driver
- func Hex2Bytes(str string) []byte
- func HexToBytes(str string) ([]byte, error)
- func InitEvmAddressDriver(driver address.Driver)
- func LeftPadBytes(slice []byte, l int) []byte
- func PaddedBigBytes(bigint *big.Int, n int) []byte
- func ReadBits(bigint *big.Int, buf []byte)
- func RightPadBytes(slice []byte, l int) []byte
- func S256(x *big.Int) *big.Int
- func SafeAdd(x, y uint64) (uint64, bool)
- func SafeMul(x, y uint64) (uint64, bool)
- func ToWordSize(size uint64) uint64
- func U256(x *big.Int) *big.Int
- func Zero(value *big.Int) bool
- type Address
- func BigToAddress(b *big.Int) Address
- func BytesToAddress(b []byte) Address
- func EmptyAddress() Address
- func ExecAddress(execName string) Address
- func HexToAddr(s string) Address
- func NewAddress(cfg *types.Chain33Config, txHash []byte) Address
- func NewContractAddress(b Address, txHash []byte) Address
- func NewEvmContractAddress(b Address, nonce uint64) Address
- func PubKey2Address(pub []byte) Address
- func StringToAddress(addr string) *Address
- func StringToAddressLegacy(s string) *Address
- func Uint256ToAddress(b *uint256.Int) Address
- type Hash
- type Hash160Address
- type Message
- func (m *Message) Alias() string
- func (m *Message) Data() []byte
- func (m *Message) From() Address
- func (m *Message) GasLimit() uint64
- func (m *Message) GasPrice() uint32
- func (m *Message) Nonce() int64
- func (m *Message) Para() []byte
- func (m *Message) SetGasLimit(gasLimit uint64)
- func (m *Message) To() *Address
- func (m *Message) Value() uint64
Constants ¶
const ( // WordBits 一个big.Word类型取值占用多少个位 WordBits = 32 << (uint64(^big.Word(0)) >> 63) // WordBytes 一个big.Word类型取值占用多少个字节 WordBytes = WordBits / 8 )
const ( // HashLength 哈希长度 HashLength = 32 // Hash160Length Hash160格式的地址长度 Hash160Length = 20 // AddressLength 地址长度 AddressLength = 20 )
Variables ¶
var ( // Big0 大数字0 Big0 = big.NewInt(0) // Big1 大数字1 Big1 = big.NewInt(1) // Big32 大数字32 Big32 = big.NewInt(32) // Big256 大数字256 Big256 = big.NewInt(256) // Big257 大数字257 Big257 = big.NewInt(257) )
常用的大整数常量定义
var ( // TT255 2的255次幂 TT255 = BigPow(2, 255) )
2的各种常用取幂结果
Functions ¶
func Bytes2HexTrim ¶
Bytes2HexTrim 将字节数组转换为16进制的字符串表示 并且将前面多余的0去除
func GetDataBig ¶
GetDataBig 返回从开始位置制定长度的数据 如果源数据不足,则剩余位置用零填充
func GetEvmAddressDriver ¶ added in v1.67.3
GetEvmAddressDriver get driver
func InitEvmAddressDriver ¶ added in v1.67.5
InitEvmAddressDriver 初始化地址类型
func PaddedBigBytes ¶
PaddedBigBytes encodes a big integer as a big-endian byte slice. The length of the slice is at least n bytes.
func S256 ¶
S256 interprets x as a two's complement number. x must not exceed 256 bits (the result is undefined if it does) and is not modified.
S256(0) = 0 S256(1) = 1 S256(2**255) = -2**255 S256(2**256-1) = -1
func ToWordSize ¶
ToWordSize 计算制定字节长度所对应的字长度(一个字,对应32个字节,也就是256位) 如果长度不足一个字长,则补足 EVM在内存中存储时的最小单位是字长(256位),而不是字节
Types ¶
type Address ¶
type Address struct {
// contains filtered or unexported fields
}
Address 封装evm内部地址对象 raw为地址原始数据 formatAddr为chain33框架中格式化地址, 相关转换格式由默认地址插件指定 chain33 => evm, 即将formatAddr转换为raw数据, [20]byte evm => chain33, 即将原始数据raw格式化为formatAddr
func NewAddress ¶
func NewAddress(cfg *types.Chain33Config, txHash []byte) Address
NewAddress xHash生成EVM合约地址
func NewContractAddress ¶ added in v1.65.3
func NewEvmContractAddress ¶ added in v1.67.4
NewEvmContractAddress 通过nonce创建合约地址
func PubKey2Address ¶ added in v1.67.3
PubKey2Address pub key to address
func StringToAddress ¶
StringToAddress try convert string to Address
func StringToAddressLegacy ¶ added in v1.67.5
StringToAddressLegacy 字符串转换为地址 Deprecated
func Uint256ToAddress ¶ added in v1.65.1
Uint256ToAddress 大数字转换为地址
type Hash160Address ¶
type Hash160Address [Hash160Length]byte
Hash160Address EVM中使用的地址格式
func BytesToHash160Address ¶
func BytesToHash160Address(b []byte) Hash160Address
BytesToHash160Address 字节向地址转换
func HexToAddress ¶
func HexToAddress(s string) Hash160Address
HexToAddress returns Address with byte values of s. If s is larger than len(h), s will be cropped from the left.
func (Hash160Address) Hex ¶
func (h Hash160Address) Hex() string
Hex returns an EIP55-compliant hex string representation of the address.
func (*Hash160Address) SetBytes ¶
func (h *Hash160Address) SetBytes(b []byte)
SetBytes sets the address to the value of b. If b is larger than len(a) it will panic.
func (Hash160Address) String ¶
func (h Hash160Address) String() string
String implements fmt.Stringer.
func (Hash160Address) ToAddress ¶
func (h Hash160Address) ToAddress() Address
ToAddress 返回Chain33格式的地址
type Message ¶
type Message struct {
// contains filtered or unexported fields
}
Message 合约交易消息模型 在EVM执行器中传递此消息,由外部Tx等价构造
func NewMessage ¶
func NewMessage(from Address, to *Address, nonce int64, amount uint64, gasLimit uint64, gasPrice uint32, data, para []byte, alias string) *Message
NewMessage 新建消息结构
func (*Message) SetGasLimit ¶ added in v1.65.3
GasLimit Gas限制
Directories ¶
Path | Synopsis |
---|---|
Package math provides integer math utilities.
|
Package math provides integer math utilities. |