Import Mitum

CommonJS

To use mitumJS package with CommonJS (cjs), import the package using require as follows:

const { Mitum } = require("@mitumjs/mitumjs");
// You can set the RPC-URL as shown below.
const rpcurl = "http://127.0.0.1:54320"; 
// If you want to use testnet, use below line
//const rpcurl = "https://testnet.imfact.im"; 
const mitum = new Mitum(rpcurl);

If you want to explicitly specify the use of CommonJS (cjs), you can name your file with the .cjs extension.

ESM (ES Module)

To use mitumJS package with ESM (ES Module), import the package using importe as follows:

import { Mitum }  from "@mitumjs/mitumjs";
// You can set the RPC-URL as shown below.
const rpcurl = "http://127.0.0.1:54320";
// If you want to use testnet, use below line.
//const rpcurl = "https://testnet.imfact.im"; 
const mitum = new Mitum(rpcurl);

If you want to explicitly specify the use of ESM, you can name your file with the .mjs extension.

Typescript

To develop with TypeScript, import the Mitum source code from mitumJS and use it as follows:

// Make sure to adjust the path to the Mitum source code within your project
import { Mitum } from "../src/index";

// You can set the RPC-URL as shown below.
const rpcurl = "http://127.0.0.1:54320";
// If you want to use testnet, use below line
//const rpcurl = "https://testnet.imfact.im"; 
const mitum = new Mitum(rpcurl);

Last updated