DEV Community

OnFinality
OnFinality

Posted on • Originally published at onfinality.io

Asset Hub Polkadot: RPC Endpoints, Assets, and Smart Contracts

Quick Recommendation: How to Connect to Asset Hub Polkadot

If you are building an application that needs to read balances, submit transactions, or query asset metadata on Asset Hub Polkadot, the fastest path is to use a managed RPC endpoint. You can start with the public endpoint wss://asset-hub-polkadot-rpc.polkadot.io for testing, but for production workloads you should evaluate a dedicated or high-tier public RPC provider that offers consistent performance and reliability. OnFinality provides RPC endpoints for Asset Hub Polkadot and other Polkadot system chains, with options ranging from free public endpoints to dedicated nodes. Check the supported networks list to confirm availability and see RPC pricing for rate limits and plan details.

For most developers, the decision comes down to:

  • Prototyping or low-traffic apps: Public endpoints are fine, but be aware of rate limits and potential downtime.
  • Production dApps: Use a managed provider with multiple endpoints, WebSocket support, and failover capabilities.
  • High-throughput or archival needs: Consider a dedicated node to avoid shared resource contention.

What Is Asset Hub Polkadot?

Asset Hub Polkadot (formerly known as Statemint) is a system parachain on the Polkadot network. It is designed to provide core functionality for issuing and managing on-chain assets, including fungible tokens, non-fungible tokens (NFTs), and, more recently, smart contracts. While the relay chain (Polkadot) handles security and consensus, Asset Hub focuses on asset logic—minting, burning, transferring, and metadata—efficiently and cost-effectively.

Key features include:

  • Native asset creation: Create and manage tokens with configurable permissions and metadata.
  • NFT support: Mint and transfer non-fungible assets.
  • Smart contracts: Deploy and interact with smart contracts using the pallet-revive (formerly pallet-contracts).
  • XCM integration: Move assets across parachains using cross-consensus messaging.
  • Low fees: Transactions on Asset Hub are typically cheaper than on the relay chain.

After the runtime upgrade to version 2.0.0, Asset Hub also hosts balances, staking, and governance features that previously lived on the relay chain, making it the primary network for everyday Polkadot activity.

Why Use Asset Hub Polkadot?

Asset Hub provides a standardized framework for asset management that is native to the Polkadot ecosystem. Here are the main reasons developers and projects choose it:

  • Cost efficiency: Creating and transferring assets on Asset Hub is significantly cheaper than on the relay chain.
  • Interoperability: Assets issued on Asset Hub can be transferred to other parachains via XCM, enabling cross-chain applications.
  • Smart contract support: With the addition of smart contract capabilities, developers can build DeFi, gaming, and other applications directly on Asset Hub.
  • Security: As a system parachain, Asset Hub benefits from the same shared security as the relay chain.

Chain Settings at a Glance

When connecting your application to Asset Hub Polkadot, you need the correct network configuration. Here are the essential details:

Setting Value
Network Name Asset Hub Polkadot
Chain ID 1000 (para ID)
RPC Endpoint (HTTPS) https://asset-hub-polkadot-rpc.polkadot.io
RPC Endpoint (WSS) wss://asset-hub-polkadot-rpc.polkadot.io
Token Symbol DOT
Token Decimals 10
Block Explorer Subscan

Note: These are public endpoints. For production, consider using a managed provider like OnFinality, which offers dedicated endpoints with better reliability. Check the Polkadot network page for OnFinality's specific endpoints.

Connecting to Asset Hub Polkadot with RPC

To interact with Asset Hub Polkadot, you can use JSON-RPC calls. Here's a simple curl example to get the latest block number:

curl -H "Content-Type: application/json" \
  -d '{"id":1, "jsonrpc":"2.0", "method":"chain_getHeader", "params":[]}' \
  https://asset-hub-polkadot-rpc.polkadot.io
Enter fullscreen mode Exit fullscreen mode

For WebSocket subscriptions (e.g., listening to new blocks), you can use a tool like wscat or a JavaScript library. Here's an example using the ws package in Node.js:

const WebSocket = require('ws');

const ws = new WebSocket('wss://asset-hub-polkadot-rpc.polkadot.io');

ws.on('open', function open() {
  ws.send(JSON.stringify({
    id: 1,
    jsonrpc: '2.0',
    method: 'chain_subscribeNewHeads',
    params: []
  }));
});

ws.on('message', function incoming(data) {
  console.log(data.toString());
});
Enter fullscreen mode Exit fullscreen mode

For higher-level interaction, you can use the Polkadot.js API. Here's an example of querying the balance of an account:

const { ApiPromise, WsProvider } = require('@polkadot/api');

async function main() {
  const provider = new WsProvider('wss://asset-hub-polkadot-rpc.polkadot.io');
  const api = await ApiPromise.create({ provider });

  const address = 'YOUR_ADDRESS_HERE';
  const { data: { free } } = await api.query.system.account(address);
  console.log('Free balance:', free.toString());

  await api.disconnect();
}

main().catch(console.error);
Enter fullscreen mode Exit fullscreen mode

Managing Assets on Asset Hub Polkadot

