Documentation ¶
Index ¶
- Constants
- Variables
- func ABIEncode(fn string, args ...EtherType) []byte
- func CurvePoint(x *big.Int, y *big.Int, v int)
- func DecodeABI(v []byte, args ...interface{}) error
- func IPCDial() (io.ReadWriteCloser, error)
- func IPCPath(s string) func() (io.ReadWriteCloser, error)
- func MetadataHash(b []byte) []byte
- func RegisterHSM(name string, probe func(hints ...string) HSM)
- func SignTransaction(t *Transaction, sign Signer) ([]byte, error)
- func StripBytecode(b []byte) []byte
- type ABIDecoder
- type ABIDescriptor
- func (z *ABIDescriptor) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *ABIDescriptor) EncodeMsg(en *msgp.Writer) (err error)
- func (z *ABIDescriptor) MarshalMsg(b []byte) (o []byte, err error)
- func (z *ABIDescriptor) Msgsize() (s int)
- func (d *ABIDescriptor) Signature() string
- func (z *ABIDescriptor) UnmarshalMsg(bts []byte) (o []byte, err error)
- type ABIParam
- type AddrSlice
- type Address
- func (z *Address) DecodeMsg(dc *msgp.Reader) (err error)
- func (a *Address) EncodeABI(v []byte) []byte
- func (z *Address) EncodeMsg(en *msgp.Writer) (err error)
- func (a *Address) FromString(s string) error
- func (z *Address) MarshalMsg(b []byte) (o []byte, err error)
- func (a Address) MarshalText() ([]byte, error)
- func (z *Address) Msgsize() (s int)
- func (a *Address) Scan(s fmt.ScanState, x rune) error
- func (a *Address) String() string
- func (z *Address) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (a *Address) UnmarshalText(b []byte) error
- func (a *Address) Zero() bool
- type Block
- func (z *Block) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Block) EncodeMsg(en *msgp.Writer) (err error)
- func (z *Block) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Block) Msgsize() (s int)
- func (b *Block) ParseTransactions() ([]Transaction, error)
- func (b *Block) Time() time.Time
- func (z *Block) UnmarshalMsg(bts []byte) (o []byte, err error)
- type BlockIterator
- func (z *BlockIterator) DecodeMsg(dc *msgp.Reader) (err error)
- func (z BlockIterator) EncodeMsg(en *msgp.Writer) (err error)
- func (z BlockIterator) MarshalMsg(b []byte) (o []byte, err error)
- func (z BlockIterator) Msgsize() (s int)
- func (b *BlockIterator) Next() <-chan *Block
- func (b *BlockIterator) Stop()
- func (z *BlockIterator) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Bytes
- type CallOpts
- type Client
- func (c *Client) Accounts() ([]Address, error)
- func (c *Client) BlockNumber() (int64, error)
- func (c *Client) Call(opts *CallOpts) (tx Hash, err error)
- func (c *Client) Coinbase() (*Address, error)
- func (c *Client) ConstCall(opts *CallOpts, out interface{}, pending bool) error
- func (c *Client) ConstCallAt(opts *CallOpts, out interface{}, block int64) error
- func (z *Client) DecodeMsg(dc *msgp.Reader) (err error)
- func (c *Client) Do(method string, params []json.RawMessage, result interface{}) error
- func (z Client) EncodeMsg(en *msgp.Writer) (err error)
- func (c *Client) EstimateGas(opts *CallOpts) (gas Int, err error)
- func (c *Client) FilterTopics(topics []*Hash, addr *Address, start, end int64) (*Filter, error)
- func (c *Client) GasPrice() (int64, error)
- func (c *Client) GetBalance(addr *Address) (Int, error)
- func (c *Client) GetBalanceAt(addr *Address, blocknum int64) (Int, error)
- func (c *Client) GetBlock(num int64, txs bool) (*Block, error)
- func (c *Client) GetCode(addr *Address) ([]byte, error)
- func (c *Client) GetCodeAt(addr *Address, blocknum int64) ([]byte, error)
- func (c *Client) GetNonce(addr *Address) (int64, error)
- func (c *Client) GetNonceAt(addr *Address, blocknum int64) (int64, error)
- func (c *Client) GetReceipt(tx *Hash) (*Receipt, error)
- func (c *Client) GetTransaction(h *Hash) (*Transaction, error)
- func (c *Client) Hashrate() (int64, error)
- func (c *Client) IterateBlocks(from int64, txs bool) *BlockIterator
- func (c *Client) Latest(txs bool) (*Block, error)
- func (z Client) MarshalMsg(b []byte) (o []byte, err error)
- func (c *Client) Mining() (bool, error)
- func (z Client) Msgsize() (s int)
- func (c *Client) Pending() ([]Transaction, error)
- func (c *Client) ProtocolVersion() (string, error)
- func (c *Client) RawCall(raw []byte) (tx Hash, err error)
- func (c *Client) StorageAt(addr *Address, offset *Hash, block int64) (Hash, error)
- func (c *Client) Syncing() (*SyncStatus, error)
- func (c *Client) TokenTransfers(from *Address, to *Address, tok *Address, start, end int64) (*Filter, error)
- func (c *Client) UnlockAccount(addr *Address, password string) error
- func (z *Client) UnmarshalMsg(bts []byte) (o []byte, err error)
- type CompiledBundle
- func (c *CompiledBundle) Contract(name string) *CompiledContract
- func (z *CompiledBundle) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *CompiledBundle) EncodeMsg(en *msgp.Writer) (err error)
- func (z *CompiledBundle) MarshalMsg(b []byte) (o []byte, err error)
- func (z *CompiledBundle) Msgsize() (s int)
- func (b *CompiledBundle) SourceOf(c *CompiledContract, pc int) string
- func (z *CompiledBundle) UnmarshalMsg(bts []byte) (o []byte, err error)
- type CompiledContract
- func (z *CompiledContract) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *CompiledContract) EncodeMsg(en *msgp.Writer) (err error)
- func (c *CompiledContract) Find(desc string) *ABIDescriptor
- func (z *CompiledContract) MarshalMsg(b []byte) (o []byte, err error)
- func (z *CompiledContract) Msgsize() (s int)
- func (z *CompiledContract) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Data
- func (z *Data) DecodeMsg(dc *msgp.Reader) (err error)
- func (d *Data) EncodeABI(v []byte) []byte
- func (z Data) EncodeMsg(en *msgp.Writer) (err error)
- func (z Data) MarshalMsg(b []byte) (o []byte, err error)
- func (d Data) MarshalText() ([]byte, error)
- func (z Data) Msgsize() (s int)
- func (d *Data) String() string
- func (z *Data) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (d *Data) UnmarshalText(b []byte) error
- type DataSlice
- type EtherSlice
- type EtherType
- type Filter
- type HSM
- type HSMKey
- type HTTPTransport
- type Hash
- func (z *Hash) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Hash) EncodeMsg(en *msgp.Writer) (err error)
- func (h *Hash) FromString(s string) error
- func (z *Hash) MarshalMsg(b []byte) (o []byte, err error)
- func (h Hash) MarshalText() ([]byte, error)
- func (z *Hash) Msgsize() (s int)
- func (h *Hash) Scan(s fmt.ScanState, verb rune) error
- func (h *Hash) String() string
- func (z *Hash) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (h *Hash) UnmarshalText(b []byte) error
- type InfuraTransport
- type Int
- func (i *Int) Big() *big.Int
- func (i *Int) Cmp(x *Int) int
- func (i *Int) Copy() Int
- func (i *Int) DecodeMsg(r *msgp.Reader) error
- func (i *Int) EncodeABI(v []byte) []byte
- func (i *Int) EncodeMsg(w *msgp.Writer) error
- func (i *Int) FromString(s string) error
- func (i *Int) Int64() int64
- func (i *Int) IsZero() bool
- func (i *Int) MarshalMsg(b []byte) ([]byte, error)
- func (i Int) MarshalText() ([]byte, error)
- func (i *Int) Msgsize() int
- func (i *Int) Scan(s fmt.ScanState, verb rune) error
- func (i *Int) SetInt64(v int64)
- func (i *Int) SetUint64(v uint64)
- func (i *Int) String() string
- func (i *Int) Uint64() uint64
- func (i *Int) UnmarshalJSON(b []byte) error
- func (i *Int) UnmarshalMsg(b []byte) ([]byte, error)
- func (i *Int) UnmarshalText(b []byte) error
- type IntSlice
- type Keyfile
- type Log
- type PrivateKey
- func (k *PrivateKey) Address() *Address
- func (k *PrivateKey) FromString(s string) error
- func (k *PrivateKey) MarshalText() ([]byte, error)
- func (k *PrivateKey) PublicKey() *PublicKey
- func (k *PrivateKey) Sign(hash *Hash) *Signature
- func (k *PrivateKey) Signer() Signer
- func (k *PrivateKey) String() string
- func (k *PrivateKey) ToECDSA() *ecdsa.PrivateKey
- func (p *PrivateKey) ToKeyfile(name string, pass []byte) *Keyfile
- func (k *PrivateKey) UnmarshalText(b []byte) error
- type PublicKey
- type RPCError
- func (z *RPCError) DecodeMsg(dc *msgp.Reader) (err error)
- func (z RPCError) EncodeMsg(en *msgp.Writer) (err error)
- func (e *RPCError) Error() string
- func (z RPCError) MarshalMsg(b []byte) (o []byte, err error)
- func (z RPCError) Msgsize() (s int)
- func (z *RPCError) UnmarshalMsg(bts []byte) (o []byte, err error)
- type RPCRequest
- type RPCResponse
- type RPCTransport
- type Receipt
- func (z *Receipt) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *Receipt) EncodeMsg(en *msgp.Writer) (err error)
- func (z *Receipt) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Receipt) Msgsize() (s int)
- func (r *Receipt) ParseTransfer(l *Log) (TokenTransfer, bool)
- func (r *Receipt) Threw() bool
- func (z *Receipt) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Sender
- func (s *Sender) Call(opts *CallOpts) (Hash, error)
- func (s *Sender) Cancel(h *Hash) (Hash, error)
- func (s *Sender) ConstCall(to *Address, method string, out interface{}, args ...EtherType) error
- func (s *Sender) Create(code []byte, value *Int) (Address, error)
- func (s *Sender) Drain(prompt ...func(t *Transaction)) error
- func (s *Sender) Send(to *Address, method string, args ...EtherType) (Hash, error)
- func (s *Sender) Wait(h *Hash) error
- type Signature
- func (s *Signature) FromString(z string) error
- func (s *Signature) MarshalText() ([]byte, error)
- func (z *Signature) Parts() (r, s big.Int, v int)
- func (z *Signature) Recover(hash *Hash) (*PublicKey, error)
- func (s *Signature) String() string
- func (s *Signature) UnmarshalText(b []byte) error
- func (z *Signature) Valid() bool
- type Signer
- type Source
- type SyncStatus
- type TokenTransfer
- func (z *TokenTransfer) DecodeMsg(dc *msgp.Reader) (err error)
- func (z *TokenTransfer) EncodeMsg(en *msgp.Writer) (err error)
- func (z *TokenTransfer) MarshalMsg(b []byte) (o []byte, err error)
- func (z *TokenTransfer) Msgsize() (s int)
- func (z *TokenTransfer) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Transaction
- func (z *Transaction) DecodeMsg(dc *msgp.Reader) (err error)
- func (t *Transaction) Encode(sig *Signature) []byte
- func (z *Transaction) EncodeMsg(en *msgp.Writer) (err error)
- func (t *Transaction) HashToSign() *Hash
- func (z *Transaction) MarshalMsg(b []byte) (o []byte, err error)
- func (z *Transaction) Msgsize() (s int)
- func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error)
- type Transport
- type Uint64
- func (z *Uint64) DecodeMsg(dc *msgp.Reader) (err error)
- func (z Uint64) EncodeMsg(en *msgp.Writer) (err error)
- func (z Uint64) MarshalMsg(b []byte) (o []byte, err error)
- func (i Uint64) MarshalText() ([]byte, error)
- func (z Uint64) Msgsize() (s int)
- func (i *Uint64) UnmarshalJSON(b []byte) error
- func (z *Uint64) UnmarshalMsg(bts []byte) (o []byte, err error)
- func (i *Uint64) UnmarshalText(b []byte) error
Constants ¶
const ( Pending = int64(-2) // Pending block. Latest = int64(-1) // Latest block. Earliest = int64(0) // Earliest block. )
Block specifiers.
Variables ¶
var ( // ERC20Transfer is hash of the canonical ERC20 Transfer event ERC20Transfer = HashString("Transfer(address,address,uint256)") // ERC20Approve is the hash of the canonical ERC20 Approve event ERC20Approve = HashString("Approval(address,address,uint256)") )
var ErrCannotCancel = errors.New("seth: cannot cancel")
ErrCannotCancel is returned when attempting to cancel a transaction that has already been mined.
var ErrNotFound = errors.New("seth: not found")
var PasswordDenied = errors.New("password denied")
Functions ¶
func CurvePoint ¶
CurvePoint takes the x-coordinate of a secp256k1 curve point and computes the corresponding y-coordinate. "v" should indicate the low bit of the y-coordinate.
func DecodeABI ¶
DecodeABI decodes a solidity return value into its constituent arguments.
NOTE: Not all values are supported. Currently, supported types are:
- integers -> all Go integer types, plus big.Int and seth.Int
- bool -> bool
- string -> string
- address -> seth.Address
- uint256[] -> seth.IntSlice
- address[] -> seth.AddrSlice
- bytes32[] -> seth.DataSlice
- bytes -> []byte or seth.Bytes
func IPCDial ¶
func IPCDial() (io.ReadWriteCloser, error)
IPCDial dials geth over local IPC
It can be used in NewClient like
NewClient(IPCDial)
func IPCPath ¶
func IPCPath(s string) func() (io.ReadWriteCloser, error)
IPCPath returns a closure that dials a unix socket.
It can be used in NewClient like
NewClient(IPCPath("/path/to/geth.ipc"))
func MetadataHash ¶
MetadataHash tries to return the portion of a compiled solidity contract that represents the hash of the metadata. If the metadata can't be found, a nil slice is returned.
func RegisterHSM ¶
RegisterHSM registers an HSM under a name and a function to probe if the HSM is installed. The probe function can take hints passed from FindHSM to help it locate the module.
func SignTransaction ¶
func SignTransaction(t *Transaction, sign Signer) ([]byte, error)
SignTransaction produces a signed, serialized 'raw' transaction from the given transaction and signer.
func StripBytecode ¶
StripBytecode returns the portion of the bytecode that isn't solidity metadata. If no solidity metadata is present, the argument is returned unchanged.
Types ¶
type ABIDecoder ¶
type ABIDecoder []interface{}
ABIDecoder is an encoding.TextUnmarshaler that can unpack a JSON-RPC response into its constituent solidity arugments.
func NewABIDecoder ¶
func NewABIDecoder(args ...interface{}) *ABIDecoder
NewABIDecoder constructs an ABIDecoder whose implementation of encoding.TextUnmarshaler unpacks arguments into the provided arguments.
func (*ABIDecoder) UnmarshalText ¶
func (d *ABIDecoder) UnmarshalText(v []byte) error
UnmarshalText implements encoding.TextUnmarshaler
type ABIDescriptor ¶
type ABIDescriptor struct { // one of "function" "constructor" "fallback" "event" Type string `json:"type" msg:"name"` Name string `json:"name" msg:"name"` Inputs []ABIParam `json:"inputs" msg:"inputs"` Outputs []ABIParam `json:"outputs,omitempty" msg:"outputs"` Payable bool `json:"payable" msg:"payable"` Mutability string `json:"stateMutability" msg:"stateMutability"` // "pure", "view", "nonpayable", "payable" Constant bool `json:"constant" msg:"constant"` // either "pure" or "view" Anonymous bool `json:"anonymous" msg:"anonymous"` }
ABIDescriptor describes a function, constructor, or event
func (*ABIDescriptor) DecodeMsg ¶
func (z *ABIDescriptor) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*ABIDescriptor) EncodeMsg ¶
func (z *ABIDescriptor) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*ABIDescriptor) MarshalMsg ¶
func (z *ABIDescriptor) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*ABIDescriptor) Msgsize ¶
func (z *ABIDescriptor) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*ABIDescriptor) Signature ¶
func (d *ABIDescriptor) Signature() string
Signature returns the canonical function/event signature. For functions, the first 4 bytes of the hash of the signature is the function selector, and for events, the hash of the signature is the first topic in the log.
func (*ABIDescriptor) UnmarshalMsg ¶
func (z *ABIDescriptor) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type ABIParam ¶
type ABIParam struct { Name string `json:"name" msg:"name"` Type string `json:"type" msg:"type"` Components []ABIParam `json:"components,omitempty" msg:"componenets"` // for tuples, nested parameters Indexed bool `json:"indexed" msg:"indexed"` // for events, whether or not the parameter is indexed }
ABIParam describes an input or output parameter to an ABIDescriptor
func (*ABIParam) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type AddrSlice ¶
type AddrSlice []Address
AddrSlice is an implementation of EtherSlice for a list of addresses
type Address ¶
type Address [20]byte
Address represent an Ethereum address
func (*Address) FromString ¶
func (*Address) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Address) MarshalText ¶
func (*Address) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Address) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Address) UnmarshalText ¶
type Block ¶
type Block struct { Number *Uint64 `json:"number"` // block number, or nil if pending Hash *Hash `json:"hash"` // block hash, or nil if pending Parent Hash `json:"parentHash"` // parent block hash Nonce Uint64 `json:"nonce"` UncleHash Hash `json:"sha3Uncles"` // hash of uncles in block Bloom Data `json:"logsBloom,omitempty"` // bloom filter of logs, or nil if pending TxRoot Hash `json:"transactionsRoot"` // root of transaction trie of block StateRoot Hash `json:"stateRoot"` // root of final state trie of block ReceiptsRoot Hash `json:"receiptsRoot"` // root of receipts trie of block Miner Address `json:"miner"` GasLimit Uint64 `json:"gasLimit"` GasUsed Uint64 `json:"gasUsed"` Transactions []json.RawMessage `json:"transactions"` // transactions; either hex strings of hashes, or actual tx bodies Uncles []Hash `json:"uncles"` // array of uncle hashes Difficulty *Int `json:"difficulty"` TotalDifficulty *Int `json:"totalDifficulty"` Timestamp Uint64 `json:"timestamp"` Extra Data `json:"extraData,omitempty"` }
Block represents and Ethereum block
func (*Block) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Block) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Block) ParseTransactions ¶
func (b *Block) ParseTransactions() ([]Transaction, error)
Transactions returns the list of block transactions, given that b.Transactions is a set of serialized transactions, and not just a set of tx hashes.
type BlockIterator ¶
type BlockIterator struct {
// contains filtered or unexported fields
}
BlockIterator manages a channel that yields blocks in block number order.
func (*BlockIterator) DecodeMsg ¶
func (z *BlockIterator) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (BlockIterator) EncodeMsg ¶
func (z BlockIterator) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (BlockIterator) MarshalMsg ¶
func (z BlockIterator) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (BlockIterator) Msgsize ¶
func (z BlockIterator) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*BlockIterator) Next ¶
func (b *BlockIterator) Next() <-chan *Block
Next returns the next block in the chain. The channel will be closed when Stop() is called.
func (*BlockIterator) Stop ¶
func (b *BlockIterator) Stop()
Stop causes the block itertation to stop. It should only be called once.
func (*BlockIterator) UnmarshalMsg ¶
func (z *BlockIterator) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Bytes ¶
type Bytes []byte
Bytes is like Data, but can be be greater than 32 bytes in length
func (Bytes) MarshalText ¶
func (*Bytes) UnmarshalText ¶
type CallOpts ¶
type CallOpts struct { From *Address `json:"from,omitempty"` // Sender address To *Address `json:"to,omitempty"` // Contract address Gas *Int `json:"gas,omitempty"` // Gas offered for call GasPrice *Int `json:"gasPrice,omitempty"` // GasPrice offered for gas Value *Int `json:"value,omitempty"` // Value to send Data Data `json:"data"` // Input to the call Nonce *Uint64 `json:"nonce,omitempty"` // Nonce of the call }
CallOpts describes a transaction (contract call).
func (*CallOpts) EncodeCall ¶
EncodeCall sets up c.Data so that it reflects the given function signature and argument list.
EncodeCall does some rudimentary sanity checking on the provided arguments and panics if the function signature string or argument list is malformed. For instance, for a function signature of "transfer(address,uint256)", EncodeCall would panic if two arguments weren't provided, or if they weren't an *Address and *Int, respectively.
func (*CallOpts) Transaction ¶
func (o *CallOpts) Transaction() *Transaction
Transaction returns a transaction structure representing this call.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func NewClientTransport ¶
func NewHTTPClient ¶
func (*Client) BlockNumber ¶
BlockNumber gets the number of the most recent block.
func (*Client) ConstCall ¶
ConstCall executes an EVM call without mining a transaction into the blockchain. If 'pending' is true, the transaction is executed in the pending block; otherwise the call is executed in the latest block. 'out' should be a type that can be unmarshaled from the JSON representation of the return value of the function.
func (*Client) ConstCallAt ¶
ConstCallAt executes a call in the given block.
func (*Client) Do ¶
func (c *Client) Do(method string, params []json.RawMessage, result interface{}) error
Do makes a raw rpc request; it does not interpret the method or param strings, and tries to unmarshal the result directly into "result." Use another method instead, if you can.
func (*Client) EstimateGas ¶
EstimateGas estimates the gas cost of mining this call into the blockchain.
func (*Client) FilterTopics ¶
FilterTopics creates a log filter that matches the given topics. (Topics are order-dependent.) If 'addr' is non-nil, only logs generated from that address are yielded by the filter. If 'start' and 'end' are non-negative, then they specify the range of blocks in which to search. Otherwise, the filter starts at the latest block.
func (*Client) GetBalance ¶
GetBalance gets the balance of an address in wei at the latest block.
func (*Client) GetBalanceAt ¶
GetBalanceAt gets the balance for a specific address and at a specific block number.
func (*Client) GetBlock ¶
GetBlock gets a block by block number. If 'txs' is true, the block includes all the transactions in the block; otherwise it only includes the transaction hashes.
func (*Client) GetNonceAt ¶
GetNonceAt gets the account nonce for a specific address and at a specific block number.
func (*Client) GetReceipt ¶
GetReceipt gets a receipt for a given transaction hash.
func (*Client) GetTransaction ¶
func (c *Client) GetTransaction(h *Hash) (*Transaction, error)
GetTransaction gets a transaction by its hash
func (*Client) Hashrate ¶
Hashrate gets the number of hashes per second that the node is mining with.
func (*Client) IterateBlocks ¶
func (c *Client) IterateBlocks(from int64, txs bool) *BlockIterator
IterateBlocks creates a BlockIterator that starts at the given block number.
func (Client) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Client) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Client) Pending ¶
func (c *Client) Pending() ([]Transaction, error)
Pending returns the list of pending transactions.
func (*Client) ProtocolVersion ¶
ProtocolVersion gets the protocol version of the node.
func (*Client) StorageAt ¶
StorageAt reads contract storage from a contract at a particular 256-bit address.
func (*Client) Syncing ¶
func (c *Client) Syncing() (*SyncStatus, error)
Syncing returns the syncing status of the node, or nil if not syncing.
func (*Client) TokenTransfers ¶
func (c *Client) TokenTransfers(from *Address, to *Address, tok *Address, start, end int64) (*Filter, error)
TokenTransfers returns a filter that searches for token transfers matching the given arguments. If any of the argments are nil, the filter matches that argument as a wildcard. In other words, if from, to, and tok are all nil, this filter finds all token transfers in the given block range.
func (*Client) UnlockAccount ¶
UnlockAccount unlocks the given address with the associated passphrase.
type CompiledBundle ¶
type CompiledBundle struct { Filenames []string `msg:"filenames"` // Input filenames in sourcemap ID order Sources []string `msg:"sources"` // actual source code, in filename order Contracts []CompiledContract `msg:"contracts"` // Compiled code Warnings []string `msg:"warnings"` }
CompiledBundle represents the output of a single invocation of solc. A CompiledBundle contains zero or more contracts.
func Compile ¶
func Compile(sources []Source) (*CompiledBundle, error)
Compile sources into a bundle with caching.
func CompileGlob ¶
func CompileGlob(glob string) (*CompiledBundle, error)
CompileGlob compiles all the files that match the given filepath glob (e.g. "*.sol")
func CompileString ¶
func CompileString(code string) (*CompiledBundle, error)
CompileString compiles source code from a string.
func (*CompiledBundle) Contract ¶
func (c *CompiledBundle) Contract(name string) *CompiledContract
func (*CompiledBundle) DecodeMsg ¶
func (z *CompiledBundle) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*CompiledBundle) EncodeMsg ¶
func (z *CompiledBundle) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*CompiledBundle) MarshalMsg ¶
func (z *CompiledBundle) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*CompiledBundle) Msgsize ¶
func (z *CompiledBundle) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*CompiledBundle) SourceOf ¶
func (b *CompiledBundle) SourceOf(c *CompiledContract, pc int) string
SourceOf returns the source line (text) of the given pc.
NOTE: right now solc creates terrible source maps. You may get the entire contract code back in the source string.
func (*CompiledBundle) UnmarshalMsg ¶
func (z *CompiledBundle) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type CompiledContract ¶
type CompiledContract struct { Name string `msg:"name"` // Contract name Code []byte `msg:"code"` // Code is the EVM bytecode for a contract Sourcemap string `msg:"sourcemap"` // Sourcemap is the stringified source map for the contract ABI []ABIDescriptor `msg:"abi"` // Raw JSON ABI // contains filtered or unexported fields }
CompiledContract represents a single solidity contract.
func (*CompiledContract) DecodeMsg ¶
func (z *CompiledContract) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*CompiledContract) EncodeMsg ¶
func (z *CompiledContract) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*CompiledContract) Find ¶
func (c *CompiledContract) Find(desc string) *ABIDescriptor
Find finds a function or event based on the hash of the descriptor. Keep in mind that the descriptor must use canonical type names and no superfluous whitespace.
For example:
c.Find("transfer(address,uint256)")
find the ERC20 "transfer" function. Similarly,
c.Find("Transfer(address,address,uint256)")
finds the ERC20 "Transfer" event.
func (*CompiledContract) MarshalMsg ¶
func (z *CompiledContract) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*CompiledContract) Msgsize ¶
func (z *CompiledContract) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*CompiledContract) UnmarshalMsg ¶
func (z *CompiledContract) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Data ¶
type Data []byte
Data is just binary that can decode Ethereum's silly quoted hex
func (Data) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Data) MarshalText ¶
func (Data) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Data) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Data) UnmarshalText ¶
type EtherSlice ¶
type EtherSlice interface { // The implementation of EtherSlice.EncodeABI should // only concatenate the raw slice values to the input, // and not the slice length prefix. EtherType // Len should return the number of elements in the slice Len() int }
EtherSlice is an EtherType that represents a dynamically-sized list (e.g. []address or []uint in solidity)
type EtherType ¶
type EtherType interface { // EncodeABI encodes this type using the // canonical contract ABI encoding EncodeABI(v []byte) []byte // contains filtered or unexported methods }
EtherType represents a type in the Ethereum Contract ABI type system https://github.com/ethereum/wiki/wiki/Ethereum-Contract-ABI
type Filter ¶
type Filter struct {
// contains filtered or unexported fields
}
Filter represents a Log filter
func (*Filter) Close ¶
func (f *Filter) Close()
Close will close the filter. Closing the filter will cause the output channel to be closed. Close is safe to call from any goroutine.
type HSM ¶
type HSM interface { // Unlock unlocks the hardware security module. // It is acceptable for this function to be a no-op // if no software unlocking feature exists. Unlock(b []byte) error // Pubkeys returns the list of secp256k1 public keys // on the device, along with the ID of the key. Pubkeys() ([]HSMKey, error) // Signer should return a Signer function that // can be passed to functions like seth.SignTransaction Signer(key *HSMKey) (Signer, error) }
HSM is the interface that an HSM (Hardware Security Module) driver has to impelement. This interface is deliberately Ethereum-specific.
type HSMKey ¶
type HSMKey struct { ID string // ID is an opaque, device-specific identifier Public PublicKey // Public is the public part of the secp256k1 key-pair Aux interface{} // Device-specific data }
HSMKey represents a key on an HSM device.
type HTTPTransport ¶
type HTTPTransport struct {
URL string
}
An HTTPTransport is a client transport for making requests over HTTP.
func (*HTTPTransport) Execute ¶
func (t *HTTPTransport) Execute(req *RPCRequest, res *RPCResponse) error
Execute implements Transport.
type Hash ¶
type Hash [32]byte
Hash represents a Keccak256 hash
func HashString ¶
HashString produces a Hash that corresponds to the Keccak-256 hash of the given string
func (*Hash) FromString ¶
func (*Hash) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Hash) MarshalText ¶
func (*Hash) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Hash) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Hash) UnmarshalText ¶
type InfuraTransport ¶
type InfuraTransport struct{}
InfuraTransport is a transport that operates on https://api.infura.io/v1/jsonrpc/mainnet
func (InfuraTransport) Execute ¶
func (i InfuraTransport) Execute(req *RPCRequest, res *RPCResponse) error
type Int ¶
Int is a big.Int that can decode Ethereum's silly quoted hex
func (*Int) FromString ¶
func (Int) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Int) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Int) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type IntSlice ¶
type IntSlice []Int
IntSlice is an implementation of EtherSlice for a list of integers
type Keyfile ¶
type Keyfile struct { ID string `json:"id"` Version int `json:"version"` Crypto struct { Cipher string `json:"cipher"` CipherParams json.RawMessage `json:"cipherparams"` Ciphertext string `json:"ciphertext"` KDF string `json:"kdf"` KDFParams json.RawMessage `json:"kdfparams"` MAC string `json:"mac"` } `json:"crypto"` Address string `json:"address,omitempty"` Name string `json:"name"` Meta json.RawMessage `json:"meta"` }
Keyfile represents an Ethereum key file as defined in the "Web3 Secret Storage Definition"
type Log ¶
type Log struct { Removed bool `json:"removed"` LogIndex *Uint64 `json:"logIndex"` // nil if pending; same for following fields TxIndex *Uint64 `json:"transactionIndex"` TxHash *Hash `json:"transactionHash"` BlockHash *Hash `json:"blockHash"` BlockNumber *Uint64 `json:"blockNumber"` Address Address `json:"address"` Data Data `json:"data"` // serialized log arguments Topics []Data `json:"topics"` // indexed log arguments }
Log is an Ethereum log (or, in Solidity, an "event")
func (*Log) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type PrivateKey ¶
type PrivateKey [32]byte
A PrivateKey holds a private key.
func GenPrivateKey ¶
func GenPrivateKey() *PrivateKey
GenPrivateKey generates a private key from the default entropy source.
func NewPrivateKey ¶
func NewPrivateKey(d *big.Int) *PrivateKey
NewPrivateKey creates a private key from d.
func ParsePrivateKey ¶
func ParsePrivateKey(s string) (*PrivateKey, error)
ParsePrivateKey parses a private key.
func (*PrivateKey) Address ¶
func (k *PrivateKey) Address() *Address
Address returns the address corresponding to this private key.
func (*PrivateKey) FromString ¶
func (k *PrivateKey) FromString(s string) error
FromString parses a private key from a string.
func (*PrivateKey) MarshalText ¶
func (k *PrivateKey) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler.
func (*PrivateKey) PublicKey ¶
func (k *PrivateKey) PublicKey() *PublicKey
PublicKey returns the public key corresponding to this private key.
func (*PrivateKey) Sign ¶
func (k *PrivateKey) Sign(hash *Hash) *Signature
Sign a hash with this private key.
func (*PrivateKey) Signer ¶
func (k *PrivateKey) Signer() Signer
Signer returns a Signer for this private key.
func (*PrivateKey) String ¶
func (k *PrivateKey) String() string
String returns a string representation of the private key.
func (*PrivateKey) ToECDSA ¶
func (k *PrivateKey) ToECDSA() *ecdsa.PrivateKey
ToECDSA returns the private key as an ECDSA private key.
func (*PrivateKey) ToKeyfile ¶
func (p *PrivateKey) ToKeyfile(name string, pass []byte) *Keyfile
ToKeyfile produces a Keyfile for p with the given name and password. The Keyfile is produced using the strongest available parameters, which, as of this writing, are aes-128-ctr encryption and scrypt-based key-derivation. Pass Name may be "". For privacy reasons, ToKeyfile doesn't set Keyfile.Address.
func (*PrivateKey) UnmarshalText ¶
func (k *PrivateKey) UnmarshalText(b []byte) error
UnmarshalText implements encoding.TextUnmarshaler.
type PublicKey ¶
type PublicKey [64]byte
A PublicKey holds a public key.
func NewPublicKey ¶
NewPublicKey creates a public key from X and Y.
func ParsePublicKey ¶
ParsePublicKey parses a public key.
func (*PublicKey) FromString ¶
FromString parses a public key from a string.
func (*PublicKey) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*PublicKey) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type RPCError ¶
type RPCError struct { Code int `json:"code"` Message string `json:"message"` Data json.RawMessage `json:"data"` }
RPCError is an error returned by a server
func (RPCError) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type RPCRequest ¶
type RPCRequest struct { Version string `json:"jsonrpc"` Method string `json:"method"` Params []json.RawMessage `json:"params"` ID int `json:"id"` }
RPCRequest is a request to be sent to an RPC server.
type RPCResponse ¶
type RPCResponse struct { ID int `json:"id"` Version string `json:"jsonrpc"` Result json.RawMessage `json:"result"` Error RPCError `json:"error"` }
RPCResponse is a response returned by an RPC server.
type RPCTransport ¶
type RPCTransport struct {
// contains filtered or unexported fields
}
An RPCTrasport is a client transport for making requests over an RPC connection.
func (*RPCTransport) Execute ¶
func (t *RPCTransport) Execute(req *RPCRequest, res *RPCResponse) error
type Receipt ¶
type Receipt struct { Hash Hash `json:"transactionHash"` Index Uint64 `json:"transactionIndex"` BlockHash Hash `json:"blockHash"` BlockNumber Uint64 `json:"blockNumber"` GasUsed Uint64 `json:"gasUsed"` Cumulative Uint64 `json:"cumulativeGasUsed"` Address *Address `json:"contractAddress"` // contract created, or none if not a contract creation Status Uint64 `json:"status"` Logs []Log `json:"logs"` }
Receipt is a transaction receipt
func (*Receipt) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (*Receipt) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Receipt) ParseTransfer ¶
func (r *Receipt) ParseTransfer(l *Log) (TokenTransfer, bool)
ParseTransfer tries to parse this log as an ERC20 token transfer event, with the signature
event Transfer(address indexed from, address indexed to, uint256 value);
type Sender ¶
type Sender struct { *Client Addr *Address // A Signer can be used to sign raw transactions for this sender. If // this is set, all transactions will be sent as raw transactions. Signer Signer // GasRatio is the ratio of the gas estimate // to use as the gas offered for a transaction, // expressed as a rational number. // For instance, Num=5,Denom=4 would offer 5/4ths of // the gas estimate as the gas for a transaction. GasRatio struct { Num, Denom int } // GasPrice is the gas price offered for each transaction. GasPrice Int }
Sender is a client that sends transactions from a particular address.
func (*Sender) Call ¶
Call makes a transaction call using the given CallOpts. Omitted fields are populated with default values.
func (*Sender) Create ¶
Create creates a new contract with the given contract code. This call blocks until the transaction posts, and then returns the contract's address.
func (*Sender) Drain ¶
func (s *Sender) Drain(prompt ...func(t *Transaction)) error
Drain waits for the pending transaction pool to contain no transactions from this account.
type Signature ¶
type Signature [65]byte
A Signature holds an ECDSA signature in Ethereum's compact representation.
func NewSignature ¶
NewSignature constructs a signature from r, s, and v.
func ParseSignature ¶
ParseSignature parses a signature from a string.
func (*Signature) FromString ¶
FromString parses a signature from a string.
func (*Signature) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (*Signature) Recover ¶
Recover validates the signature and returns a public key given the hash.
func (*Signature) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
type Source ¶
func (Source) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
type SyncStatus ¶
type SyncStatus struct { Starting Uint64 `json:"startingBlock"` // Starting block of sync. Current Uint64 `json:"currentBlock"` // Current block of sync. Highest Uint64 `json:"highestBlock"` // Highest block of sync, estimated. }
SyncStatus indicates the syncing status of the node.
type TokenTransfer ¶
type TokenTransfer struct { Block int64 // block number TxHeight int // index of transaction in block Token Address // address of contract From Address // 'from' argument in transfer To Address // 'to' argument in transfer Amount Int // value amount }
TokenTransfer represents an ERC20 token transfer event
func (*TokenTransfer) DecodeMsg ¶
func (z *TokenTransfer) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*TokenTransfer) EncodeMsg ¶
func (z *TokenTransfer) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*TokenTransfer) MarshalMsg ¶
func (z *TokenTransfer) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*TokenTransfer) Msgsize ¶
func (z *TokenTransfer) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*TokenTransfer) UnmarshalMsg ¶
func (z *TokenTransfer) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Transaction ¶
type Transaction struct { Hash Hash `json:"hash"` // tx hash Nonce Uint64 `json:"nonce"` // sender nonce Block Hash `json:"blockHash"` // hash of parent block BlockNumber Uint64 `json:"blockNumber"` // To *Address `json:"to"` // receiver, or nil for contract creation TxIndex *Uint64 `json:"transactionIndex"` // transaction index, or nil if pending From *Address `json:"from"` // from Value Int `json:"value"` // value in wei GasPrice Int `json:"gasPrice"` // gas price Gas Uint64 `json:"gas"` // gas spent on transaction Input Data `json:"input"` // input data }
Transaction represents an ethereum transaction.
func (*Transaction) DecodeMsg ¶
func (z *Transaction) DecodeMsg(dc *msgp.Reader) (err error)
DecodeMsg implements msgp.Decodable
func (*Transaction) Encode ¶
func (t *Transaction) Encode(sig *Signature) []byte
Encode returns an RLP encoded representation of the transaction. If a signature is provided, this will return an encoded representation containing the signature.
func (*Transaction) EncodeMsg ¶
func (z *Transaction) EncodeMsg(en *msgp.Writer) (err error)
EncodeMsg implements msgp.Encodable
func (*Transaction) HashToSign ¶
func (t *Transaction) HashToSign() *Hash
HashToSign returns a hash which can be used to sign the transaction.
func (*Transaction) MarshalMsg ¶
func (z *Transaction) MarshalMsg(b []byte) (o []byte, err error)
MarshalMsg implements msgp.Marshaler
func (*Transaction) Msgsize ¶
func (z *Transaction) Msgsize() (s int)
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Transaction) UnmarshalMsg ¶
func (z *Transaction) UnmarshalMsg(bts []byte) (o []byte, err error)
UnmarshalMsg implements msgp.Unmarshaler
type Transport ¶
type Transport interface {
Execute(req *RPCRequest, res *RPCResponse) error
}
type Uint64 ¶
type Uint64 uint64
Uint64 is a uint64 that marshals as a hex-encoded number.
func (Uint64) MarshalMsg ¶
MarshalMsg implements msgp.Marshaler
func (Uint64) MarshalText ¶
MarshalText implements encoding.TextMarshaler.
func (Uint64) Msgsize ¶
Msgsize returns an upper bound estimate of the number of bytes occupied by the serialized message
func (*Uint64) UnmarshalJSON ¶
UnmarshalJSON implements json.Unmarshaler.
func (*Uint64) UnmarshalMsg ¶
UnmarshalMsg implements msgp.Unmarshaler
func (*Uint64) UnmarshalText ¶
UnmarshalText implements encoding.TextUnmarshaler.
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
package cc is a library for converting between cryptocurrencies.
|
package cc is a library for converting between cryptocurrencies. |
cmd
|
|
Package yubihsm implements a cgo wrapper around yubihsm.h provided by the YubiHSM2 SDK.
|
Package yubihsm implements a cgo wrapper around yubihsm.h provided by the YubiHSM2 SDK. |