Skip to Content
MCN Blockchain

SDKs and libraries

Connect ethers to MCN, read finalized state and handle native amounts.

MCN uses Ethereum account and transaction formats. Configure the RPC URL and chain ID explicitly in your application. The examples here use ethers v6 and Node.js 24; they do not require a separate MCN SDK.

Install and read Mainnet

Create read.mjs in the new directory with the following contents. The example reads the public deposit-contract address; no private key or transfer is involved.

mkdir mcn-app
cd mcn-app
npm init -y
npm install --save-exact ethers@6.17.0
read.mjs
import { JsonRpcProvider, formatEther } from "ethers";

const rpc = new JsonRpcProvider("https://rpc.mcnblockchain.com");
try {
  const network = await rpc.getNetwork();
  if (network.chainId !== 2325n) throw new Error("Wrong network");
  const genesis = await rpc.getBlock(0);
  if (genesis?.hash !== "0xaed6cbc96425678993f2beedef93ab9f8dabab801da7858ac54b8f35f3e5909e") {
    throw new Error("Wrong genesis");
  }
  const block = await rpc.getBlock("finalized");
  if (!block) throw new Error("Finalized block unavailable");
  const address = "0x00000000219ab540356cbb839cbe05303d7705fa";
  const balance = await rpc.getBalance(address, block.number);
  console.log({ finalizedHeight: block.number, balanceMCN: formatEther(balance) });
} finally {
  rpc.destroy();
}
node read.mjs

Native units

import { parseEther, formatEther } from "ethers";

const value = parseEther("0.1"); // 100000000000000000n
console.log(formatEther(value)); // "0.1" MCN

The helper names refer to 18-decimal units. On the configured MCN network the amounts represent MCN. Accept decimal amounts as strings and serialize bigint values as strings in JSON.

Choose the next example

Keep signing separate from reads. In browser applications, use the user's wallet and request the MCN network. For servers, keep keys in your custody system. Third-party libraries must still be configured for MCN; a default provider configured for Ethereum will read Ethereum instead.

ethers documentation

On this page