Logo
RPC Assistant

Enjin RPC: Endpoints, Chain Settings, and Developer Workflow

摘要

Enjin runs two Substrate-based chains: the Enjin Matrix Chain (application layer for NFTs and tokens) and the Enjin Relay Chain (consensus and security). Both use Substrate RPC (not EVM JSON-RPC), so developers need to use Polkadot.js or raw WebSocket/HTTPS calls. This article covers public and private RPC endpoints, chain settings, common RPC methods, and how to choose infrastructure for production dApps.

Enjin RPC Decision Checklist

Before integrating Enjin RPC endpoints, consider these criteria:

CriterionWhat to checkWhy it matters
Chain typeMatrix Chain (application) vs Relay Chain (consensus)Each chain has separate endpoints and RPC methods. Use Matrix Chain for NFT and token operations.
ProtocolSubstrate RPC (not EVM)You cannot use eth_* methods. Use Polkadot.js or raw Substrate JSON-RPC.
Data retentionArchive vs full vs prunedArchive nodes store full history; required for historical queries.
Endpoint typePublic vs private vs dedicatedPublic endpoints have rate limits; private/dedicated offer higher throughput and reliability.
Throughput needsRequests per second (RPS)Estimate peak load. Shared plans may throttle; dedicated nodes provide consistent performance.
WebSocket supportWSS for real-time subscriptionsRequired for event listening (e.g., new blocks, token transfers).
Geographic latencyNode location relative to your usersLower latency improves dApp responsiveness.
Provider reputationUptime history, support, documentationCheck independent reviews and provider SLAs.

What Is Enjin RPC?

Enjin is a blockchain ecosystem focused on NFTs and gaming, built on Substrate as a Polkadot parachain. It consists of two chains:

  • Enjin Matrix Chain: The application layer where NFTs, tokens, and smart contracts live. Most dApp interactions happen here.
  • Enjin Relay Chain: The consensus and security layer, inherited from Polkadot. Developers rarely interact with it directly, but it provides finality and cross-chain communication.

Both chains expose RPC endpoints using the Substrate JSON-RPC protocol. This is different from Ethereum's JSON-RPC: there are no eth_* methods. Instead, you use system_*, chain_*, state_*, and custom pallet methods.

Enjin RPC Endpoints

To interact with the Enjin network, you need an RPC endpoint. Options include:

  • Public endpoints: Free but rate-limited, suitable for testing and low-traffic apps.
  • Private endpoints: Provided by infrastructure services like OnFinality, offering higher rate limits and dedicated support.
  • Dedicated nodes: Full control over a node instance, best for production workloads with high throughput.

Example Endpoints (for illustration)

ChainHTTPSWSS
Matrix Chainhttps://enjin-matrix-rpc.example.comwss://enjin-matrix-rpc.example.com
Relay Chainhttps://enjin-relay-rpc.example.comwss://enjin-relay-rpc.example.com

Note: Replace with actual endpoints from your provider. OnFinality offers Enjin RPC endpoints as part of its supported networks.

Connecting to Enjin RPC

Using Polkadot.js

Polkadot.js is the standard library for interacting with Substrate-based chains.

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

async function main() {
  const wsProvider = new WsProvider('wss://enjin-matrix-rpc.example.com');
  const api = await ApiPromise.create({ provider: wsProvider });

  // Get chain info
  const chain = await api.rpc.system.chain();
  const version = await api.rpc.system.version();
  console.log(`Connected to ${chain} v${version}`);

  // Get latest block hash
  const lastHash = await api.rpc.chain.getBlockHash();
  console.log(`Latest block hash: ${lastHash}`);
}

main().catch(console.error);

Using curl (HTTPS)

curl -s -X POST https://enjin-matrix-rpc.example.com \
  -H 'Content-Type: application/json' \
  -d '{"id":1,"jsonrpc":"2.0","method":"chain_getBlockHash","params":[0]}'

Using WebSocket (raw)

wscat -c wss://enjin-matrix-rpc.example.com
> {"id":1,"jsonrpc":"2.0","method":"chain_getBlockHash","params":[0]}

Common RPC Methods

Enjin exposes standard Substrate RPC methods plus custom pallet methods for NFT operations.

System Methods

  • system_chain – Returns the chain name.
  • system_version – Returns the node version.
  • system_health – Returns node health (peers, syncing status).

Chain Methods

  • chain_getBlock – Returns block by hash or number.
  • chain_getBlockHash – Returns block hash by number.
  • chain_getHeader – Returns block header.
  • chain_subscribeNewHeads – Subscribe to new block headers.

State Methods

  • state_getStorage – Returns storage value for a given key.
  • state_getMetadata – Returns runtime metadata.
  • state_queryStorage – Query storage at a specific block.

NFT Methods (Enjin-specific)

