pub trait StateProvider:
BlockHashReader
+ AccountReader
+ StateRootProvider
+ StorageRootProvider
+ StateProofProvider
+ Send
+ Sync {
// Required methods
fn storage(
&self,
account: Address,
storage_key: StorageKey,
) -> ProviderResult<Option<StorageValue>>;
fn bytecode_by_hash(
&self,
code_hash: B256,
) -> ProviderResult<Option<Bytecode>>;
// Provided methods
fn account_code(&self, addr: Address) -> ProviderResult<Option<Bytecode>> { ... }
fn account_balance(&self, addr: Address) -> ProviderResult<Option<U256>> { ... }
fn account_nonce(&self, addr: Address) -> ProviderResult<Option<u64>> { ... }
}
Expand description
An abstraction for a type that provides state data.
Required Methods§
Sourcefn storage(
&self,
account: Address,
storage_key: StorageKey,
) -> ProviderResult<Option<StorageValue>>
fn storage( &self, account: Address, storage_key: StorageKey, ) -> ProviderResult<Option<StorageValue>>
Get storage of given account.
Sourcefn bytecode_by_hash(&self, code_hash: B256) -> ProviderResult<Option<Bytecode>>
fn bytecode_by_hash(&self, code_hash: B256) -> ProviderResult<Option<Bytecode>>
Get account code by its hash
Provided Methods§
Sourcefn account_code(&self, addr: Address) -> ProviderResult<Option<Bytecode>>
fn account_code(&self, addr: Address) -> ProviderResult<Option<Bytecode>>
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) -> ProviderResult<Option<U256>>
fn account_balance(&self, addr: Address) -> ProviderResult<Option<U256>>
Get account balance by its address.
Returns None
if the account doesn’t exist
Sourcefn account_nonce(&self, addr: Address) -> ProviderResult<Option<u64>>
fn account_nonce(&self, addr: Address) -> ProviderResult<Option<u64>>
Get account nonce by its address.
Returns None
if the account doesn’t exist