Installations
npm install eosjs
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
15.14.0
NPM Version
7.7.6
Score
98.6
Supply Chain
99.6
Quality
80.1
Maintenance
50
Vulnerability
99.6
License
Releases
EOSJS v22.1.0 Release Notes
Published on 13 Jul 2021
EOSJS v22.0.0 Release Notes
Published on 20 May 2021
EOSJS v21.0.4 Release Notes
Published on 19 Apr 2021
EOSJS v22.0.0-rc2 Release Notes
Published on 17 Feb 2021
EOSJS v22.0.0-rc1 Release Notes
Published on 15 Dec 2020
EOSJS v21.0.3 Release Notes
Published on 12 Aug 2020
Contributors
Unable to fetch Contributors
Languages
TypeScript (72.79%)
JavaScript (14.61%)
HTML (7.42%)
Shell (3.41%)
Dockerfile (1.13%)
CSS (0.42%)
C++ (0.22%)
Developer
Download Statistics
Total Downloads
11,624,214
Last Day
3,240
Last Week
31,912
Last Month
176,915
Last Year
1,791,788
GitHub Statistics
1,433 Stars
1,387 Commits
463 Forks
109 Watching
56 Branches
58 Contributors
Package Meta Information
Latest Version
22.1.0
Package Id
eosjs@22.1.0
Size
79.40 kB
NPM Version
7.7.6
Node Version
15.14.0
Publised On
13 Jul 2021
Total Downloads
Cumulative downloads
Total Downloads
11,624,214
Last day
-59.9%
3,240
Compared to previous day
Last week
-26.2%
31,912
Compared to previous week
Last month
-5.6%
176,915
Compared to previous month
Last year
7.6%
1,791,788
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
eosjs
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
1import { Api, JsonRpc, RpcError } from 'eosjs'; 2import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig'; // development only
CommonJS
Importing using commonJS syntax is supported by Node.js out of the box.
1const { Api, JsonRpc, RpcError } = require('eosjs'); 2const { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig'); // development only 3const fetch = require('node-fetch'); // node only; not needed in browsers 4const { 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
1const defaultPrivateKey = "5JtUScZK2XEp3g9gh7F8bwtPTRAkASmNrrftmx4AxDKD5K4zDnr"; // bob 2const signatureProvider = new JsSignatureProvider([defaultPrivateKey]);
JSON-RPC
Open a connection to JSON-RPC, include fetch
when on Node.js.
1const 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
1const 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.
1(async () => { 2 const result = await api.transact({ 3 actions: [{ 4 account: 'eosio.token', 5 name: 'transfer', 6 authorization: [{ 7 actor: 'useraaaaaaaa', 8 permission: 'active', 9 }], 10 data: { 11 from: 'useraaaaaaaa', 12 to: 'useraaaaaaab', 13 quantity: '0.0001 SYS', 14 memo: '', 15 }, 16 }] 17 }, { 18 blocksBehind: 3, 19 expireSeconds: 30, 20 }); 21 console.dir(result); 22})();
Error handling
use RpcError
for handling RPC Errors
1... 2try { 3 const result = await api.transact({ 4 ... 5} catch (e) { 6 console.log('\nCaught exception: ' + e); 7 if (e instanceof RpcError) 8 console.log(JSON.stringify(e.json, null, 2)); 9} 10...
Contributing
License
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.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
all changesets reviewed
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
dependency not pinned by hash detected -- score normalized to 8
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-docker-images.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/build-docker-images.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-docker-images.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/build-docker-images.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-docker-images.yml:41: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/build-docker-images.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-docker-images.yml:99: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/build-docker-images.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-docker-images.yml:157: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/build-docker-images.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build-docker-images.yml:215: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/build-docker-images.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:51: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:110: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:165: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:275: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:330: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:389: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:499: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:668: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:220: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:444: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:554: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/integration-tests.yml:609: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/integration-tests.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-edge.yml:19: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/publish-edge.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-edge.yml:25: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/publish-edge.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-release.yml:18: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/publish-release.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/publish-release.yml:24: update your workflow using https://app.stepsecurity.io/secureworkflow/EOSIO/eosjs/publish-release.yml/master?enable=pin
- Warn: containerImage not pinned by hash: .github/eosjs-ci/Dockerfile:7
- Warn: containerImage not pinned by hash: .github/eosjs-ci/Dockerfile:69
- Info: 37 out of 59 GitHub-owned GitHubAction dependencies pinned
- Info: 32 out of 32 third-party GitHubAction dependencies pinned
- Info: 0 out of 2 containerImage dependencies pinned
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is archived
Details
- Warn: Repository is archived.
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/build-docker-images.yml:1
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/integration-tests.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish-edge.yml:1
- Warn: no topLevel permission defined: .github/workflows/publish-release.yml:1
- Info: no jobLevel write permissions found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 30 are checked with a SAST tool
Reason
29 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-67hx-6x53-jw92
- Warn: Project is vulnerable to: GHSA-p8p7-x288-28g6
- Warn: Project is vulnerable to: GHSA-93q8-gq69-wqmw
- Warn: Project is vulnerable to: GHSA-fwr7-v2mv-hh25
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-x9w5-v3q2-3rhw
- Warn: Project is vulnerable to: GHSA-7gc6-qh9x-w6h8
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-w573-4hg7-7wgq
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-896r-f27r-55mw
- Warn: Project is vulnerable to: GHSA-9c47-m6qq-7p4h
- Warn: Project is vulnerable to: GHSA-952p-6rrq-rcjv
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-xvch-5gv4-984h
- Warn: Project is vulnerable to: GHSA-r683-j2x4-v87g
- Warn: Project is vulnerable to: GHSA-hrpp-h998-j3pp
- Warn: Project is vulnerable to: GHSA-c2qf-rxjj-qqgw
- Warn: Project is vulnerable to: GHSA-4wf5-vphf-c2xc
- Warn: Project is vulnerable to: GHSA-jgrx-mgxx-jf9v
- Warn: Project is vulnerable to: GHSA-72xf-g2v4-qvf3
- Warn: Project is vulnerable to: GHSA-hc6q-2mpp-qw7j
- Warn: Project is vulnerable to: GHSA-4vvj-4cpr-p986
- Warn: Project is vulnerable to: GHSA-j8xg-fqg3-53r7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
4.3
/10
Last Scanned on 2024-12-23
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More