-
Notifications
You must be signed in to change notification settings - Fork 78
Add runtime API calls guide with SDK examples #1325
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: staging/product-ia
Are you sure you want to change the base?
Conversation
Add comprehensive guide for calling runtime APIs using PAPI, Polkadot.js, Dedot, Python Substrate Interface, and Subxt. Examples demonstrate AccountNonceApi and Metadata runtime API calls with complete, tested code snippets for each SDK.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good. We agreed on using paseo asset hub for the chain interaction tutorials. Could you please refactor this guide where needed?
- Update all examples to use Paseo Asset Hub endpoint (wss://asset-hub-paseo.dotters.network) - Change PAPI types generation to use polkadotTestNet descriptor - Update console output messages to show "Connected to Polkadot Hub TestNet" - Update HTML output snippets to reflect testnet connection - Update Python output to show asset-hub-paseo spec name
Updated. |
nhussein11
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@brunopgalvao approved, left some minor comments. Many thanks!
| - **[Python Substrate Interface](/reference/tools/py-substrate-interface/){target=\_blank}** - Python library for Substrate chains | ||
| - **[Subxt](/reference/tools/subxt/){target=\_blank}** - Rust library with compile-time type safety | ||
|
|
||
| Select your preferred SDK below to see complete, runnable examples that query Polkadot Hub TestNet (Paseo Asset Hub) for account nonces and metadata information. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Select your preferred SDK below to see complete, runnable examples that query Polkadot Hub TestNet (Paseo Asset Hub) for account nonces and metadata information. | |
| Select your preferred SDK below to see complete, runnable examples that query Polkadot Hub TestNet for account nonces and metadata information. |
| import { withPolkadotSdkCompat } from 'polkadot-api/polkadot-sdk-compat'; | ||
| import { polkadotTestNet } from '@polkadot-api/descriptors'; | ||
|
|
||
| const ASSET_HUB_RPC = 'INSERT_WS_ENDPOINT'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should be "POLKADOT_TESTNET_RPC"
| @@ -0,0 +1,34 @@ | |||
| import { ApiPromise, WsProvider } from '@polkadot/api'; | |||
|
|
|||
| const ASSET_HUB_RPC = 'INSERT_WS_ENDPOINT'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
|
|
||
|
|
||
| def main(): | ||
| # Connect to Polkadot Hub TestNet (Paseo Asset Hub) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| # Connect to Polkadot Hub TestNet (Paseo Asset Hub) | |
| # Connect to Polkadot Hub TestNet |
| @@ -0,0 +1,33 @@ | |||
| from substrateinterface import SubstrateInterface | |||
|
|
|||
| ASSET_HUB_RPC = "INSERT_WS_ENDPOINT" | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| 3. Download the Polkadot Hub TestNet metadata: | ||
|
|
||
| ```bash | ||
| subxt metadata --url INSERT_WS_ENDPOINT -o asset_hub_metadata.scale |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally this should be something like: polkadot_testnet_metadata.scale but I failed to do that in other tests, any idea what might be the reason?
| subxt metadata --url INSERT_WS_ENDPOINT -o asset_hub_metadata.scale | ||
| ``` | ||
|
|
||
| Ensure to replace `INSERT_WS_ENDPOINT` with the proper WebSocket endpoint, such as `wss://asset-hub-paseo.dotters.network` for Polkadot Hub TestNet (Paseo Asset Hub). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| Ensure to replace `INSERT_WS_ENDPOINT` with the proper WebSocket endpoint, such as `wss://asset-hub-paseo.dotters.network` for Polkadot Hub TestNet (Paseo Asset Hub). | |
| Ensure to replace `INSERT_WS_ENDPOINT` with the proper WebSocket endpoint, such as `wss://asset-hub-paseo.dotters.network` for Polkadot Hub TestNet. |
| import { DedotClient, WsProvider } from 'dedot'; | ||
| import type { PolkadotAssetHubApi } from '@dedot/chaintypes'; | ||
|
|
||
| const ASSET_HUB_RPC = 'INSERT_WS_ENDPOINT'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same here
| const ADDRESS = 'INSERT_ADDRESS'; | ||
|
|
||
| async function main() { | ||
| // Initialize provider and client with Asset Hub types |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| // Initialize provider and client with Asset Hub types | |
| // Initialize provider and client with Polkadot TestNet types |
📝 Description
Add comprehensive guide for calling runtime APIs using PAPI, Polkadot.js, Dedot, Python Substrate Interface, and Subxt.
Examples demonstrate AccountNonceApi and Metadata runtime API calls with complete, tested code snippets for each SDK.
🔍 Review Preference
Choose one:
🤖 AI-Ready Docs
If content changed, regenerate AI files:
python3 scripts/generate_llms.py✅ Checklist