1
use sp_core::crypto::AccountId32;
use sp_core::crypto::Ss58Codec;
use subxt::{
    PolkadotConfig,
};

#[subxt::subxt(
    runtime_metadata_path = "./artifacts/metadata.scale",
    derive_for_all_types = "Clone, Debug, Eq, PartialEq"
)]
pub mod polkadot {}


let account_id32 = AccountId32::from_string(&account_id).unwrap();
let account_id32_clone = account_id32.clone();

let client = subxt::client::OnlineClient::<PolkadotConfig>::from_url(NODE_URL)
                    .await
                    .unwrap();
let balance_storage = polkadot::storage().system().account(account_id32_clone);
let balance_details = client
                    .storage()
                    .at(None)
                    .await
                    .unwrap()
                    .fetch(&balance_storage)
                    .await
                    .unwrap();

if let Some(balance_details) = balance_details {
        println!("{}",balance_details.data.free);
     }

It was working before subxt upgrade to subxt 0.26.0

But now it gives error:

 let balance_storage = polkadot::storage().system().account(account_id32_clone);
   |                                                                    ------- ^^^^^^^^^^^^^^^^^^ the trait `Borrow<subxt::utils::AccountId32>` is not implemented for `sp_core::crypto::AccountId32`
   |                                                                    |
   |                                                                    required by a bound introduced by this call

I am using sp-core = { version = "7.0.0", default-features = false }

1 Answer 1

2

Try:

use subxt::utils::AccountId32;

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .