docs ⦿ dedot 🧑‍💻
TypinkXTelegramGithub
dedot 🧑‍💻
dedot 🧑‍💻
  • Welcome to Dedot
  • Why Dedot?
  • Getting started
    • Installation
    • Connect to network
    • @polkadot/api -> dedot
    • Packages structure
  • Clients & Providers
    • Providers
    • Clients
  • Client API
    • ChainApi
    • Constants
    • Runtime APIs
    • Storage Queries
    • Transactions
    • Events
    • Errors
  • ink! Smart Contracts
    • Introduction
    • Generate Types & APIs
    • Deploy contracts
    • Queries
    • Transactions
    • Events
    • Handle errors
  • CLI
  • Keyring & Signer
  • Runtime upgrades
  • Type system
  • Utilities
    • HexString
    • Uint8Array (U8a)
    • String
    • Hash functions
    • Address
    • BigInt & number
    • Balances
    • Merkleized Metadata
  • Help & FAQ
    • Tutorials
      • Develop ink! dApp using Typink
    • Built with Dedot
    • Forum Posts
    • Telegram
    • Github
    • API Reference
Powered by GitBook
On this page
  • Metadata >= v15
  • Metadata v14

Was this helpful?

Edit on GitHub
  1. Client API

Runtime APIs

PreviousConstantsNextStorage Queries

Last updated 8 months ago

Was this helpful?

Metadata >= v15

The latest stable Metadata v15 now includes all the runtime apis type information. For chains that are supported Metadata V15, we can now execute all available runtime apis with syntax client.call.<runtimeApi>.<methodName>, those apis are exposed in ChainApi interface. E.g: Runtime Apis for Polkadot network is defined , similarly for other networks as well.

// Get account nonce
const nonce = await client.call.accountNonceApi.accountNonce(<address>);

// Query transaction payment info
const tx = client.tx.balances.transferKeepAlive(<address>, 2_000_000_000_000n);
const queryInfo = await client.call.transactionPaymentApi.queryInfo(tx.toU8a(), tx.length);

// Get runtime version
const runtimeVersion = await client.call.core.version();

Metadata v14

For chains that only support Metadata v14, we need to bring in the Runtime Api definitions when initializing the DedotClient instance to encode & decode the calls. You can find all supported Runtime Api definitions in package.

import { RuntimeApis } from 'dedot/runtime-specs';

const client = await DedotClient.new({ 
  provider: new WsProvider('wss://rpc.mynetwork.com'), 
  runtimeApis: RuntimeApis 
});

// Or bring in only the Runtime Api definition that you want to interact with
import { AccountNonceApi } from 'dedot/runtime-specs';
const client = await DedotClient.new({ 
  provider: new WsProvider('wss://rpc.mynetwork.com'), 
  runtimeApis: { AccountNonceApi } 
});

// Get account nonce
const nonce = await client.call.accountNonceApi.accountNonce(<address>);

You absolutely can define your own Runtime Api definition if you don't find it in the .

here
dedot/runtime-specs
supported list