Author API
The Author API provides a way to submit and watch extrinsics on the blockchain.
This API is available through the AuthorApi class from the polkadart package.
Sample usage
void main() async {
final provider = Provider.fromUri(Uri.parse('wss://rpc.polkadot.io'));
final author = AuthorApi(provider);
final extrinsic = hex.decode('cd018400e6c8ca9e309a1cce16eee662a9b3886f0c7b7fddce5cd89db7a6eba0a2aa003b01b873dd1fe5a0b23641496be8d7f2938f06698ca07c1de6d75a4e6f18159aaa5fdca09d9bf50d71d80f4055e34c8a40097c3c9a34d8309dbe9ca97ff450b9a28700580000000024506f6c6b6164617274');
final submit = await author.submitAndWatchExtrinsic(extrinsic as Uint8List, (data) => print('From here: ${data.type} - ${data.value}'));
}
If you send a valid extrinsic, you will get an output similar to this:
Instance of '_ForwardingStreamSubscription<SubscriptionMessage<dynamic>, ExtrinsicStatus>'
From here: broadcast - [12D3KooWEW8fqaHq47NfZx5M8VHpnGaPYFPKNyoRxHNxJNaftxex, 12D3KooWRXzBHd1cMG5DRGwo5Uw6AVB3NM35s9hJZJPLVXEjnJm1, 12D3KooWNhvdEMm58VzCogLN8zSY8M22z2BxW6HFSCzm7uxtWD4k, 12D3KooWFvW8WS6BgGqH9YwCzbYNDHt54eXu74MXsWTy5YBNVG8p, 12D3KooWKyCEReVMRfDJVMWPqYHkgNBxRuzBeGrh45gFNaRyo3xa, 12D3KooWR9ZQqixCCskgLs1iQMqFYYLsFdei1CQgg2TRkpuerU8r, 12D3KooWHVDNuABpm6oZ8ZCuiE4MvnMsZTxrURm92ESDexj1YCTw, 12D3KooWM1RwsLQPtGfDksczydDZvZjeY9ZcsanhzyJvPzCAHwpS, 12D3KooWGTYAoDHV656gGVydaG8HzPSLRKq7JYhkKCxLVEaWSZVH, 12D3KooWQXgbYeL1ueo2oD8aEktrKW57Nz2gmQocHuVknAevgWn8, 12D3KooWRCXsj3xpfQ1FAuPgTHetoF9CGEGifEPciY6vvgBZskm6, 12D3KooWRUuNjg4RE8zyXrrJWZsKCiPLMFa4KGVp88axt3SRRGs9, 12D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PydbTQmMAgXvG6peKR, 12D3KooWBaPqD5By7WZF1yPiuyd8mmHDYv3FPx2wjrF2tYDA2vct, 12D3KooWQZkoqjez2aJ8GsTf1K5vCY2PV3XxwVf9B3iuuYYxViEE, 12D3KooWPhm3P3xV2FAa2pRwi751ofrM4dCX9E1cAkQXPgAXmUv2, 12D3KooWGAkVvjifuhNmNPRBzDqLeqQ9PzAMqZSC7jc7GXKxyKAM, 12D3KooWQvuM83h996TEAV91j7WXjeZXET3ZnnC1N6sLnAA7Ye7n, 12D3KooWDRJxWNZMd7LsyrwziDzjarHNYgRkCS9TZc7uGz1tS9KU, 12D3KooWBn8eMBgQz2WR6zNMoEfDvuQ3i9oMrXhtWK4c3UEHzAo6, 12D3KooWS7HX5pNMXCDPQP5dapVPPwgzPp6cPhVgsGFwkdpV4sEc, 12D3KooWLZxXQsbADZSQmUinWASqpZMNo9NdRr4DDcvFjtCwGfhi, 12D3KooWRehgtSgMoCBKN1Dd2G6btn13HMA6pgu4vU18GRVmyzic, 12D3KooWFhmerVkfFpS198agSBJuPvebhBAEn6zb569ogXvnzq8G, 12D3KooWQZF95Wre2JSUX5zMy5ACy6zkXSqjsUV615kfF7VY6d9N, 12D3KooWKZwp59WkysZYAKLUGLJhsYKHRhvNaXvhD7fBhhCuPDy1, 12D3KooWGk8zv6TJqYtJnJtSCyUTKH3xAQg8VvvuiGNRhQ2uK8AZ]
From here: inBlock - 0x726aeb560cb25b7c731ddb7ec1df8f845ae31d2eeb98478e6f716a7e05a8ac5a
From here: retracted - 0x726aeb560cb25b7c731ddb7ec1df8f845ae31d2eeb98478e6f716a7e05a8ac5a
From here: inBlock - 0xaeaa329613992c9f06e4bff428acc49656209dad19b2829b020122058cf00aa5
From here: finalized - 0xaeaa329613992c9f06e4bff428acc49656209dad19b2829b020122058cf00aa5
Methods
There are just two methods available in the AuthorApi class, you can find them below:
submitExtrinsic
Future<Uint8List> submitExtrinsic(Uint8List extrinsic)
Submit a fully formatted extrinsic for block inclusion. The type will be changed to Extrinsic later
submitAndWatchExtrinsic
Future<StreamSubscription<ExtrinsicStatus>> submitAndWatchExtrinsic(
Uint8List extrinsic, Function(ExtrinsicStatus) onData)
Submits and subscribe to watch an extrinsic until unsubscribed.
Polkadart API
We have two different ways to interact with the Polkadot or Polkadot based chains, through the Polkadart API and the network-specific APIs that are generated by the Polkadart CLI.
Chain API
The Chain API is mainly used to get information needed to build and sign transactions. This API is available through the ChainApi class from the polkadart package.