Skip to main content
9 votes

Determining the final fee from a client

Just to elaborate on this, since I've been digging into it and asking around... We can use the following formula to calculate the partial_fee for an extrinsic (ie the total/final fee minus any tip). ...
jsdw's user avatar
  • 1,335
8 votes
Accepted

Where do I add a SignedExtension in a Subxt call?

Edit Oct 16 2023: As of Subxt 0.32, there is now a SignedExtension trait in Subxt, and an signed_extensions::AnyOf type which can be given some Config and tuple ofSignedExtensionimpls, and itself ...
jsdw's user avatar
  • 1,335
7 votes
Accepted

Making sudo call using subxt

There is a nice test that could be helpful for you to discover how to use sudo: let call = Call::Balances(BalancesCall::transfer { dest: bob, value: 10_000, }); let found_event = cxt .api ...
Bruno's user avatar
  • 8,335
7 votes
Accepted

With subxt how can I subscribe to watch extrinsics?

The logic in subxt will map through in a similar way. The EventRecord struct contains a Phase enum where ApplyExtrinsic(u32) refers to the index of the extrinsic in the block. So the way to map it is -...
Jaco's user avatar
  • 5,875
6 votes
Accepted

Why can't I decode an extrinsic created with the contracts tab in Polkadot JS apps?

You tried to decode a hash of the extrinsic, not the actual encoded extrinsic itself. The "extrinsic hash" is a one-way blake256(<extrinsic data>) so it doesn't contain the decodable ...
Jaco's user avatar
  • 5,875
4 votes
Accepted

How do `subxt` and `substrate-api-client` libraries differ?

I've not used substrate-api-client yet, but I think one distinguishing feature is autogeneration of code from metadata is something that subxt has put a lot of effort into. substrate-api-client ...
Squirrel's user avatar
  • 3,889
4 votes

What is the difference between check_extrinsic and uncheck_extrinsic?

UncheckedExtrinsic is the format in which the outside is sending the extrinsic to the node. This extrinsic is aware of the full structure, meaning it knows how to decode the Call signature etc. The ...
bkchr's user avatar
  • 11.6k
4 votes

Call ink contract using rust

With Rust, it's a bit more complicated than with JS/TS. Here's an example of how to call a contract using subxt: // assuming you have `api` and the contract address let mut call_data = Vec::<u8>:...
Oleksandr Mykhailenko's user avatar
4 votes
Accepted

Decoding Polkadot/Kusama transactions in Rust

Also, Subxt doesn't currently have a means to decode transactions, but you can obtain the bytes for each transaction back currently eg: let extrinsics = api.blocks().at(hash).await?.body().await?....
jsdw's user avatar
  • 1,335
4 votes
Accepted

How to get block author with Subxt?

I had a bit of a dig to see how this might be done, and it turns out that Polkadot.js does a lot of work under the hood here. I hope somebody might be able to refine this, but I had a go at ...
jsdw's user avatar
  • 1,335
4 votes

How to get block author with Subxt?

