Trait alloy_zksync::provider::ZksyncProvider

source ·
pub trait ZksyncProvider<T = BoxTransport>: Provider<Zksync>
where T: Transport + Clone,
{
Show 22 methods // Provided methods fn get_main_contract(&self) -> ProviderCall<NoParams, Address> { ... } fn get_testnet_paymaster(&self) -> ProviderCall<NoParams, Option<Address>> { ... } fn get_l1_chain_id(&self) -> ProviderCall<NoParams, U64> { ... } fn get_l1_batch_number(&self) -> ProviderCall<NoParams, U64> { ... } fn estimate_fee( &self, tx: TransactionRequest, ) -> ProviderCall<(TransactionRequest,), Eip712Fee> { ... } fn estimate_gas_l1_to_l2( &self, tx: TransactionRequest, ) -> ProviderCall<(TransactionRequest,), U256> { ... } fn get_bridgehub_contract(&self) -> ProviderCall<NoParams, Option<Address>> { ... } fn get_bridge_contracts(&self) -> ProviderCall<NoParams, BridgeAddresses> { ... } fn get_base_token_l1_address(&self) -> ProviderCall<NoParams, Address> { ... } fn get_all_account_balances( &self, address: Address, ) -> ProviderCall<(Address,), HashMap<Address, U256>> { ... } fn get_l2_to_l1_msg_proof( &self, block_number: u64, sender: Address, msg: B256, l2_log_position: Option<usize>, ) -> ProviderCall<(u64, Address, B256, Option<usize>), Option<L2ToL1LogProof>> { ... } fn get_l2_to_l1_log_proof( &self, tx_hash: B256, l2_to_l1_log_index: Option<usize>, ) -> ProviderCall<(B256, Option<usize>), Option<L2ToL1LogProof>> { ... } fn get_block_details( &self, block_number: u64, ) -> ProviderCall<(u64,), Option<BlockDetails>> { ... } fn get_transaction_details( &self, tx_hash: B256, ) -> ProviderCall<(B256,), Option<TransactionDetails>> { ... } fn get_raw_block_transactions( &self, block_number: u64, ) -> ProviderCall<(u64,), Vec<Transaction>> { ... } fn get_l1_batch_details( &self, l1_batch_number: u64, ) -> ProviderCall<(u64,), Option<L1BatchDetails>> { ... } fn get_bytecode_by_hash( &self, tx_hash: B256, ) -> ProviderCall<(B256,), Option<Bytes>> { ... } fn get_l1_batch_block_range( &self, l1_batch_number: u64, ) -> ProviderCall<(u64,), Option<(U64, U64)>> { ... } fn get_l1_gas_price(&self) -> ProviderCall<NoParams, U256> { ... } fn get_fee_params(&self) -> ProviderCall<NoParams, FeeParams> { ... } fn get_protocol_version( &self, version_id: Option<u16>, ) -> ProviderCall<(Option<u16>,), Option<ProtocolVersion>> { ... } fn get_proof( &self, address: Address, keys: Vec<B256>, l1_batch_number: u64, ) -> ProviderCall<(Address, Vec<B256>, u64), Option<Proof>> { ... }
}
Expand description

ZKsync provider is an extension trait for the Provider trait that adds ZKsync-specific methods.

This trait has a blanket implementation for any type that implements Provider trait. It means that it can be built using normal ProviderBuilder by specifying the network generic parameter.

For convenience, you can use zksync_provider function instead.

Provided Methods§

source

fn get_main_contract(&self) -> ProviderCall<NoParams, Address>

Gets the address of the main ZKsync contract on L1.

source

fn get_testnet_paymaster(&self) -> ProviderCall<NoParams, Option<Address>>

Gets the address of the testnet paymaster ZKsync contract on L2, if it’s present on the network.

source

fn get_l1_chain_id(&self) -> ProviderCall<NoParams, U64>

Gets the L1 Chain ID.

source

fn get_l1_batch_number(&self) -> ProviderCall<NoParams, U64>

Gets the latest L1 batch number.

source

fn estimate_fee( &self, tx: TransactionRequest, ) -> ProviderCall<(TransactionRequest,), Eip712Fee>

Estimates transaction gas for a transaction.

source

