Overview
In this section we will show you how to interact with network-specific APIs that are generated by the Polkadart CLI. These APIs are specific to the network you are connecting to and provide all the methods available on that network in a type-safe way.
Installation
To have access to the network-specific APIs, you need to install the Polkadart CLI and generate the types for the network you are interested in. If you already did that on the Getting Started section, you can skip this step.
Add the following to your pubspec.yaml
file:
Get the dependencies by running:
Generating the APIs
Now let’s configure Polkadart CLI to generate the types for us, add the following configuration at the end of your pubspec file.
And finally let’s generate the types:
You will see that a folder lib/generated
was created for you and it contains all APIs, types and extrinsics for the networks you specified.
We will provide the same example as the one in the Polkadart API section, but this time using the network-specific APIs.
Example: StateApi
You will get the same output as the Polkadart API example on StateApi section:
Example: SystemApi
You will get the same output as the Polkadart API example on SystemApi section:
Next steps
The following sections will provide more details on the available APIs for polkadot network. The APIs are generated based on a snapshot of the network in the time of writing, please keep in mind that the network may have changed since then.