Documentation ¶
Overview ¶
* @Author: small_ant xms.chnb@gmail.com * @Time: 2022-01-15 13:50:16 * @LastAuthor: small_ant xms.chnb@gmail.com * @lastTime: 2022-12-08 14:14:42 * @FileName: units * @Desc: * * Copyright (c) 2022 by small_ant xms.chnb@gmail.com, All Rights Reserved.
Index ¶
- Constants
- Variables
- func Ether(i uint64) *big.Int
- func FWei(i *big.Int) *big.Int
- func Gwei(i uint64) *big.Int
- func Keccak256(buf []byte) []byte
- func Keccak256HashData(data ...[]byte) []byte
- func SignHash(data []byte) []byte
- func SignRSV(isig interface{}) ([32]byte, [32]byte, uint8)
- func SignString(data string) []byte
- func ToDecimal(ivalue interface{}, decimals int) decimal.Decimal
- func ToWei(iamount interface{}, decimals int) *big.Int
- type Address
- type Block
- type BlockNumber
- type BlockNumberOrHash
- type CallMsg
- type Hash
- type Log
- type LogFilter
- type Network
- type Receipt
- type Transaction
Constants ¶
const ( Latest BlockNumber = -1 Earliest = -2 Pending = -3 )
Variables ¶
var ( // ZeroAddress is an address of all zeros ZeroAddress = Address{} // ZeroHash is a hash of all zeros ZeroHash = Hash{} )
Functions ¶
func FWei ¶
`FWei` converts a `big.Int` from wei to ether
Args:
i: The amount of Wei you want to convert.
func Keccak256 ¶ added in v1.1.4
It takes a byte array, and returns a byte array
Args:
buf ([]byte): The data to be hashed.
Returns:
The hash of the input buffer.
func Keccak256HashData ¶ added in v1.1.4
It takes a variable number of byte slices and returns a single byte slice
Returns:
The hash of the data.
func SignHash ¶ added in v1.1.4
It takes a byte array, converts it to a string, prepends a string to it, and then hashes the result
Args:
data ([]byte): The data to sign.
Returns:
The hash of the message.
func SignRSV ¶ added in v1.1.3
It takes a signature in the form of a byte array or hex string, and returns the R, S, and V values as byte arrays and a uint8
Args:
isig: signature
func SignString ¶ added in v1.1.4
It takes a string and returns a byte array
Args:
data (string): The data to sign.
Returns:
The return value is a byte array.
Types ¶
type Address ¶
type Address [20]byte
Address is an Ethereum address
func BytesToAddress ¶
BytesToAddress converts bytes to an address object
func HexToAddress ¶
HexToAddress converts an hex string value to an address object
func (Address) MarshalText ¶
MarshalText implements the marshal interface
func (*Address) UnmarshalText ¶
UnmarshalText implements the unmarshal interface
type Block ¶
type Block struct { Number uint64 Hash Hash ParentHash Hash Sha3Uncles Hash TransactionsRoot Hash StateRoot Hash ReceiptsRoot Hash Miner Address Difficulty *big.Int ExtraData []byte GasLimit uint64 GasUsed uint64 Timestamp uint64 Transactions []*Transaction TransactionsHashes []Hash Uncles []Hash }
func (*Block) MarshalJSON ¶
MarshalJSON implements the marshal interface
func (*Block) UnmarshalJSON ¶
UnmarshalJSON implements the unmarshal interface
type BlockNumber ¶
type BlockNumber int
func EncodeBlock ¶
func EncodeBlock(block ...BlockNumber) BlockNumber
func (BlockNumber) Location ¶
func (b BlockNumber) Location() string
func (BlockNumber) String ¶
func (b BlockNumber) String() string
type BlockNumberOrHash ¶
type BlockNumberOrHash interface {
Location() string
}
type CallMsg ¶
func (*CallMsg) MarshalJSON ¶
MarshalJSON implements the Marshal interface.
type Hash ¶
type Hash [32]byte
Hash is an Ethereum hash
func (Hash) MarshalText ¶
MarshalText implements the marshal interface
func (*Hash) UnmarshalText ¶
UnmarshalText implements the unmarshal interface
type Log ¶
type Log struct { Removed bool LogIndex uint64 TransactionIndex uint64 TransactionHash Hash BlockHash Hash BlockNumber uint64 Address Address Topics []Hash Data []byte }
func (*Log) MarshalJSON ¶
MarshalJSON implements the marshal interface
func (*Log) UnmarshalJSON ¶
UnmarshalJSON implements the unmarshal interface
type LogFilter ¶
type LogFilter struct { Address []Address Topics []*Hash BlockHash *Hash From *BlockNumber To *BlockNumber }
func (*LogFilter) MarshalJSON ¶
MarshalJSON implements the Marshal interface.
func (*LogFilter) SetFromUint64 ¶
func (*LogFilter) SetTo ¶
func (l *LogFilter) SetTo(b BlockNumber)
func (*LogFilter) SetToUint64 ¶
type Receipt ¶
type Receipt struct { TransactionHash Hash TransactionIndex uint64 ContractAddress Address BlockHash Hash From Address BlockNumber uint64 GasUsed uint64 CumulativeGasUsed uint64 LogsBloom []byte Logs []*Log }
func (*Receipt) UnmarshalJSON ¶
UnmarshalJSON implements the unmarshal interface
type Transaction ¶
type Transaction struct { Hash Hash From Address To *Address Input []byte GasPrice uint64 Gas uint64 Value *big.Int Nonce uint64 V []byte R []byte S []byte BlockHash Hash BlockNumber uint64 TxnIndex uint64 }
func (*Transaction) MarshalJSON ¶
func (t *Transaction) MarshalJSON() ([]byte, error)
MarshalJSON implements the Marshal interface.
func (*Transaction) MarshalRLP ¶
func (t *Transaction) MarshalRLP() []byte
func (*Transaction) MarshalRLPWith ¶
func (t *Transaction) MarshalRLPWith(arena *fastrlp.Arena) *fastrlp.Value
MarshalRLPWith marshals the transaction to RLP with a specific fastrlp.Arena
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(buf []byte) error
UnmarshalJSON implements the unmarshal interface
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
builtin/ens
Code generated by go-web3/abigen.
|
Code generated by go-web3/abigen. |
builtin/erc20
Code generated by go-web3/abigen.
|
Code generated by go-web3/abigen. |
fastrlp
module
|
|