{"id":13453293,"url":"https://github.com/EOSIO/eosjs","last_synced_at":"2025-03-24T01:31:19.325Z","repository":{"id":24340715,"uuid":"99262393","full_name":"EOSIO/eosjs","owner":"EOSIO","description":"General purpose library for the EOSIO blockchain. ","archived":true,"fork":false,"pushed_at":"2022-08-01T01:38:25.000Z","size":16437,"stargazers_count":1433,"open_issues_count":53,"forks_count":461,"subscribers_count":108,"default_branch":"master","last_synced_at":"2025-03-17T06:38:34.625Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://eosio.github.io/eosjs","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/EOSIO.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-08-03T18:17:52.000Z","updated_at":"2025-03-15T20:58:47.000Z","dependencies_parsed_at":"2022-07-13T10:30:42.778Z","dependency_job_id":null,"html_url":"https://github.com/EOSIO/eosjs","commit_stats":null,"previous_names":[],"tags_count":106,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/EOSIO%2Feosjs/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/EOSIO","download_url":"https://codeload.github.com/EOSIO/eosjs/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245194208,"owners_count":20575725,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T08:00:37.540Z","updated_at":"2025-03-24T01:31:18.729Z","avatar_url":"https://github.com/EOSIO.png","language":"TypeScript","funding_links":[],"categories":["EOS Smart Contract Development","Language Support","EOS Libraries","Developers","TypeScript"],"sub_categories":["Programming tools","JavaScript","Libraries and Frameworks"],"readme":"# eosjs\n[![Build Status](https://github.com/eosio/eosjs/workflows/CI/badge.svg?branch=master)](https://github.com/EOSIO/eosjs/actions)  [![npm version](https://badge.fury.io/js/eosjs.svg)](https://badge.fury.io/js/eosjs)  [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)  ![npm](https://img.shields.io/npm/dw/eosjs.svg)\n\nJavascript API for integration with EOSIO-based blockchains using [EOSIO RPC API](https://developers.eos.io/eosio-nodeos/reference).\n\nDocumentation can be found [here](https://eosio.github.io/eosjs)\n\n## Installation\n\n### NPM\n\nThe official distribution package can be found at [npm](https://www.npmjs.com/package/eosjs).\n\n### Add dependency to your project\n\n`yarn add eosjs`\n\n### Using with Typescript\n\nIn order to get access to the `TextEncoding` and `TextDecoding` types, you need to add `@types/text-encoding` as a dev dependency:\n`yarn add --dev @types/text-encoding`\n\nIf you're using Node (not a browser) then you'll also need to make sure the `dom` lib is referenced in your `tsconfig.json`:\n\n```\n{\n\t\"compilerOptions\": {\n\t\t\"lib\": [..., \"dom\"]\n\t}\n}\n```\n\n### Browser Distribution\n\nClone 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](https://eosio.github.io/eosjs/guides/1.-Browsers.html).\n\n## Import\n\n### ES Modules\n\nImporting using ESM syntax is supported using TypeScript, [webpack](https://webpack.js.org/api/module-methods), or  [Node.js with `--experimental-modules` flag](https://nodejs.org/api/esm.html)\n```js\nimport { Api, JsonRpc, RpcError } from 'eosjs';\nimport { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig';           // development only\n```\n\n### CommonJS\n\nImporting using commonJS syntax is supported by Node.js out of the box.\n```js\nconst { Api, JsonRpc, RpcError } = require('eosjs');\nconst { JsSignatureProvider } = require('eosjs/dist/eosjs-jssig');      // development only\nconst fetch = require('node-fetch');                                    // node only; not needed in browsers\nconst { TextEncoder, TextDecoder } = require('util');                   // node only; native TextEncoder/Decoder\n```\n\n## Basic Usage\n\n### Signature Provider\n\nThe Signature Provider holds private keys and is responsible for signing transactions.\n\n***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***\n\n```js\nconst defaultPrivateKey = \"5JtUScZK2XEp3g9gh7F8bwtPTRAkASmNrrftmx4AxDKD5K4zDnr\"; // bob\nconst signatureProvider = new JsSignatureProvider([defaultPrivateKey]);\n```\n\n### JSON-RPC\n\nOpen a connection to JSON-RPC, include `fetch` when on Node.js.\n```js\nconst rpc = new JsonRpc('http://127.0.0.1:8888', { fetch });\n```\n\n### API\n\nInclude 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\n```js\nconst api = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });\n```\n\n### Sending a transaction\n\n`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.\n\n```js\n(async () =\u003e {\n  const result = await api.transact({\n    actions: [{\n      account: 'eosio.token',\n      name: 'transfer',\n      authorization: [{\n        actor: 'useraaaaaaaa',\n        permission: 'active',\n      }],\n      data: {\n        from: 'useraaaaaaaa',\n        to: 'useraaaaaaab',\n        quantity: '0.0001 SYS',\n        memo: '',\n      },\n    }]\n  }, {\n    blocksBehind: 3,\n    expireSeconds: 30,\n  });\n  console.dir(result);\n})();\n```\n\n### Error handling\n\nuse `RpcError` for handling RPC Errors\n```js\n...\ntry {\n  const result = await api.transact({\n  ...\n} catch (e) {\n  console.log('\\nCaught exception: ' + e);\n  if (e instanceof RpcError)\n    console.log(JSON.stringify(e.json, null, 2));\n}\n...\n```\n\n## Contributing\n\n[Contributing Guide](./CONTRIBUTING.md)\n\n[Code of Conduct](./CONTRIBUTING.md#conduct)\n\n## License\n\n[MIT](./LICENSE)\n\n## Important\n\nSee [LICENSE](./LICENSE) for copyright and license terms.\n\nAll repositories and other materials are provided subject to the terms of this [IMPORTANT](./IMPORTANT.md) 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.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEOSIO%2Feosjs","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FEOSIO%2Feosjs","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FEOSIO%2Feosjs/lists"}