backends

package
v1.4.8 Latest Latest
Warning

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

Go to latest
Published: Jun 24, 2016 License: GPL-3.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewNilBackend

func NewNilBackend() bind.ContractBackend

NewNilBackend creates a new binding backend that can be used for instantiation but will panic on any invocation. Its sole purpose is to help testing.

func NewRPCBackend

func NewRPCBackend(client rpc.Client) bind.ContractBackend

NewRPCBackend creates a new binding backend to an RPC provider that can be used to interact with remote contracts.

Types

type SimulatedBackend

type SimulatedBackend struct {
	// contains filtered or unexported fields
}

SimulatedBackend implements bind.ContractBackend, simulating a blockchain in the background. Its main purpose is to allow easily testing contract bindings.

func NewSimulatedBackend

func NewSimulatedBackend(accounts ...core.GenesisAccount) *SimulatedBackend

NewSimulatedBackend creates a new binding backend using a simulated blockchain for testing purposes.

func (*SimulatedBackend) Commit

func (b *SimulatedBackend) Commit()

Commit imports all the pending transactions as a single block and starts a fresh new state.

func (*SimulatedBackend) ContractCall

func (b *SimulatedBackend) ContractCall(contract common.Address, data []byte, pending bool) ([]byte, error)

ContractCall implements ContractCaller.ContractCall, executing the specified contract with the given input data.

func (*SimulatedBackend) EstimateGasLimit

func (b *SimulatedBackend) EstimateGasLimit(sender common.Address, contract *common.Address, value *big.Int, data []byte) (*big.Int, error)

EstimateGasLimit implements ContractTransactor.EstimateGasLimit, executing the requested code against the currently pending block/state and returning the used gas.

func (*SimulatedBackend) HasCode added in v1.4.5

func (b *SimulatedBackend) HasCode(contract common.Address, pending bool) (bool, error)

HasCode implements ContractVerifier.HasCode, checking whether there is any code associated with a certain account in the blockchain.

func (*SimulatedBackend) PendingAccountNonce

func (b *SimulatedBackend) PendingAccountNonce(account common.Address) (uint64, error)

PendingAccountNonce implements ContractTransactor.PendingAccountNonce, retrieving the nonce currently pending for the account.

func (*SimulatedBackend) Rollback

func (b *SimulatedBackend) Rollback()

Rollback aborts all pending transactions, reverting to the last committed state.

func (*SimulatedBackend) SendTransaction

func (b *SimulatedBackend) SendTransaction(tx *types.Transaction) error

SendTransaction implements ContractTransactor.SendTransaction, delegating the raw transaction injection to the remote node.

func (*SimulatedBackend) SuggestGasPrice

func (b *SimulatedBackend) SuggestGasPrice() (*big.Int, error)

SuggestGasPrice implements ContractTransactor.SuggestGasPrice. Since the simulated chain doens't have miners, we just return a gas price of 1 for any call.

Jump to

Keyboard shortcuts

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