fn estimate_gas_l1_to_l2( &self, tx: TransactionRequest, ) -> ProviderCall<(TransactionRequest,), U256>

Estimates the gas required for an L1 to L2 transaction.

source

fn get_bridgehub_contract(&self) -> ProviderCall<NoParams, Option<Address>>

Retrieves the bridge hub contract address.

source

fn get_bridge_contracts(&self) -> ProviderCall<NoParams, BridgeAddresses>

Retrieves the addresses of canonical bridge contracts for ZKsync Era.

source

fn get_base_token_l1_address(&self) -> ProviderCall<NoParams, Address>

Retrieves the L1 base token address.

source

fn get_all_account_balances( &self, address: Address, ) -> ProviderCall<(Address,), HashMap<Address, U256>>

Gets all account balances for a given address.

§Parameters
  • address: an account address.
§Returns

A hashmap with token addresses as keys and their corresponding balances as values. Each key-value pair represents the balance of a specific token held by the account.

source

fn get_l2_to_l1_msg_proof( &self, block_number: u64, sender: Address, msg: B256, l2_log_position: Option<usize>, ) -> ProviderCall<(u64, Address, B256, Option<usize>), Option<L2ToL1LogProof>>

Retrieves the proof for an L2 to L1 message.

§Parameters
  • block_number: the block number where the message was emitted.
  • sender: The sender of the message.
  • msg: The keccak256 hash of the sent message.
  • l2_log_position: Optional: The index in the block of the event that was emitted by the L1Messenger when submitting this message. If it is omitted, the proof for the first message is returned.
source

fn get_l2_to_l1_log_proof( &self, tx_hash: B256, l2_to_l1_log_index: Option<usize>, ) -> ProviderCall<(B256, Option<usize>), Option<L2ToL1LogProof>>

Retrieves the log proof for an L2 to L1 transaction.

§Parameters
  • tx_hash: hash of the L2 transaction the L2 to L1 log was produced in.
  • l2_to_l1_log_index: Optional: The index of the L2 to L1 log in the transaction.
source

fn get_block_details( &self, block_number: u64, ) -> ProviderCall<(u64,), Option<BlockDetails>>

Retrieves details for a given L2 block.

source

fn get_transaction_details( &self, tx_hash: B256, ) -> ProviderCall<(B256,), Option<TransactionDetails>>

Retrieves details for a given transaction.

source

fn get_raw_block_transactions( &self, block_number: u64, ) -> ProviderCall<(u64,), Vec<Transaction>>

Lists transactions in a native encoding (e.g. that has more details, but does not adhere to the “common” Web3 Transaction interface).

source

fn get_l1_batch_details( &self, l1_batch_number: u64, ) -> ProviderCall<(u64,), Option<L1BatchDetails>>

Retrieves details for a given L1 batch.

source

fn get_bytecode_by_hash( &self, tx_hash: B256, ) -> ProviderCall<(B256,), Option<Bytes>>

Retrieves the bytecode of a transaction by its hash.

source

fn get_l1_batch_block_range( &self, l1_batch_number: u64, ) -> ProviderCall<(u64,), Option<(U64, U64)>>

Returns the range of blocks contained within a batch given by the batch number.

source

fn get_l1_gas_price(&self) -> ProviderCall<NoParams, U256>

Retrieves the current L1 gas price.

source

fn get_fee_params(&self) -> ProviderCall<NoParams, FeeParams>

Retrieves the current fee parameters.

source

fn get_protocol_version( &self, version_id: Option<u16>, ) -> ProviderCall<(Option<u16>,), Option<ProtocolVersion>>

Gets the protocol version.

source

fn get_proof( &self, address: Address, keys: Vec<B256>, l1_batch_number: u64, ) -> ProviderCall<(Address, Vec<B256>, u64), Option<Proof>>

Generates Merkle proofs for one or more storage values associated with a specific account, accompanied by a proof of their authenticity. It verifies that these values remain unaltered.

§Parameters
  • address: account address to fetch storage values and proofs for.
  • keys: the keys in the account.
  • l1_batch_number: number of the L1 batch specifying the point in time at which the requested values are returned.
§Returns

The account details and proofs for storage keys.

Implementors§

source§

impl<P> ZksyncProvider for P
where P: Provider<Zksync>,