Quick Decision: How to Connect to Statemine
Before diving into the details, here's a quick guide to help you decide how to connect to Statemine. If you're building a production application, you need a reliable RPC endpoint. You have two main options:
- Use a public endpoint for testing and development. OnFinality provides a public endpoint for Statemine that you can use for quick experiments.
- Use a dedicated node for production workloads. If your application requires high throughput, archive data, or WebSocket subscriptions, a dedicated node gives you the performance and reliability you need.
For most production use cases, we recommend using a managed RPC service like OnFinality to avoid the operational overhead of running your own node. Check the supported RPC networks page to see if Statemine is available and review RPC pricing for cost details.
What Is Statemine?
Statemine is a common good parachain on the Kusama network. It serves as a hub for assets, NFTs, and other token standards. Unlike general-purpose smart contract chains, Statemine is optimized for asset management, offering low transaction fees and fast block times. It is the Kusama counterpart to Statemint on Polkadot.
Statemine uses the Substrate framework and supports the Assets pallet and the Uniques pallet. This allows users to create and manage fungible assets and non-fungible tokens (NFTs) directly on the chain without deploying smart contracts. The chain is designed to be lightweight and efficient, making it ideal for use cases like token issuance, NFT minting, and asset transfers.
Chain Settings at a Glance
Here are the key chain settings for Statemine that you'll need when configuring your RPC connection:
| Setting | Value |
|---|---|
| Chain ID | 1000 |
| Network Name | Statemine |
| Native Token | KSM |
| Block Time | 6 seconds |
| Consensus | PoS (NPoS) |
| Explorer | Kusama Explorer |
| RPC Endpoint |
wss://statemine-rpc.publicnode.com (example) |
Note: The RPC endpoint above is a placeholder. For the official OnFinality public endpoint, refer to the Statemine network page.
How to Connect to Statemine
To connect to Statemine, you can use a WebSocket or HTTPS endpoint. Here's an example using the Polkadot.js API:
const { ApiPromise, WsProvider } = require('@polkadot/api');
async function main() {
const wsProvider = new WsProvider('wss://statemine-rpc.publicnode.com');
const api = await ApiPromise.create({ provider: wsProvider });
await api.isReady;
console.log('Connected to Statemine');
// Your code here
}
main().catch(console.error);
For a simple JSON-RPC call using curl, you can use:
curl -H "Content-Type: application/json" -d '{"id":1, "jsonrpc":"2.0", "method":"chain_getHeader", "params":[]}' https://statemine-rpc.publicnode.com
Remember to replace the endpoint with the actual OnFinality endpoint from the network page.
Using Statemine for Asset and NFT Management
Statemine's primary use case is asset management. You can create assets using the Assets pallet. Here's an example of how to create an asset using the Polkadot.js API:
const { Keyring } = require('@polkadot/keyring');
const { ApiPromise, WsProvider } = require('@polkadot/api');
async function createAsset() {
const wsProvider = new WsProvider('wss://statemine-rpc.publicnode.com');
const api = await ApiPromise.create({ provider: wsProvider });
const keyring = new Keyring({ type: 'sr25519' });
const alice = keyring.addFromUri('//Alice');
const tx = api.tx.assets.create(1, alice.address, 1000000);
const hash = await tx.signAndSend(alice);
console.log('Transaction hash:', hash.toHex());
}
createAsset().catch(console.error);
Similarly, you can mint NFTs using the Uniques pallet. These operations are straightforward and cost-effective on Statemine.
Provider Evaluation Matrix
When choosing an RPC provider for Statemine, consider the following factors:
| Provider | Public Endpoint | Dedicated Node | Archive Data | WebSocket Support | Pricing |
|---|---|---|---|---|---|
| OnFinality | Yes | Yes | Yes | Yes | Transparent |
| Other Providers | Varies | Varies | Varies | Varies | Varies |
OnFinality offers both public and dedicated endpoints, with support for archive data and WebSocket subscriptions. This makes it suitable for a wide range of applications, from simple asset transfers to complex NFT marketplaces. For a detailed comparison, refer to our guide on how to choose an RPC provider.
Common Pitfalls and Debugging
When working with Statemine, you might encounter a few common issues:
- Connection timeouts: If you're using a public endpoint, it may be rate-limited. Consider using a dedicated node for production.
- Incorrect chain ID: Make sure you're using the correct chain ID (1000) when configuring your wallet or application.
- WebSocket disconnections: WebSocket connections can drop if the endpoint is overloaded. Implement reconnection logic in your application.
- Asset creation errors: Ensure you have sufficient KSM balance to cover transaction fees.
If you encounter issues, check the Statemine network page for the latest endpoint information and status.
Build vs. Rent: When to Use a Managed RPC Service
Running your own Statemine node requires significant infrastructure and maintenance. You need to sync the chain, keep the node updated, and handle scaling. For most developers, using a managed RPC service like OnFinality is more cost-effective and reliable. OnFinality handles the infrastructure, so you can focus on building your application.
Consider the following tradeoffs:
| Factor | Self-Hosted | Managed Service |
|---|---|---|
| Initial Setup | High | Low |
| Maintenance | High | Low |
| Scalability | Manual | Automatic |
| Cost | Hardware + Ops | Subscription |
| Reliability | Depends on your setup | High |
If you need a quick start, use a public endpoint. If you need production-grade reliability, consider a dedicated node from OnFinality. Check RPC pricing for cost details.
Key Takeaways
- Statemine is a Kusama parachain for asset and NFT management.
- Use the correct chain ID (1000) and endpoint when connecting.
- For production, use a managed RPC service like OnFinality to avoid operational overhead.
- Always check the official network page for the latest endpoint information.
Frequently Asked Questions
What is Statemine used for?
Statemine is used for creating and managing assets and NFTs on the Kusama network. It provides a low-cost, efficient platform for token issuance and transfer.
How do I get a Statemine RPC endpoint?
You can use a public endpoint from OnFinality or other providers. For production, consider a dedicated node. Visit the Statemine network page for the official endpoint.
What is the difference between Statemine and Statemint?
Statemine is on Kusama, while Statemint is on Polkadot. They serve similar purposes but on different networks.
Can I use WebSocket with Statemine?
Yes, WebSocket is supported. Use wss:// endpoints for real-time subscriptions.
What are the transaction fees on Statemine?
Fees are paid in KSM and are generally low. The exact fee depends on network congestion and transaction complexity.
For more details, explore the supported networks page and find the right infrastructure for your project.
Related resources
Originally published at OnFinality.
Top comments (0)