ethereum

package
v0.6.8 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2022 License: AGPL-3.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

View Source
const AddressLength = common.AddressLength

AddressLength is the expected length of the address

View Source
const SignatureLength = 65

SignatureLength is the expected length of the Signature.

Variables

View Source
var HexToAddress = common.HexToAddress

HexToAddress returns Address from hex representation.

View Source
var HexToBytes = common.FromHex

HexToBytes returns bytes from hex string.

View Source
var HexToHash = common.HexToHash

HexToHash returns Hash from hex string.

View Source
var IsHexAddress = common.IsHexAddress

IsHexAddress verifies if given string is a valid Ethereum address.

Functions

func BlockNumberFromContext added in v0.5.0

func BlockNumberFromContext(ctx context.Context) *big.Int

BlockNumberFromContext returns the block number from the context.

func SHA3Hash

func SHA3Hash(b []byte) []byte

SHA3Hash calculates SHA3 hash.

func WithBlockNumber added in v0.5.0

func WithBlockNumber(ctx context.Context, block *big.Int) context.Context

WithBlockNumber sets the block number in the context.

Types

type Address

type Address = common.Address
var EmptyAddress Address

EmptyAddress contains empty Ethereum address: 0x0000000000000000000000000000000000000000

type Call

type Call struct {
	// Address is the contract's address.
	Address Address
	// Data is the raw call data.
	Data []byte
}

type Client

type Client interface {
	// BlockNumber returns the current block number.
	BlockNumber(ctx context.Context) (*big.Int, error)
	// Call executes a message call transaction, which is directly
	// executed in the VM of the node, but never mined into the blockchain.
	Call(ctx context.Context, call Call) ([]byte, error)
	// CallBlocks executes the same call on multiple blocks (counting back from the latest)
	// and returns multiple results in a slice
	CallBlocks(ctx context.Context, call Call, blocks []int64) ([][]byte, error)
	// MultiCall works like the Call function but allows to execute multiple
	// calls at once.
	MultiCall(ctx context.Context, calls []Call) ([][]byte, error)
	// Storage returns the value of key in the contract storage of the
	// given account.
	Storage(ctx context.Context, address Address, key Hash) ([]byte, error)
	// SendTransaction injects a signed transaction into the pending pool
	// for execution.
	SendTransaction(ctx context.Context, transaction *Transaction) (*Hash, error)
}

type Hash

type Hash = common.Hash

type Signature

type Signature [SignatureLength]byte

Signature represents the 65 byte signature.

func SignatureFromBytes

func SignatureFromBytes(b []byte) Signature

func SignatureFromVRS

func SignatureFromVRS(v uint8, r [32]byte, s [32]byte) Signature

func (Signature) Bytes

func (s Signature) Bytes() []byte

func (Signature) VRS

func (s Signature) VRS() (sv uint8, sr [32]byte, ss [32]byte)

type Signer

type Signer interface {
	// Address returns account's address used to sign data. May be empty if
	// the signer is used only to verify signatures.
	Address() Address
	// SignTransaction signs transaction. Signed transaction will be set
	// to the SignedTx field in the Transaction structure.
	SignTransaction(transaction *Transaction) error
	// Signature signs the hash of the given data and returns it.
	Signature(data []byte) (Signature, error)
	// Recover returns the wallet address that created the given signature.
	// TODO: Move Recover to a separate interface.
	Recover(signature Signature, data []byte) (*Address, error)
}

type Transaction

type Transaction struct {
	// Address is the contract's address.
	Address Address
	// Nonce is the transaction nonce. If zero, the nonce will be filled
	// automatically.
	Nonce uint64
	// PriorityFee is the maximum tip value. If nil, the suggested gas tip value
	// will be used.
	PriorityFee *big.Int
	// MaxFee is the maximum fee value. If nil, double value of a suggested
	// gas fee will be used.
	MaxFee *big.Int
	// GasLimit is the maximum gas available to be used for this transaction.
	GasLimit *big.Int
	// Data is the raw transaction data.
	Data []byte
	// ChainID is the transaction chain ID. If nil, the chan ID will be filled
	// automatically.
	ChainID *big.Int
	// SignedTx contains signed transaction. The data type stored here may
	// be different for various implementations.
	SignedTx interface{}
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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