@mitumjs/mitumjs
v2.1.11
Published
framework for mitum network
Downloads
52
Readme
Abstraction
mitum.js is the framework of the mitum blockchain written in the typescript language and provided in esm, cjs builded form.
The Mitum blockchain operates on a multi-sig account basis. However, for user convenience, single-sig is prioritized.
Name the method so that it can be called intuitively from the user's perspective.
For consistency, method names use camel notation.
To eliminate confusion about the singular/plural representation of method names, we unify the singular notation.
The exception is when there are more than one method with the same function and the return value is singular and plural.
Install
- Both commonjs (cjs) and ES2020 (esm) are available.
- For ESM, the runtime environment is detected automatically: XMLHttpRequests are supported in the browser, and HTTP requests are supported in Node.js. This project has been developed in the following environments:
- node version >= 16
- npm version >= 8
Check your node, npm version
$ node --version
$ npm --version
You can install this package locally using this command:
$ npm i @mitumjs/mitumjs
Usage
Use the cjs module or esm module as described below.
This is an example of how to 'require' a CJS module.
Enter an RPC-URL to communicate with the node.
You can omit the RPC-URL if you don't need to communicate with the node (for example, to generate a simple key pair or an operation for signing).
You can set the RPC-URL as shown below.
// test.cjs
const { Mitum } = require("@mitumjs/mitumjs");
const mitum = new Mitum("http://127.0.0.1:54320");
const keys = mitum.account.etherKeys(2);
console.log(keys);
- This is an example of how to 'import' a ESM module.
// test.mjs
import Mitum from '@mitumjs/mitumjs';
const mitum = new Mitum("http://127.0.0.1:54320");
const keys = mitum.account.etherKeys(2);
console.log(keys);
⚠️ Note
If you want to specify whether to use CommonJS or ESM in your package, add the following entry in the package.json : "type": "commonjs" or "type": "module". Also, consider explicitly specifying the file extension as .cjs or .mjs rather than .js in the execution file.
Functions
Important note about using functions :
The operation of Mitum is a transaction ‘message’.
Thus if function returns an operation object, remember that you haven't sent an operation to the network.
Any operation returned by the function is a raw transaction object, which requires additional signing.
Signed operation object must be sent to the network via the operation.send() function. (This is similar to web3.js and ethers.js).
Mitum JS SDK user guide
Futher etailed information on how to use each function and the contract model can be found at the link below.
Be sure to check it out before using SDK.
📖 Mitum JS SDK user guide