Import Mitum

The SDK provides two main classes, which are both available as named exports:

Mitum: The main SDK class for core logic. Use this to create operations, generate keys, and communicate directly with a Mitum node (via its API Endpoint).

BrowserProvider: The EIP-1193 standard provider. Use this in dApps to connect to browser wallets like Fact Wallet (window.imfact) for account requests and transaction signing.

CommonJS

Use the CommonJS (CJS) bundle via require. This bundle uses Node.js native modules (like the built-in Buffer) for optimal performance.

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

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

ESM (ES Module)

Use the ES Module (ESM) bundle via import. This bundle includes necessary browser polyfills (like Buffer) automatically. You no longer need to configure polyfills in your config files or perform manual fixes.

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

// Initialize the Provider by wrapping the wallet's injected object
const provider = new BrowserProvider(window.imfact);

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

Typescript

To develop with TypeScript, import the Mitum from index.ts as follow:

Last updated