1

I'm developing a client library for Dart. I wonder how can I send transactions using RPC.

If I wanted to send a balance transfer only using RPC how could I do it? What are the steps?

I know that I should encode the data before sending it, but I couldn't figure out what to encode and what RPC method to send.

2 Answers 2

7

To send the transaction look at the author_submitExtrinsic and author_submitAndWatchExtrinsic, the latter when using subscriptions and wanting to have access to the processing status.

As to the format, it really depends on the on-chain metadata and the signed extensions that are applied on the extrinsic. However generally, assuming Polkadot/Kusama it would be in the following format -

  • compact encoded length
  • version + signing bit (as per metadata, currently 0x84 when signed - version 4, high bit indicates that is it signed)
  • address of sender (generally MultiAddress, so 33 bytes in length)
  • signature of extrinsic payload (generally MultiSignature type, so 65 bytes in length)
  • mortal era
  • nonce
  • tip
  • call (indexes and params)
1
1

https://github.com/substrate-developer-hub/awesome-substrate#mobile lists at least one option: https://github.com/Pocket4D/Polkadot-Dart

Although at the time I am writing it looks stale and unfinished, sadly. But it can perhaps give you a head start to build what you need. There are a few more here to review too https://github.com/search?q=dart+substrate .

The canonical way to submit transactions aka extrinsics is via the Polkadot.js API, one tool that you may reference for how to do this could be best exemplified in the substrate-api-sidecar.

In rust there is also https://github.com/paritytech/subxt that is worth a look.

Hope these help!

1
  • 1
    Unfortunately, there's a lack of Substrate libraries for the dart-lang. I'm planning to fill that void. Taking a look at subxt helped a lot.
    – Burak
    Commented Jun 10, 2022 at 18:27

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.