use subxt::{Error, OnlineClient, PolkadotConfig};
use subxt_signer::sr25519::dev;
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
mod polkadot {}
#[tokio::main]
async fn main() -> Result<(), Error> {
let api = OnlineClient::<PolkadotConfig>::new().await?;
let at_block = api.at_current_block().await?;
let dest = dev::bob().public_key().into();
let balance_transfer_tx = polkadot::transactions()
.balances()
.transfer_allow_death(dest, 10_000);
let from = dev::alice();
let events = at_block
.transactions()
.sign_and_submit_then_watch_default(&balance_transfer_tx, &from)
.await?
.wait_for_finalized_success()
.await?;
if let Some(event) = events.find_first::<polkadot::balances::events::Transfer>() {
println!("Balance transfer success: {event:?}");
}
Ok(())
}