Add get_storage_at
@@ -398,7 +398,27 @@ impl<P: JsonRpcClient> Provider<P> {
.map_err(Into::into)?)
}
- // TODO: get_storage_at
+ /// Get the storage of an address for a particular slot location
+ pub async fn get_storage_at(
+ &self,
+ from: impl Into<NameOrAddress>,
+ location: H256,
+ block: Option<BlockNumber>,
+ ) -> Result<H256, ProviderError> {
+ let from = match from.into() {
+ NameOrAddress::Name(ens_name) => self.resolve_name(&ens_name).await?,
+ NameOrAddress::Address(addr) => addr,
+ };
+
+ let from = utils::serialize(&from);
+ let location = utils::serialize(&location);
+ let block = utils::serialize(&block.unwrap_or(BlockNumber::Latest));
+ Ok(self
+ .0
+ .request("eth_getStorageAt", [from, location, block])
+ .await
+ .map_err(Into::into)?)
+ }
/// Returns the deployed code at a given address
pub async fn get_code(