Enjin's Multi-Token standard is built into the runtime. Common operations include:

  • nft.balanceOf(account, tokenId) – Get token balance.
  • nft.totalSupply(tokenId) – Get total supply.
  • nft.ownerOf(tokenId) – Get token owner.

Note: Exact method names depend on the runtime version. Check the Enjin documentation for the latest pallet details.

Choosing an RPC Provider

When selecting an RPC provider for Enjin, consider:

  • Supported chains: Ensure the provider offers both Matrix Chain and Relay Chain endpoints.
  • Rate limits: Public endpoints often limit requests per second. For production, use a private or dedicated node.
  • WebSocket support: Required for real-time features like event subscriptions.
  • Geographic distribution: Providers with multiple regions reduce latency.
  • Archive data: If you need historical state, choose an archive node provider.

OnFinality provides Enjin RPC endpoints with flexible plans, including shared and dedicated options. See RPC pricing and supported networks for details.

Common Pitfalls and Troubleshooting

1. Using EVM Methods

Enjin is not EVM-compatible. Calling eth_blockNumber will fail. Always use Substrate methods.

2. Rate Limiting

Public endpoints may throttle high-frequency requests. If you see HTTP 429 errors, upgrade to a private endpoint or implement client-side backoff.

3. WebSocket Disconnections

WebSocket connections can drop due to network issues or server load. Implement reconnection logic in your client.

4. Block Finality

Enjin Relay Chain provides finality after a few blocks. For irreversible transactions, wait for finalization before acting.

5. Data Retention

Full nodes prune historical state. For queries on past blocks, use an archive node or an indexer like the Enjin Platform.

Key Takeaways

  • Enjin uses Substrate RPC, not EVM JSON-RPC. Use Polkadot.js or raw Substrate calls.
  • Two chains: Matrix Chain (application) and Relay Chain (consensus). Most interactions are with Matrix Chain.
  • Public endpoints are fine for development; production apps need private or dedicated infrastructure.
  • OnFinality offers Enjin RPC endpoints with shared and dedicated options. Check supported networks for availability.
  • Always test with a small workload before scaling.

Frequently Asked Questions

Q: Can I use MetaMask with Enjin? A: No, Enjin is not EVM-compatible. Use Polkadot.js or a Substrate wallet.

Q: What is the difference between Matrix Chain and Relay Chain? A: Matrix Chain handles application logic (NFTs, tokens). Relay Chain provides consensus and security. Most dApps interact with Matrix Chain.

Q: How do I get ENJ tokens for gas? A: ENJ is the native token on the Matrix Chain. You can acquire it from exchanges or faucets (for testnets).

Q: Does Enjin support WebSocket subscriptions? A: Yes, both chains support WSS for real-time updates.

Q: Where can I find the latest Enjin RPC methods? A: Refer to the Enjin documentation and the runtime metadata via state_getMetadata.

RPC 知识库

相关 RPC 内容

Blockchain Infrastructure

What Are Dedicated Nodes and When Should You Use Them?

Dedicated nodes are blockchain nodes provisioned exclusively for a single user or project, offering isolated compute, storage, and bandwidth. They eli...

Network Rpc

Bifrost RPC Endpoints: Chain Settings, Provider Options, and Developer Setup

Bifrost is an EVM-compatible Layer 1 blockchain with a staking liquidity protocol. This article covers Bifrost mainnet and testnet RPC endpoints, chai...

Rpc Provider Selection

How to Evaluate Alchemy as an RPC Provider for Your Web3 Project

This article provides a structured framework for evaluating Alchemy as an RPC provider, covering key criteria such as feature set, pricing model, perf...

Network Rpc

什么是Polkadot节点,如何运行一个?

# 什么是Polkadot节点,如何运行一个? Polkadot节点是一种软件客户端,它连接到Polkadot网络,同步区块链数据,并提供RPC端点用于查询状态、提交交易以及与平行链交互。运行自己的节点可以让你直接、无需信任地访问网络,但这需要大量的硬件、存储和持续的维护。对于许多开发者和dApp来...

Network Rpc

关于BSC RPC端点,我需要了解什么?

# 关于BSC RPC端点,我需要了解什么? BSC RPC端点至关重要,因为Web3应用依赖稳定的端点访问来进行读取、交易、仪表盘和后端工作流。正确的设置应匹配你的工作负载,支持所需的网络和测试网,使限制可见,并在共享RPC不再足够时提供扩展路径。 对于BNB智能链构建者、基础设施负责人、DeFi...

Rpc Provider Selection

How to Choose an Avalanche RPC Provider for Production dApps

Selecting the right Avalanche RPC provider is critical for dApp performance, reliability, and cost. This article covers the key evaluation criteria—la...

永远不用担心基础设施

OnFinality 消除了 DevOps 的繁重工作,让您能够更聪明、更快地构建。

开始