interface.go 1.82 KB
Newer Older
1 2 3 4 5 6
package drivers

import (
	"context"
	"math/big"

7
	"github.com/ethereum/go-ethereum"
8 9 10 11 12 13 14
	"github.com/ethereum/go-ethereum/common"
	"github.com/ethereum/go-ethereum/core/types"
)

// L1Client is an abstraction over an L1 Ethereum client functionality required
// by the batch submitter.
type L1Client interface {
15 16 17 18 19 20 21
	// EstimateGas tries to estimate the gas needed to execute a specific
	// transaction based on the current pending state of the backend blockchain.
	// There is no guarantee that this is the true gas limit requirement as
	// other transactions may be added or removed by miners, but it should
	// provide a basis for setting a reasonable default.
	EstimateGas(context.Context, ethereum.CallMsg) (uint64, error)

22 23 24
	// HeaderByNumber returns a block header from the current canonical chain.
	// If number is nil, the latest known header is returned.
	HeaderByNumber(context.Context, *big.Int) (*types.Header, error)
25 26 27 28 29 30 31 32 33 34 35 36

	// NonceAt returns the account nonce of the given account. The block number
	// can be nil, in which case the nonce is taken from the latest known block.
	NonceAt(context.Context, common.Address, *big.Int) (uint64, error)

	// SendTransaction injects a signed transaction into the pending pool for
	// execution.
	//
	// If the transaction was a contract creation use the TransactionReceipt
	// method to get the contract address after the transaction has been mined.
	SendTransaction(context.Context, *types.Transaction) error

37 38 39 40
	// SuggestGasTipCap retrieves the currently suggested gas tip cap after 1559
	// to allow a timely execution of a transaction.
	SuggestGasTipCap(context.Context) (*big.Int, error)

41 42 43 44
	// TransactionReceipt returns the receipt of a transaction by transaction
	// hash. Note that the receipt is not available for pending transactions.
	TransactionReceipt(context.Context, common.Hash) (*types.Receipt, error)
}