chainlink: Index | Files

package eth

import ""


Package Files

client.go contracts.go gen_log_json.go geth_copied.go types.go


const FunctionSelectorLength = 4

FunctionSelectorLength should always be a length of 4 as a byte.


var ChainlinkFulfilledTopic = utils.MustHash("ChainlinkFulfilled(bytes32)")

ChainlinkFulfilledTopic is the signature for the event emitted after calling ChainlinkClient.validateChainlinkCallback(requestId). See ../../evm-contracts/src/v0.6/ChainlinkClient.sol

var WeiPerEth = new(big.Int).Exp(big.NewInt(10), big.NewInt(18), nil)

WeiPerEth is amount of Wei currency units in one Eth.

func MustGetV6ContractEventID Uses

func MustGetV6ContractEventID(name, eventName string) common.Hash

MustGetV6ContractEventID finds the event for the given contract by searching embedded contract assets from evm/, or panics if not found.

type Block Uses

type Block struct {
    Transactions []Transaction  `json:"transactions"`
    Difficulty   hexutil.Uint64 `json:"difficulty"`

Block represents a full block See:

type BlockHeader Uses

type BlockHeader struct {
    ParentHash  common.Hash      `json:"parentHash"`
    UncleHash   common.Hash      `json:"sha3Uncles"`
    Coinbase    common.Address   `json:"miner"`
    Root        common.Hash      `json:"stateRoot"`
    TxHash      common.Hash      `json:"transactionsRoot"`
    ReceiptHash common.Hash      `json:"receiptsRoot"`
    Bloom       types.Bloom      `json:"logsBloom"`
    Difficulty  hexutil.Big      `json:"difficulty"`
    Number      hexutil.Big      `json:"number"`
    GasLimit    hexutil.Uint64   `json:"gasLimit"`
    GasUsed     hexutil.Uint64   `json:"gasUsed"`
    Time        hexutil.Big      `json:"timestamp"`
    Extra       hexutil.Bytes    `json:"extraData"`
    Nonce       types.BlockNonce `json:"nonce"`
    GethHash    common.Hash      `json:"mixHash"`
    ParityHash  common.Hash      `json:"hash"`

BlockHeader represents a block header in the Ethereum blockchain. Deliberately does not have required fields because some fields aren't present depending on the Ethereum node. i.e. Parity does not always send mixHash

func (BlockHeader) Hash Uses

func (h BlockHeader) Hash() common.Hash

Hash will return GethHash if it exists otherwise it returns the ParityHash

type CallArgs Uses

type CallArgs struct {
    To   common.Address `json:"to"`
    Data hexutil.Bytes  `json:"data"`

CallArgs represents the data used to call the balance method of an ERC contract. "To" is the address of the ERC contract. "Data" is the message sent to the contract.

type CallerSubscriber Uses

type CallerSubscriber interface {
    Call(result interface{}, method string, args ...interface{}) error
    Subscribe(context.Context, interface{}, ...interface{}) (Subscription, error)

CallerSubscriber implements the Call and Subscribe functions. Call performs a JSON-RPC call with the given arguments and Subscribe registers a subscription, using an open stream to receive updates from ethereum node.

type CallerSubscriberClient Uses

type CallerSubscriberClient struct {

CallerSubscriberClient implements the ethereum Client interface using a CallerSubscriber instance.

func (*CallerSubscriberClient) GetBlockByNumber Uses

func (client *CallerSubscriberClient) GetBlockByNumber(hex string) (Block, error)

GetBlockByNumber returns the block for the passed hex, or "latest", "earliest", "pending". Includes all transactions

func (*CallerSubscriberClient) GetBlockHeight Uses

func (client *CallerSubscriberClient) GetBlockHeight() (uint64, error)

func (*CallerSubscriberClient) GetChainID Uses

func (client *CallerSubscriberClient) GetChainID() (*big.Int, error)

GetChainID returns the ethereum ChainID.

func (*CallerSubscriberClient) GetERC20Balance Uses

func (client *CallerSubscriberClient) GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)

GetERC20Balance returns the balance of the given address for the token contract address.

func (*CallerSubscriberClient) GetEthBalance Uses

func (client *CallerSubscriberClient) GetEthBalance(address common.Address) (*assets.Eth, error)

GetEthBalance returns the balance of the given addresses in Ether.

func (*CallerSubscriberClient) GetLogs Uses

func (client *CallerSubscriberClient) GetLogs(q ethereum.FilterQuery) ([]Log, error)

GetLogs returns all logs that respect the passed filter query.

func (*CallerSubscriberClient) GetNonce Uses

func (client *CallerSubscriberClient) GetNonce(address common.Address) (uint64, error)

GetNonce returns the nonce (transaction count) for a given address.

func (*CallerSubscriberClient) GetTxReceipt Uses

func (client *CallerSubscriberClient) GetTxReceipt(hash common.Hash) (*TxReceipt, error)

GetTxReceipt returns the transaction receipt for the given transaction hash.

func (*CallerSubscriberClient) SendRawTx Uses

func (client *CallerSubscriberClient) SendRawTx(hex string) (common.Hash, error)

SendRawTx sends a signed transaction to the transaction pool.

func (*CallerSubscriberClient) SubscribeToLogs Uses

func (client *CallerSubscriberClient) SubscribeToLogs(
    ctx context.Context,
    channel chan<- Log,
    q ethereum.FilterQuery,
) (Subscription, error)

SubscribeToLogs registers a subscription for push notifications of logs from a given address.

Inspired by the eth client's SubscribeToLogs:

func (*CallerSubscriberClient) SubscribeToNewHeads Uses

func (client *CallerSubscriberClient) SubscribeToNewHeads(
    ctx context.Context,
    channel chan<- BlockHeader,
) (Subscription, error)

SubscribeToNewHeads registers a subscription for push notifications of new blocks.

type Client Uses

type Client interface {
    GetNonce(address common.Address) (uint64, error)
    GetEthBalance(address common.Address) (*assets.Eth, error)
    GetERC20Balance(address common.Address, contractAddress common.Address) (*big.Int, error)
    SendRawTx(hex string) (common.Hash, error)
    GetTxReceipt(hash common.Hash) (*TxReceipt, error)
    GetBlockHeight() (uint64, error)
    GetBlockByNumber(hex string) (Block, error)
    GetChainID() (*big.Int, error)
    SubscribeToNewHeads(ctx context.Context, channel chan<- BlockHeader) (Subscription, error)

Client is the interface used to interact with an ethereum node.

type ContractCodec Uses

type ContractCodec interface {
    ABI() *abi.ABI
    GetMethodID(method string) ([]byte, error)
    EncodeMessageCall(method string, args ...interface{}) ([]byte, error)
    UnpackLog(out interface{}, event string, log Log) error

func GetContractCodec Uses

func GetContractCodec(name string) (ContractCodec, error)

GetContract loads the contract JSON file from ../../evm-contracts/abi/v0.4 and parses the ABI JSON contents into an abi.ABI object

NB: These contracts can be built by running

yarn setup:contracts

in the base project directory.

func GetV6ContractCodec Uses

func GetV6ContractCodec(name string) (ContractCodec, error)

GetV6Contract loads the contract JSON file from ../../evm-contracts/abi/v0.6 and parses the ABI JSON contents into an abi.ABI object

NB: These contracts can be built by running

yarn setup:contracts

in the base project directory.

type FunctionSelector Uses

type FunctionSelector [FunctionSelectorLength]byte

FunctionSelector is the first four bytes of the call data for a function call and specifies the function to be called.

func BytesToFunctionSelector Uses

func BytesToFunctionSelector(b []byte) FunctionSelector

BytesToFunctionSelector converts the given bytes to a FunctionSelector.

func HexToFunctionSelector Uses

func HexToFunctionSelector(s string) FunctionSelector

HexToFunctionSelector converts the given string to a FunctionSelector.

func (FunctionSelector) Bytes Uses

func (f FunctionSelector) Bytes() []byte

Bytes returns the FunctionSelector as a byte slice

func (FunctionSelector) MarshalJSON Uses

func (f FunctionSelector) MarshalJSON() ([]byte, error)

MarshalJSON returns the JSON encoding of f

func (FunctionSelector) Scan Uses

func (f FunctionSelector) Scan(value interface{}) error

Scan returns the selector from its serialization in the database

func (*FunctionSelector) SetBytes Uses

func (f *FunctionSelector) SetBytes(b []byte)

SetBytes sets the FunctionSelector to that of the given bytes (will trim).

func (FunctionSelector) String Uses

func (f FunctionSelector) String() string

String returns the FunctionSelector as a string type.

func (*FunctionSelector) UnmarshalJSON Uses

func (f *FunctionSelector) UnmarshalJSON(input []byte) error

UnmarshalJSON parses the raw FunctionSelector and sets the FunctionSelector type to the given input.

func (FunctionSelector) Value Uses

func (f FunctionSelector) Value() (driver.Value, error)

Value returns this instance serialized for database storage

func (FunctionSelector) WithoutPrefix Uses

func (f FunctionSelector) WithoutPrefix() string

WithoutPrefix returns the FunctionSelector as a string without the '0x' prefix.

type Log Uses

type Log struct {
    // Consensus fields:
    // address of the contract that generated the event
    Address common.Address `json:"address" gencodec:"required"`
    // list of topics provided by the contract.
    Topics []common.Hash `json:"topics" gencodec:"required"`
    // supplied by the contract, usually ABI-encoded
    Data UntrustedBytes `json:"data" gencodec:"required"`

    // Derived fields. These fields are filled in by the node
    // but not secured by consensus.
    // block in which the transaction was included
    BlockNumber uint64 `json:"blockNumber"`
    // hash of the transaction
    TxHash common.Hash `json:"transactionHash"`
    // index of the transaction in the block
    TxIndex uint `json:"transactionIndex"`
    // hash of the block in which the transaction was included
    BlockHash common.Hash `json:"blockHash"`
    // index of the log in the receipt
    Index uint `json:"logIndex"`

    // The Removed field is true if this log was reverted due to a chain reorganisation.
    // You must pay attention to this field if you receive logs through a filter query.
    Removed bool `json:"removed"`

Log represents a contract log event. These events are generated by the LOG opcode and stored/indexed by the node. NOTE: This is almost (but not quite) a copy of go-ethereum/core/types.Log, in log.go

func (Log) Copy Uses

func (log Log) Copy() Log

Copy creates a deep copy of a log. The LogBroadcaster creates a single websocket subscription for all log events that we're interested in and distributes them to the relevant subscribers elsewhere in the codebase. If a given log needs to be distributed to multiple subscribers while avoiding data races, it's necessary to make copies.

func (Log) GetTopic Uses

func (log Log) GetTopic(idx uint) (common.Hash, error)

GetTopic returns the hash for the topic at the passed index, or error.

func (Log) MarshalJSON Uses

func (l Log) MarshalJSON() ([]byte, error)

MarshalJSON marshals as JSON.

func (*Log) UnmarshalJSON Uses

func (l *Log) UnmarshalJSON(input []byte) error

UnmarshalJSON unmarshals from JSON.

type LogSubscriber Uses

type LogSubscriber interface {
    GetLogs(q ethereum.FilterQuery) ([]Log, error)
    SubscribeToLogs(ctx context.Context, channel chan<- Log, q ethereum.FilterQuery) (Subscription, error)

LogSubscriber encapsulates only the methods needed for subscribing to ethereum log events.

type Subscription Uses

type Subscription interface {
    Err() <-chan error

Subscription holds the methods for an ethereum log subscription.

The Unsubscribe method cancels the sending of events. You must call Unsubscribe in all cases to ensure that resources related to the subscription are released. It can be called any number of times.

type Transaction Uses

type Transaction struct {
    GasPrice hexutil.Uint64 `json:"gasPrice"`

type TxReceipt Uses

type TxReceipt struct {
    BlockNumber *utils.Big   `json:"blockNumber"`
    BlockHash   *common.Hash `json:"blockHash"`
    Hash        common.Hash  `json:"transactionHash"`
    Logs        []Log        `json:"logs"`

TxReceipt holds the block number and the transaction hash of a signed transaction that has been written to the blockchain.

func (TxReceipt) FulfilledRunLog Uses

func (txr TxReceipt) FulfilledRunLog() bool

FulfilledRunLog returns true if this tx receipt is the result of a fulfilled run log.

func (*TxReceipt) Unconfirmed Uses

func (txr *TxReceipt) Unconfirmed() bool

Unconfirmed returns true if the transaction is not confirmed.

type UntrustedBytes Uses

type UntrustedBytes []byte

This data can contain anything and is submitted by user on-chain, so we must be extra careful how we interact with it

func (UntrustedBytes) SafeByteSlice Uses

func (ary UntrustedBytes) SafeByteSlice(start int, end int) ([]byte, error)

SafeByteSlice returns an error on out of bounds access to a byte array, where a normal slice would panic instead

Package eth imports 20 packages (graph). Updated 2020-04-06. Refresh now. Tools for package owners.

The go get command cannot install this package because of the following issues: