pub trait StateProvider:
BlockHashReader
+ AccountReader
+ BytecodeReader
+ StateRootProvider
+ StorageRootProvider
+ StateProofProvider
+ HashedPostStateProvider {
// Required methods
fn storage(
&self,
account: Address,
storage_key: FixedBytes<32>,
) -> Result<Option<Uint<256, 4>>, ProviderError>;
fn storage_by_hashed_key(
&self,
address: Address,
hashed_storage_key: FixedBytes<32>,
) -> Result<Option<Uint<256, 4>>, ProviderError>;
// Provided methods
fn account_code(
&self,
addr: &Address,
) -> Result<Option<Bytecode>, ProviderError> { ... }
fn account_balance(
&self,
addr: &Address,
) -> Result<Option<Uint<256, 4>>, ProviderError> { ... }
fn account_nonce(
&self,
addr: &Address,
) -> Result<Option<u64>, ProviderError> { ... }
}Expand description
An abstraction for a type that provides state data.
Required Methods§
Sourcefn storage(
&self,
account: Address,
storage_key: FixedBytes<32>,
) -> Result<Option<Uint<256, 4>>, ProviderError>
fn storage( &self, account: Address, storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
Get storage of given account.
When use_hashed_state is enabled, the account and storage_key are hashed internally
before lookup. Callers must pass unhashed (plain) values.
Sourcefn storage_by_hashed_key(
&self,
address: Address,
hashed_storage_key: FixedBytes<32>,
) -> Result<Option<Uint<256, 4>>, ProviderError>
fn storage_by_hashed_key( &self, address: Address, hashed_storage_key: FixedBytes<32>, ) -> Result<Option<Uint<256, 4>>, ProviderError>
Get storage using a pre-hashed storage key.
Unlike Self::storage, hashed_storage_key must already be keccak256-hashed.
The address remains unhashed (plain) since history indices are keyed by plain address.
This is used when changeset keys are pre-hashed (e.g., use_hashed_state mode)
to avoid double-hashing.
Provided Methods§
Sourcefn account_code(
&self,
addr: &Address,
) -> Result<Option<Bytecode>, ProviderError>
fn account_code( &self, addr: &Address, ) -> Result<Option<Bytecode>, ProviderError>
Get account code by its address.
Returns None if the account doesn’t exist or account is not a contract
Sourcefn account_balance(
&self,
addr: &Address,
) -> Result<Option<Uint<256, 4>>, ProviderError>
fn account_balance( &self, addr: &Address, ) -> Result<Option<Uint<256, 4>>, ProviderError>
Get account balance by its address.
Returns None if the account doesn’t exist
Sourcefn account_nonce(&self, addr: &Address) -> Result<Option<u64>, ProviderError>
fn account_nonce(&self, addr: &Address) -> Result<Option<u64>, ProviderError>
Get account nonce by its address.
Returns None if the account doesn’t exist