ethbackend

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Aug 22, 2025 License: GPL-3.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Backend

type Backend struct {
	ethclient.Client
	// contains filtered or unexported fields
}

func DialOmni added in v0.17.0

func DialOmni(ctx context.Context, addr string) (*Backend, error)

func NewBackend

func NewBackend(chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client, privateKeys ...*ecdsa.PrivateKey) (*Backend, error)

NewBackend returns a new backend backed by in-memory private keys.

func NewDevBackend added in v0.11.0

func NewDevBackend(chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client) (*Backend, error)

NewDevBackend returns a backend with all pre-funded anvil dev accounts.

func NewFireBackend

func NewFireBackend(ctx context.Context, chainName string, chainID uint64, blockPeriod time.Duration, ethCl ethclient.Client, fireCl fireblocks.Client) (*Backend, error)

NewFireBackend returns a backend that supports all accounts supported by the configured fireblocks client. Note that private keys can still be added via AddAccount.

func (*Backend) AddAccount

func (b *Backend) AddAccount(privkey *ecdsa.PrivateKey) (common.Address, error)

AddAccount adds a in-memory private key account to the backend. Note this can be called even if other accounts are fireblocks based.

func (*Backend) BindOpts

func (b *Backend) BindOpts(ctx context.Context, from common.Address) (*bind.TransactOpts, error)

BindOpts returns a new TransactOpts for interacting with bindings based contracts for the provided account. The TransactOpts are partially stubbed, since txmgr handles nonces and signing.

Do not cache or store the TransactOpts, as they are not safe for concurrent use (pointer). Rather create a new TransactOpts for each transaction.

func (*Backend) Chain

func (b *Backend) Chain() (string, uint64)

func (*Backend) EnsureSynced

func (b *Backend) EnsureSynced(ctx context.Context) error

EnsureSynced returns an error if the backend is not synced.

func (*Backend) PublicKey

func (b *Backend) PublicKey(from common.Address) (*ecdsa.PublicKey, error)

func (*Backend) Send

func (*Backend) SendTransaction

func (b *Backend) SendTransaction(ctx context.Context, in *ethtypes.Transaction) error

SendTransaction intercepts the tx that bindings generates, extracts the from address (if the backendStubSigner was used), the strips fields, and passes it to the txmgr for reliable broadcasting.

func (*Backend) Sign

func (b *Backend) Sign(ctx context.Context, from common.Address, input [32]byte) ([65]byte, error)

func (*Backend) WaitConfirmed added in v0.15.0

func (b *Backend) WaitConfirmed(ctx context.Context, tx *ethtypes.Transaction) (*ethclient.Receipt, error)

WaitConfirmed is similar to WaitMined, except that it also waits for the (first) receipt block to be "confirmed". "Confirmed" depends on the evmchain.Reorgs value, if false, it is just calls WaitMined and returns the receipt. Otherwise, it also waits for "safe" confirmation (this is very slow up to 6min). It returns an error if the (first) receipt is reorged out (even though the tx may still be included in a different block).

func (*Backend) WaitMined

func (b *Backend) WaitMined(ctx context.Context, tx *ethtypes.Transaction) (*ethclient.Receipt, error)

WaitMined waits for the transaction to be mined and asserts the receipt is successful.

func (*Backend) WithReservedNonce added in v0.17.0

func (b *Backend) WithReservedNonce(ctx context.Context, from common.Address) (context.Context, uint64, error)

WithReservedNonce returns a copy of the context including the next reserved nonce (also returned). This is useful to ensure sequential nonces with parallel transaction sending/mining..

type Backends

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

Backends is a wrapper around a set of Backends, one for each chain. At this point, it only supports "a single account for all Backends".

See Backends godoc for more information.

func BackendsFrom added in v0.13.0

func BackendsFrom(backends map[uint64]*Backend) Backends

func BackendsFromClients added in v0.14.1

func BackendsFromClients(ethClients map[uint64]ethclient.Client, privkeys ...*ecdsa.PrivateKey) (Backends, error)

func BackendsFromNetwork added in v0.12.0

func BackendsFromNetwork(ctx context.Context, network netconf.Network, endpoints xchain.RPCEndpoints, privKeys ...*ecdsa.PrivateKey) (Backends, error)

func BackendsFromTestnet added in v0.14.1

func BackendsFromTestnet(ctx context.Context, testnet types.Testnet) (Backends, error)

BackendsFromTestnet returns a multi-backends backed by in-memory keys that supports configured all chains.

func FireBackendsFromNetwork added in v0.15.0

func FireBackendsFromNetwork(ctx context.Context, network netconf.Network, endpoints xchain.RPCEndpoints, fireCl fireblocks.Client) (Backends, error)

func NewFireBackends

func NewFireBackends(ctx context.Context, testnet types.Testnet, fireCl fireblocks.Client) (Backends, error)

NewFireBackends returns a multi-backends backed by fireblocks keys that supports configured all chains.

func (Backends) AddAccount added in v0.12.0

func (b Backends) AddAccount(privkey *ecdsa.PrivateKey) (common.Address, error)

AddAccount adds a in-memory private key account to all backends. Note this can be called even if other accounts are fireblocks based.

func (Backends) All

func (b Backends) All() map[uint64]*Backend

func (Backends) Backend

func (b Backends) Backend(sourceChainID uint64) (*Backend, error)

func (Backends) BindOpts

func (b Backends) BindOpts(ctx context.Context, sourceChainID uint64, addr common.Address) (*bind.TransactOpts, *Backend, error)

BindOpts is a convenience function that an accounts' bind.TransactOpts and Backend for a given chain.

func (Backends) Clients added in v0.12.0

func (b Backends) Clients() map[uint64]ethclient.Client

func (Backends) NewWaiter

func (b Backends) NewWaiter() *Waiter

NewWaiter returns a new Waiter.

func (Backends) RPCClients

func (b Backends) RPCClients() map[uint64]ethclient.Client

func (Backends) StartIdleConnectionClosing added in v0.14.1

func (b Backends) StartIdleConnectionClosing(ctx context.Context)

StartIdleConnectionClosing starts a goroutine for each backend to close idle connections periodically. It returns immediately.

type Waiter

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

Waiter is a convenience struct to easily wait for multiple transactions to be mined. Adding is thread safe, but it panics if Add is called after Wait.

func (*Waiter) Add

func (w *Waiter) Add(chainID uint64, tx *ethtypes.Transaction)

func (*Waiter) Wait

func (w *Waiter) Wait(ctx context.Context) error

Jump to

Keyboard shortcuts

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