Documentation ¶
Index ¶
- Constants
- Variables
- func CopyBytes(b []byte) (copiedBytes []byte)
- func DecodeRevert(ret []byte) (string, bool)
- func Ether(i uint64) *big.Int
- func Gwei(i uint64) *big.Int
- func Hex2Bytes(str string) []byte
- func RegisterParser(p LogParser)
- type Address
- type Block
- type BlockNumber
- type CallMsg
- type ExecutionResult
- type FilterOpts
- type Hash
- type Log
- type LogFilter
- type LogParser
- type Network
- type NilParser
- type ParsedEvent
- type Receipt
- type StorageLog
- type ThinLog
- type ThinReceipt
- type Transaction
Constants ¶
const ( // HashLength is the expected length of the hash HashLength = 32 // AddressLength is the expected length of the address AddressLength = 20 )
Lengths of hashes and addresses in bytes.
const ( Latest BlockNumber = -1 Earliest = -2 Pending = -3 )
const ( // ReceiptStatusSuccessful is the status code of a transaction if execution succeeded. ReceiptStatusSuccessful = uint64(1) )
Variables ¶
var TraceRpc = false // trace all rpc request response
Functions ¶
func DecodeRevert ¶
revert data signature is: Error(string) (0x08c379a0) https://ethereum.stackexchange.com/questions/83528/how-can-i-get-the-revert-reason-of-a-call-in-solidity-so-that-i-can-use-it-in-th
func RegisterParser ¶
func RegisterParser(p LogParser)
Types ¶
type Address ¶
type Address [20]byte
Address is an Ethereum address
func BytesToAddress ¶
func HexToAddress ¶
HexToAddress converts an hex string value to an address object
func (Address) MarshalText ¶
MarshalText implements the marshal interface
func (*Address) SetBytes ¶
SetBytes sets the address to the value of b. If b is larger than len(a), b will be cropped from the left.
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) MarshalText ¶ added in v0.1.2
func (b BlockNumber) MarshalText() ([]byte, error)
func (BlockNumber) String ¶
func (b BlockNumber) String() string
type CallMsg ¶
func (*CallMsg) MarshalJSON ¶
MarshalJSON implements the Marshal interface.
type ExecutionResult ¶
type ExecutionResult struct { UsedGas uint64 // Total used gas but include the refunded gas Err error // Any error encountered during the execution(listed in core/vm/errors.go) ReturnData hexutil.Bytes // Returned data from evm(function result or data supplied with revert opcode) RevertReason string }
ExecutionResult includes all output after executing given evm message no matter the execution itself is successful or not.
func NewExecutionResult ¶
func NewExecutionResult(usedGas uint64, err error, ret []byte) *ExecutionResult
func (*ExecutionResult) Failed ¶
func (result *ExecutionResult) Failed() bool
Failed returns the indicator whether the execution is successful or not
func (*ExecutionResult) Return ¶
func (result *ExecutionResult) Return() []byte
Return is a helper function to help caller distinguish between revert reason and function return. Return returns the data after execution if no error occurs.
func (*ExecutionResult) Revert ¶
func (result *ExecutionResult) Revert() []byte
Revert returns the concrete revert reason if the execution is aborted by `REVERT` opcode. Note the reason can be nil if no data supplied with revert opcode.
func (*ExecutionResult) Unwrap ¶
func (result *ExecutionResult) Unwrap() error
Unwrap returns the internal evm error which allows us for further analysis outside.
type FilterOpts ¶
type Hash ¶
type Hash [32]byte
Hash is an Ethereum hash
func BytesToHash ¶
BytesToHash sets b to hash. If b is larger than len(h), b will be cropped from the left.
func (Hash) MarshalText ¶
MarshalText implements the marshal interface
func (*Hash) SetBytes ¶
SetBytes sets the hash to the value of b. If b is larger than len(h), b will be cropped from the left.
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 Event *ParsedEvent }
func (*Log) MarshalJSON ¶
MarshalJSON implements the marshal interface
func (*Log) ParseEvent ¶
func (self *Log) ParseEvent()
func (*Log) UnmarshalJSON ¶
UnmarshalJSON implements the unmarshal interface
type LogFilter ¶
type LogFilter struct { BlockHash *Hash // used by eth_getLogs, return logs only from block with this hash From *BlockNumber // beginning of the queried range, nil means genesis block To *BlockNumber // end of the range, nil means latest block Address []Address // restricts matches to event created by specific contracts // The Topic list restricts matches to particular event topics. Each event has a list // of topics. Topics matches a prefix of that list. An empty element slice matches any // topic. Non-empty elements represent an alternative that matches any of the // contained topics. // // Examples: // {} or nil matches any topic list // {{A}} matches topic A in first position // {{}, {B}} matches any topic in first position AND B in second position // {{A}, {B}} matches topic A in first position AND B in second position // {{A, B}, {C, D}} matches topic (A OR B) in first position AND (C OR D) in second position Topics [][]Hash }
func (*LogFilter) MarshalJSON ¶
MarshalJSON implements the Marshal interface.
func (*LogFilter) SetFromUint64 ¶
func (*LogFilter) SetTo ¶
func (l *LogFilter) SetTo(b BlockNumber)
func (*LogFilter) SetToUint64 ¶
type LogParser ¶
type LogParser interface {
ParseLog(log *Log) (*ParsedEvent, error)
}
type ParsedEvent ¶
type Receipt ¶
type Receipt struct { Status uint64 TransactionHash Hash TransactionIndex uint64 ContractAddress Address BlockHash Hash From Address BlockNumber uint64 GasUsed uint64 CumulativeGasUsed uint64 LogsBloom []byte Logs []*Log }
func (*Receipt) AddStorageLogs ¶
func (self *Receipt) AddStorageLogs(logs []*StorageLog)
func (*Receipt) IsReverted ¶
func (*Receipt) Thin ¶
func (self *Receipt) Thin() *ThinReceipt
func (*Receipt) UnmarshalJSON ¶
UnmarshalJSON implements the unmarshal interface
type StorageLog ¶
type ThinLog ¶
type ThinLog struct { Address Address Topics []Hash `json:"topics,omitempty"` Data []byte `json:"data,omitempty"` Event *ParsedEvent }
type ThinReceipt ¶
type Transaction ¶
type Transaction struct { 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 // contains filtered or unexported fields }
func (*Transaction) Hash ¶
func (t *Transaction) Hash() Hash
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) ToCallMsg ¶
func (t *Transaction) ToCallMsg() *CallMsg
func (*Transaction) UnmarshalJSON ¶
func (t *Transaction) UnmarshalJSON(buf []byte) error
UnmarshalJSON implements the unmarshal interface
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
blake2b
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb.
|
Package blake2b implements the BLAKE2b hash algorithm defined by RFC 7693 and the extendable output function (XOF) BLAKE2Xb. |
bn256
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve.
|
Package bn256 implements the Optimal Ate pairing over a 256-bit Barreto-Naehrig curve. |
bn256/google
Package bn256 implements a particular bilinear group.
|
Package bn256 implements a particular bilinear group. |
Package vm implements the Ethereum Virtual Machine.
|
Package vm implements the Ethereum Virtual Machine. |
runtime
Package runtime provides a basic execution model for executing EVM code.
|
Package runtime provides a basic execution model for executing EVM code. |
storage/overlaydb
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
|
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. |
storage/schema
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
|
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. |
codec
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library.
|
* Copyright (C) 2018 The ontology Authors * This file is part of The ontology library. |
common
Package common contains various helper functions.
|
Package common contains various helper functions. |
common/hexutil
Package hexutil implements hex encoding with 0x prefix.
|
Package hexutil implements hex encoding with 0x prefix. |
common/math
Package math provides integer math utilities.
|
Package math provides integer math utilities. |