Documentation
¶
Overview ¶
Package chain implements everything related to interaction with smart contracts, rpc provider, etc.
Index ¶
- Constants
- type ChainAPIClient
- func (c *ChainAPIClient) GetBlockByNumber(ctx context.Context, blockNumber *big.Int) (*types.Block, error)
- func (c *ChainAPIClient) GetBlockHeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)
- func (c *ChainAPIClient) GetChainID(ctx context.Context) (*big.Int, error)
- func (c *ChainAPIClient) GetLatestBlockHeader(ctx context.Context) (*types.Header, error)
- func (c *ChainAPIClient) GetLatestBlockNumber(ctx context.Context) (uint64, error)
- func (c *ChainAPIClient) GetProof(ctx context.Context, blockNumber *big.Int, address common.Address) (*ProofResponse, error)
- type ConfigOptions
- type Contracts
- type L2ChainIDs
- type L2Output
- type NetworkType
- type OracleAccessor
- type ProofResponse
Constants ¶
const ( L1 = NetworkType("L1") L2 = NetworkType("L2") L2BedrockMessagePasserAddress = "0x4200000000000000000000000000000000000016" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ChainAPIClient ¶
type ChainAPIClient struct {
// contains filtered or unexported fields
}
ChainAPIClient connects and encapsulates all the methods to interact with a chain.
func GetAPIClient ¶
GetAPIClient returns ChainAPIClient with client attached.
func (*ChainAPIClient) GetBlockByNumber ¶
func (c *ChainAPIClient) GetBlockByNumber(ctx context.Context, blockNumber *big.Int) (*types.Block, error)
GetBlockByNumber returns block for a given block number from a connected node.
func (*ChainAPIClient) GetBlockHeaderByNumber ¶
func (c *ChainAPIClient) GetBlockHeaderByNumber(ctx context.Context, blockNumber *big.Int) (*types.Header, error)
GetBlockHeaderByNumber returns block header for a given block number from a connected node.
func (*ChainAPIClient) GetChainID ¶
GetChainID returns chainID of a connected node.
func (*ChainAPIClient) GetLatestBlockHeader ¶
GetLatestBlockHeader returns latest block header from a connected node.
func (*ChainAPIClient) GetLatestBlockNumber ¶
func (c *ChainAPIClient) GetLatestBlockNumber(ctx context.Context) (uint64, error)
GetLatestBlockNumber returns latest block number from a connected node.
type ConfigOptions ¶
type ConfigOptions struct { L1RPCEndpoint string ChainID uint64 L2OutputOracleContractAddress string }
ConfigOptions are the options required to interact with the oracle contract.
type Contracts ¶
type Contracts struct {
// contains filtered or unexported fields
}
Contracts has information of the L1 & L2 contracts addresses.
func GetContractAddressesByChainID ¶
GetContractAddressesByChainID returns contract addresses by network chainID.
type L2ChainIDs ¶
type L2ChainIDs struct {
// contains filtered or unexported fields
}
L2ChainIDs manages L2 network chainIDs.
type L2Output ¶
type L2Output struct { OutputRoot string L1Timestamp uint64 L2BlockNumber uint64 L2OutputIndex uint64 }
L2Output is the output of GetL2Output.
type NetworkType ¶
type NetworkType = string
type OracleAccessor ¶
type OracleAccessor struct {
// contains filtered or unexported fields
}
OracleAccessor binds oracle contract to an instance for querying data.
func NewOracleAccessor ¶
func NewOracleAccessor(ctx context.Context, opts *ConfigOptions) (*OracleAccessor, error)
NewOracleAccessor returns OracleAccessor with contract instance.
func (*OracleAccessor) FinalizationPeriodSeconds ¶
func (oc *OracleAccessor) FinalizationPeriodSeconds() (*big.Int, error)
FinalizationPeriodSeconds returns output finalization time in seconds.
func (*OracleAccessor) GetL2Output ¶
func (oc *OracleAccessor) GetL2Output(index *big.Int) (L2Output, error)
GetL2Output returns L2 output at given index.
func (*OracleAccessor) GetNextOutputIndex ¶
func (oc *OracleAccessor) GetNextOutputIndex() (*big.Int, error)
GetNextOutputIndex returns index of next output to be proposed.
type ProofResponse ¶
type ProofResponse struct { Address common.Address `json:"address"` AccountProof []hexutil.Bytes `json:"accountProof"` Balance *hexutil.Big `json:"balance"` CodeHash common.Hash `json:"codeHash"` Nonce hexutil.Uint64 `json:"nonce"` StorageHash common.Hash `json:"storageHash"` StorageProof []common.Hash `json:"storageProof"` }