mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 13:21:10 +00:00
move examples to main repo so we can include_str them for publishing (#993)
* move exampels to main repo so we can include_str them for publishing * update CI to not break examples
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::config::polkadot::{Era, PlainTip, PolkadotExtrinsicParamsBuilder as Params};
|
||||
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig};
|
||||
|
||||
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
|
||||
pub mod polkadot {}
|
||||
|
||||
#[tokio::main]
|
||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
// Create a new API client, configured to talk to Polkadot nodes.
|
||||
let api = OnlineClient::<PolkadotConfig>::new().await?;
|
||||
|
||||
// Build a balance transfer extrinsic.
|
||||
let dest = AccountKeyring::Bob.to_account_id().into();
|
||||
let tx = polkadot::tx().balances().transfer(dest, 10_000);
|
||||
|
||||
// Configure the transaction parameters; for Polkadot the tip and era:
|
||||
let tx_params = Params::new()
|
||||
.tip(PlainTip::new(1_000))
|
||||
.era(Era::Immortal, api.genesis_hash());
|
||||
|
||||
// submit the transaction:
|
||||
let from = PairSigner::new(AccountKeyring::Alice.pair());
|
||||
let hash = api.tx().sign_and_submit(&tx, &from, tx_params).await?;
|
||||
println!("Balance transfer extrinsic submitted with hash : {hash}");
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Reference in New Issue
Block a user