An open-source entry in TopGit's GitHub warehouse: EOSIO/eosjs, 1.4k stars, TypeScript. General purpose library for the EOSIO blockchain.
Snapshot summary built from the project's own GitHub metadata — there's no written TopGit review yet. The page will update automatically when a full review is published.
WHY NO REVIEW YET
TopGit writes full reviews for the most-starred, most-requested repositories. This page is a snapshot until then — see the READ ME tab for the original README in full.
Javascript API for integration with EOSIO-based blockchains using EOSIO RPC API.
Documentation can be found here
Installation
NPM
The official distribution package can be found at npm.
Add dependency to your project
yarn add eosjs
Using with Typescript
In order to get access to the TextEncoding and TextDecoding types, you need to add @types/text-encoding as a dev dependency:
yarn add --dev @types/text-encoding
If you're using Node (not a browser) then you'll also need to make sure the dom lib is referenced in your tsconfig.json:
{
"compilerOptions": {
"lib": [..., "dom"]
}
}
Browser Distribution
Clone this repository locally then run yarn build-web. The browser distribution will be located in dist-web and can be directly copied into your project repository. The dist-web folder contains minified bundles ready for production, along with source mapped versions of the library for debugging. For full browser usage examples, see the documentation.
Import
ES Modules
Importing using ESM syntax is supported using TypeScript, webpack, or Node.js with --experimental-modules flag
import { Api, JsonRpc, RpcError } from 'eosjs';
import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig'; // development only
CommonJS
Importing using commonJS syntax is supported by Node.js out of the box.
const { Api, JsonRpc, RpcError } = require('eosjs');
const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig'); // development only
const fetch = require('node-fetch'); // node only; not needed in browsers
const { TextEncoder, TextDecoder } = require('util'); // node only; native TextEncoder/Decoder
Basic Usage
Signature Provider
The Signature Provider holds private keys and is responsible for signing transactions.
Using the JsSignatureProvider in the browser is not secure and should only be used for development purposes. Use a secure vault outside of the context of the webpage to ensure security when signing transactions in production
const defaultPrivateKey = "5JtUScZK2XEp3g9gh7F8bwtPTRAkASmNrrftmx4AxDKD5K4zDnr"; // bob
const signatureProvider = new JsSignatureProvider([defaultPrivateKey]);
JSON-RPC
Open a connection to JSON-RPC, include fetch when on Node.js.
const rpc = new JsonRpc('http://127.0.0.1:8888', { fetch });
API
Include textDecoder and textEncoder when using in Node. You may exclude these when running in a browser since most modern browsers now natively support these. If your browser does not support these (https://caniuse.com/#feat=textencoder), then you can import them as a dependency through the following deprecated npm package: https://www.npmjs.com/package/text-encoding
const api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });
Sending a transaction
transact() is used to sign and push transactions onto the blockchain with an optional configuration object parameter. This parameter can override the default value of broadcast: true, and can be used to fill TAPOS fields given expireSeconds and either blocksBehind or useLastIrreversible. Given no configuration options, transactions are expected to be unpacked with TAPOS fields (expiration, ref_block_num, ref_block_prefix) and will automatically be broadcast onto the chain.
...
try {
const result = await api.transact({
...
} catch (e) {
console.log('\nCaught exception: ' + e);
if (e instanceof RpcError)
console.log(JSON.stringify(e.json, null, 2));
}
...
Contributing
Contributing Guide
Code of Conduct
License
MIT
Important
See LICENSE for copyright and license terms.
All repositories and other materials are provided subject to the terms of this IMPORTANT notice and you must familiarize yourself with its terms. The notice contains important information, limitations and restrictions relating to our software, publications, trademarks, third-party resources, and forward-looking statements. By accessing any of our repositories and other materials, you accept and agree to the terms of the notice.
Yes — EOSIO/eosjs ships under the MIT license, which makes its source code freely readable (and, depending on license terms, forkable and reusable). Source: github.com/EOSIO/eosjs.
What is EOSIO/eosjs?
EOSIO/eosjs (EOSIO/eosjs) is a TypeScript project on GitHub. From the project's own README: General purpose library for the EOSIO blockchain.
What license does EOSIO/eosjs use?
EOSIO/eosjs is released under the MIT license. Always verify the LICENSE file directly on GitHub for the authoritative terms — license strings can be edited out of sync with a project's actual stance.
Where can I see EOSIO/eosjs in action?
The project maintains a homepage at http://eosio.github.io/eosjs. The README tab on this page also usually contains screenshots and a quickstart.
Where do I read more about EOSIO/eosjs?
This TopGit page is a snapshot — the READ ME tab shows the project's own README content (links stripped, images preserved). The GitHub repository at github.com/EOSIO/eosjs is the definitive source.
Read full README in the tab above.
Want a second opinion on eosjs?
Ask an AI that can read this page — one click and you get its take on eosjs.