I have similar requirement and I followed the suggestion in the previous answer given by @jsdw. Following is my code, I am able to receive the author AccountId32 from the block. fn extract_author(...
Yeou's user avatar
  • 229
4 votes

Sudo tx with subxt

Solved it: let call = nodetemplate::runtime_types::node_template_runtime::RuntimeCall::System( SystemCall::set_code { code: wasm_binary.expect("could not decode wasm binary&...
flipchan's user avatar
  • 369
4 votes

Incompatibility between subxt_signer and subxt

I found the solution to the problem. In my case, I needed to make changes to Cargo.toml. subxt-signer = { version = "0.31.0", features = ["subxt"]} I had to add features = ["...
Haider's user avatar
  • 71
3 votes
Accepted

Signed bytes from Schnorrkel library throws Bad Signature error

Actually we need a context string for substrate signatures let context = schnorrkel::signing_context(b"substrate"); Signature::Sr25519(secret.sign(context.bytes(msg))) and then we can use ...
Rusty Pythonic Script's user avatar
3 votes
Accepted

Use subxt to connect to any live node

Ah, all right I see you are using the wrong port. Change the URI to "wss://kusama-rpc.polkadot.io:443" should make it work.
Niklas Adolfsson's user avatar
3 votes

How to use subxt to query for an historical event

Eventually found the right incantation for querying whether a historical event was emitted: #[subxt::subxt(runtime_metadata_path = "metadata.scale")] pub mod runtime { } use subxt::{...
Vincent's user avatar
  • 158
3 votes

Determining the final fee from a client

There is no event for the final fee, but you can calculate it either using the runtime API for transaction_payment.query_info or by executing the fee calculation from weight/length yourself. Sidecar ...
joepetrowski's user avatar
  • 2,975
3 votes

High transaction throughput - single acccount

Your code looks reasonable, but i would rather send the extrinsics in serial and not concurrently. Otherwise you will create a lot of RPC connections and DOS your node. I am working on something ...
Oliver Tale-Yazdi's user avatar
3 votes
Accepted

What is the difference between check_extrinsic and uncheck_extrinsic?

The correct way to work with data coming from a substrate node is to use a tool or library that uses the Metadata to decode rpc responses correctly, as shown here: https://docs.substrate.io/v3/runtime/...
Joshua Mir's user avatar
3 votes

What is the smartest way to make multiple dynamic storage queries using subxt?

The options that I'm aware of are: to do what you've done (whether you use static or dynamic storage lookups). Use the "lower level" RPC method (api.rpc().query_storage_at(..) to query ...
jsdw's user avatar
  • 1,335
3 votes

How do we check Subxt's compatibility (or any Substrate product's compatibility) with Polkadot versions?

Answer is originally found here. Subxt doesn't currently need to "track" versions of Polkadot for the most part, since many parts of the API that can change (the available pallets, ...
Josh's user avatar
  • 425
3 votes

How index the substrate storage maps and ipfs cids?

Subxt is geared around interacting with the tip of a chain, and will run into issues trying to obtain and index older entries (and will need custom metadata to be provided to go back through older ...
jsdw's user avatar
  • 1,335
3 votes

Subxt vs substrate-api-client vs polkadotjs

PolkadotJS is the library to interact with Substrate nodes in Javascript, if you are building your frontend app with JS is the one to go. If your code is in another language there are some ...
Alex Bean's user avatar
  • 5,757
3 votes

subxt `PairSigner` trait bounds not satisfied

Add this import: use sp_core::{Pair}; And then the method from_phrase() returns you a tuple: (Pair, Seed) get only the Pair in your method new: let pair = sp_core::sr25519::Pair::from_phrase(...
Alex Bean's user avatar
  • 5,757
3 votes
Accepted

subxt `PairSigner` trait bounds not satisfied

This is a simple case of the subxt and sp_* dependencies being out of sync; I think you used Subxt master branch to take the dependencies you used, but you're pointing at an older version of Subxt in ...
jsdw's user avatar
  • 1,335
3 votes
Accepted

Why do subxt::Error not fit in anyhow::Error?

I've repro'd the error with a minimal example, and although the conversion subxt::Error -> anyhow::Error is implemented, it is not implemented when wrapped in a result. Thus, you can either ...
Nate Armstrong's user avatar
3 votes
Accepted

Metadata(PalletNotFound) with subxt

First of all, thanks for asking about this topic Any metadata on the disk can be further inspected with the use of subxt-cli, we've also added some new features that allows users to quickly explore ...
Alexandru Vasile's user avatar
3 votes
Accepted

Subxt - Catch Extrinsic Error

A DispatchError is returned if the extrinsic failed; this ends up being returned from the above as a subxt::Error::Runtime(dispatch_error) after wait_for_finalized_success, so you can match on it ...
jsdw's user avatar
  • 1,335
3 votes
Accepted

transfer balance subxt

The account you want to send the funds to (you need the address): let account_B: AccountId32 = the_address.parse().unwrap(); The account you want to send the funds from (you need the seed): let ...
Alex Bean's user avatar
  • 5,757
3 votes
Accepted

MultiAddress to Address String

Subxt has very basic support for turning 32-byte account IDs (aka public keys) into SS58 addresses. This is how: use subxt::utils::AccountId32; let account_id_bytes: [u8; 32] = // ... let ...
jsdw's user avatar
  • 1,335

Only top scored, non community-wiki answers of a minimum length are eligible