ethereum

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jun 14, 2019 License: GPL-3.0 Imports: 6 Imported by: 0

README

Ethereum Client

Ethereum client is supposed to be a general interface over any ethereum node.

Documentation

Index

Constants

View Source
const (
	CREATE OpCode = 0xf0 + iota
	CALL
	CALLCODE
	RETURN
	DELEGATECALL
	STATICCALL = 0xfa

	REVERT         = 0xfd
	INVALID_OPCODE = 0xfe
	SELFDESTRUCT   = 0xff
)

0xf0 range - closures.

Variables

This section is empty.

Functions

This section is empty.

Types

type Block

type Block interface {
	Transactions() []Transaction
}

type CallTraces

type CallTraces interface {
	Traces() []Trace
}

type CodeSchema

type CodeSchema interface {
	GetCode(address string) (*jsonrpc2.Request, *string)
}

type EthSchema

type EthSchema interface {
	BlockNumber() (*jsonrpc2.Request, *Number)
	GetBlockByNumber(num Number) (*jsonrpc2.Request, Block)
	GetTransaction(hash string) (*jsonrpc2.Request, Transaction)
	GetTransactionReceipt(hash string) (*jsonrpc2.Request, TransactionReceipt)
}

type EvmState

type EvmState interface {
	Pc() uint64
	Depth() int
	Op() string
	Stack() []string
}
type Header interface {
	Number() *Number
}

type Log

type Log interface {
	Topics() []string
	Data() string
}

type NetSchema

type NetSchema interface {
	Version() (*jsonrpc2.Request, *string)
}

type Number

type Number int64

func (*Number) Hex

func (n *Number) Hex() string

func (*Number) MarshalJSON

func (n *Number) MarshalJSON() ([]byte, error)

func (*Number) UnmarshalJSON

func (n *Number) UnmarshalJSON(b []byte) error

func (*Number) Value

func (n *Number) Value() int64

type OpCode

type OpCode byte

OpCode is an EVM opcode

const (
	STOP OpCode = iota
	ADD
	MUL
	SUB
	DIV
	SDIV
	MOD
	SMOD
	ADDMOD
	MULMOD
	EXP
	SIGNEXTEND
)

0x0 range - arithmetic ops.

const (
	LT OpCode = iota + 0x10
	GT
	SLT
	SGT
	EQ
	ISZERO
	AND
	OR
	XOR
	NOT
	BYTE
	SHL
	SHR
	SAR

	SHA3 = 0x20
)

0x10 range - comparison ops.

const (
	ADDRESS OpCode = 0x30 + iota
	BALANCE
	ORIGIN
	CALLER
	CALLVALUE
	CALLDATALOAD
	CALLDATASIZE
	CALLDATACOPY
	CODESIZE
	CODECOPY
	GASPRICE
	EXTCODESIZE
	EXTCODECOPY
	RETURNDATASIZE
	RETURNDATACOPY
)

0x30 range - closure state.

const (
	BLOCKHASH OpCode = 0x40 + iota
	COINBASE
	TIMESTAMP
	NUMBER
	DIFFICULTY
	GASLIMIT
)

0x40 range - block operations.

const (
	POP OpCode = 0x50 + iota
	MLOAD
	MSTORE
	MSTORE8
	SLOAD
	SSTORE
	JUMP
	JUMPI
	PC
	MSIZE
	GAS
	JUMPDEST
)

0x50 range - 'storage' and execution.

const (
	PUSH1 OpCode = 0x60 + iota
	PUSH2
	PUSH3
	PUSH4
	PUSH5
	PUSH6
	PUSH7
	PUSH8
	PUSH9
	PUSH10
	PUSH11
	PUSH12
	PUSH13
	PUSH14
	PUSH15
	PUSH16
	PUSH17
	PUSH18
	PUSH19
	PUSH20
	PUSH21
	PUSH22
	PUSH23
	PUSH24
	PUSH25
	PUSH26
	PUSH27
	PUSH28
	PUSH29
	PUSH30
	PUSH31
	PUSH32
	DUP1
	DUP2
	DUP3
	DUP4
	DUP5
	DUP6
	DUP7
	DUP8
	DUP9
	DUP10
	DUP11
	DUP12
	DUP13
	DUP14
	DUP15
	DUP16
	SWAP1
	SWAP2
	SWAP3
	SWAP4
	SWAP5
	SWAP6
	SWAP7
	SWAP8
	SWAP9
	SWAP10
	SWAP11
	SWAP12
	SWAP13
	SWAP14
	SWAP15
	SWAP16
)

0x60 range.

const (
	LOG0 OpCode = 0xa0 + iota
	LOG1
	LOG2
	LOG3
	LOG4
)

0xa0 range - logging ops.

const (
	PUSH OpCode = 0xb0 + iota
	DUP
	SWAP
)

unofficial opcodes used for parsing.

func (OpCode) IsPush

func (op OpCode) IsPush() bool

IsPush specifies if an opcode is a PUSH opcode.

func (OpCode) IsStaticJump

func (op OpCode) IsStaticJump() bool

IsStaticJump specifies if an opcode is JUMP.

func (OpCode) PushSize

func (op OpCode) PushSize() uint64

func (OpCode) String

func (op OpCode) String() string

type PubSubSchema

type PubSubSchema interface {
	Subscribe() (*jsonrpc2.Request, *SubscriptionID)
	Unsubscribe(id SubscriptionID) (*jsonrpc2.Request, *UnsubscribeSuccess)
}

type Schema

type Schema interface {
	Eth() EthSchema
	Net() NetSchema
	Trace() TraceSchema
	Code() CodeSchema
	PubSub() PubSubSchema
}

type SubscriptionID

type SubscriptionID string

func NewNilSubscriptionID

func NewNilSubscriptionID() SubscriptionID

func (SubscriptionID) String

func (id SubscriptionID) String() string

type SubscriptionResult

type SubscriptionResult struct {
	Subscription SubscriptionID `json:"subscription"`
	Result       Header         `json:"result"`
}

type Trace

type Trace interface {
	Hash() *common.Hash
	ParentHash() *common.Hash
	TransactionHash() *common.Hash
	Type() string
	From() common.Address
	To() common.Address
	Input() hexutil.Bytes
	Output() hexutil.Bytes
	Gas() *hexutil.Uint64
	GasUsed() *hexutil.Uint64
	Value() *hexutil.Big
	Error() string
}

type TraceSchema

type TraceSchema interface {
	VMTrace(hash string) (*jsonrpc2.Request, TransactionStates)
	CallTrace(hash string) (*jsonrpc2.Request, CallTraces)
}

type Transaction

type Transaction interface {
	Hash() *common.Hash

	From() *common.Address
	To() *common.Address

	Input() hexutil.Bytes
	Value() *hexutil.Big
	Gas() *hexutil.Big
	GasPrice() *hexutil.Big
}

type TransactionReceipt

type TransactionReceipt interface {
	Hash() string
	TransactionIndex() hexutil.Big

	BlockHash() common.Hash
	BlockNumber() hexutil.Big

	From() common.Address
	To() *common.Address

	GasUsed() *hexutil.Big
	CumulativeGasUsed() *hexutil.Big
	ContractAddress() *common.Address

	Status() string
	SetStatus(trace string)
	Logs() []Log
	LogsBloom() hexutil.Bytes
}

type TransactionStates

type TransactionStates interface {
	States() []EvmState
	ProcessTrace()
}

type UnsubscribeSuccess

type UnsubscribeSuccess bool

Directories

Path Synopsis
core

Jump to

Keyboard shortcuts

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