JSON-RPC ENDPOINTS
POST
eth_chainId
Returns the current chain ID.
{
"jsonrpc": "2.0",
"method": "eth_chainId",
"params": [],
"id": 1
}
POST
eth_blockNumber
Returns the current block number.
{
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
POST
eth_getBalance
Returns the balance of an account.
{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0xAddress", "latest"],
"id": 1
}
POST
eth_sendTransaction
Sends a transaction to the network.
{
"jsonrpc": "2.0",
"method": "eth_sendTransaction",
"params": [{
"from": "0xFrom",
"to": "0xTo",
"value": "0x0",
"data": "0x"
}],
"id": 1
}
QUICK START
WEB3.JS
const Web3 = require('web3');
const web3 = new Web3('https://mainnet.modem.technology');
// Get current block number
const blockNumber = await web3.eth.getBlockNumber();
console.log('Block:', blockNumber);
// Get balance
const balance = await web3.eth.getBalance('0xAddress');
console.log('Balance:', web3.utils.fromWei(balance, 'ether'));
ETHERS.JS
const { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider(
'https://mainnet.modem.technology'
);
// Get current block
const block = await provider.getBlockNumber();
console.log('Block:', block);
// Get balance
const balance = await provider.getBalance('0xAddress');
console.log('Balance:', ethers.formatEther(balance));
METAMASK
// Add MODEM Mainnet to MetaMask
await window.ethereum.request({
method: 'wallet_addEthereumChain',
params: [{
chainId: '0x15893',
chainName: 'MODEM Mainnet',
rpcUrls: ['https://mainnet.modem.technology'],
nativeCurrency: {
name: 'MODEM',
symbol: 'MODEM',
decimals: 18
},
blockExplorerUrls: ['https://explorer.modem.technology']
}]
});