Asset Hub supports both native and foreign assets. Native assets are issued directly on the parachain, while foreign assets are representations of assets from other chains, managed via XCM.

Creating a Fungible Asset

To create a new fungible asset, you need to submit an extrinsic using the assets pallet. Here's an example using Polkadot.js:

const { ApiPromise, WsProvider, Keyring } = require('@polkadot/api');

async function createAsset() {
  const provider = new WsProvider('wss://asset-hub-polkadot-rpc.polkadot.io');
  const api = await ApiPromise.create({ provider });

  const keyring = new Keyring({ type: 'sr25519' });
  const alice = keyring.addFromUri('//Alice');

  const tx = api.tx.assets.create(
    1, // asset ID
    alice.address, // admin
    1000000, // min balance
    100 // decimals
  );

  const hash = await tx.signAndSend(alice);
  console.log('Transaction hash:', hash.toHex());

  await api.disconnect();
}

createAsset().catch(console.error);
Enter fullscreen mode Exit fullscreen mode

Transferring Assets

Transferring a fungible asset is straightforward:

const tx = api.tx.assets.transfer(
  1, // asset ID
  'RECIPIENT_ADDRESS',
  1000 // amount
);
Enter fullscreen mode Exit fullscreen mode

NFTs

Asset Hub also supports NFTs through the uniques and nfts pallets. You can mint, transfer, and manage NFTs with similar extrinsics.

Smart Contracts on Asset Hub Polkadot

With the introduction of smart contract support, Asset Hub allows developers to deploy Wasm-based smart contracts using the pallet-revive. This opens up possibilities for building DeFi, gaming, and other applications directly on the network.

To deploy a contract, you typically use the polkadot.js UI or a development framework like @polkadot/contracts. The process involves:

  1. Compile your contract to Wasm.
  2. Upload the code to the chain.
  3. Instantiate the contract with initial parameters.

Here's a simplified example of uploading contract code using Polkadot.js:

const code = fs.readFileSync('my_contract.wasm');
const tx = api.tx.contracts.upload(code, null, null);
Enter fullscreen mode Exit fullscreen mode

Note that smart contract support is relatively new, so check the latest runtime documentation for exact APIs and requirements.

Common Pitfalls and Troubleshooting

When working with Asset Hub Polkadot, developers often encounter these issues:

  • Incorrect endpoint: Using a relay chain endpoint instead of the Asset Hub endpoint. Make sure you are connecting to asset-hub-polkadot.
  • Rate limiting: Public endpoints may throttle requests. If you hit rate limits, consider upgrading to a paid plan or dedicated node.
  • WebSocket disconnects: For long-running subscriptions, ensure your client handles reconnection logic.
  • Asset ID conflicts: When creating assets, choose a unique asset ID to avoid collisions.
  • Existential deposit (ED): Accounts must maintain a minimum balance (ED) to remain active. If an account drops below ED, it may be reaped.

Monitoring and Production Readiness

For production applications, you should monitor your RPC endpoints to ensure they are healthy. Here's a simple health check script using curl:

curl -s -X POST https://asset-hub-polkadot-rpc.polkadot.io \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"system_health","params":[],"id":1}'
Enter fullscreen mode Exit fullscreen mode

A healthy response will include "isSyncing": false and "peers": >0. If you are using OnFinality, you can also set up uptime monitoring and alerts through your dashboard.

Key Takeaways

  • Asset Hub Polkadot is the system parachain for asset management, NFTs, and smart contracts in the Polkadot ecosystem.
  • It offers low fees, XCM interoperability, and shared security with the relay chain.
  • For development, use the public RPC endpoints; for production, consider a managed provider like OnFinality for reliability and support.
  • Common operations include creating and transferring assets, minting NFTs, and deploying smart contracts.
  • Always monitor your endpoints and handle rate limits and reconnections gracefully.

Frequently Asked Questions

What is the difference between Asset Hub Polkadot and the Polkadot relay chain?

The relay chain provides security and consensus, while Asset Hub handles asset logic and smart contracts. After the migration, Asset Hub also hosts balances, staking, and governance.

Can I deploy ERC-20 style tokens on Asset Hub Polkadot?

Yes, you can create fungible assets that behave similarly to ERC-20 tokens, but they are native to the Substrate runtime and use the assets pallet.

How do I get DOT for transaction fees on Asset Hub?

You need DOT to pay for transaction fees. You can acquire DOT from exchanges or faucets, and then transfer it to your Asset Hub account via XCM or a direct transfer.

Is Asset Hub Polkadot compatible with Ethereum tools?

No, Asset Hub is a Substrate-based chain, so it uses Polkadot.js and Substrate APIs. However, with smart contract support, you can use Wasm-based contracts, which are different from EVM contracts.

Where can I find the official documentation for Asset Hub?

Refer to the Polkadot Developer Docs and the Polkadot Wiki for detailed information.

How do I choose between public and dedicated RPC endpoints?

For production apps with high traffic, dedicated endpoints offer better performance and reliability. Evaluate your workload, rate limits, and budget. OnFinality offers flexible RPC pricing and dedicated node options.

Related resources

Originally published at OnFinality.

Top comments (0)