Quick Start
Japan Open Chainへの接続方法を説明します。
ネットワーク情報
- Mainnet
- Testnet
| 項目 | 値 |
|---|---|
| Network Name | Japan Open Chain Mainnet |
| Chain ID | 81 |
| Currency Symbol | JOC |
| RPC URL | https://rpc-1.japanopenchain.org:8545 |
| Block Explorer | https://explorer.japanopenchain.org |
| 項目 | 値 |
|---|---|
| Network Name | Japan Open Chain Testnet |
| Chain ID | 10081 |
| Currency Symbol | JOCT |
| RPC URL | https://rpc-1.testnet.japanopenchain.org:8545 |
| Block Explorer | https://explorer.testnet.japanopenchain.org |
| Faucet | テストネットFaucet |
ウォレット追加ボタンの実装
ユーザーがワンクリックでMetaMaskにJapan Open Chainを追加できるボタンを実装するには、以下のコードを使用してください。wallet_addEthereumChainメソッドを呼び出すと、MetaMaskがネットワーク追加の確認ダイアログを表示します。
- Mainnet
- Testnet
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x51', // 81
chainName: 'Japan Open Chain Mainnet',
nativeCurrency: { name: 'JOC', symbol: 'JOC', decimals: 18 },
rpcUrls: ['https://rpc-1.japanopenchain.org:8545'],
blockExplorerUrls: ['https://explorer.japanopenchain.org']
}]
});
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x2761', // 10081
chainName: 'Japan Open Chain Testnet',
nativeCurrency: { name: 'JOCT', symbol: 'JOCT', decimals: 18 },
rpcUrls: ['https://rpc-1.testnet.japanopenchain.org:8545'],
blockExplorerUrls: ['https://explorer.testnet.japanopenchain.org']
}]
});
コードで接続
ethers.js (v6)
import { ethers } from 'ethers';
// Mainnet
const provider = new ethers.JsonRpcProvider('https://rpc-1.japanopenchain.org:8545');
// 接続確認
const blockNumber = await provider.getBlockNumber();
console.log('Current block:', blockNumber);
// Chain ID確認
const network = await provider.getNetwork();
console.log('Chain ID:', network.chainId); // 81n
web3.js
import Web3 from 'web3';
const web3 = new Web3('https://rpc-1.japanopenchain.org:8545');
// 接続確認
const blockNumber = await web3.eth.getBlockNumber();
console.log('Current block:', blockNumber);
viem
import { createPublicClient, http } from 'viem';
import { japanOpenChain } from 'viem/chains';
const client = createPublicClient({
chain: japanOpenChain,
transport: http(),
});
const blockNumber = await client.getBlockNumber();
console.log('Current block:', blockNumber);
次のステップ
- RPC Endpoints詳細 - 全エンドポイント一覧
- Mainnetへの接続手順 - ノードの立て方
- テストネットFaucet - テスト用トークンの取得
- Block Explorer - トランザクション確認