{"id":24302086,"url":"https://github.com/kaiachain/caver-js","last_synced_at":"2026-01-12T12:51:44.614Z","repository":{"id":245978441,"uuid":"811248669","full_name":"kaiachain/caver-js","owner":"kaiachain","description":"Official caver-js repository","archived":false,"fork":false,"pushed_at":"2025-04-27T16:25:10.000Z","size":8273,"stargazers_count":2,"open_issues_count":0,"forks_count":2,"subscribers_count":1,"default_branch":"dev","last_synced_at":"2025-10-04T03:05:19.614Z","etag":null,"topics":["blockchain"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-3.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kaiachain.png","metadata":{"files":{"readme":"README.md","changelog":"Changelog.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":".github/CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-06-06T08:24:12.000Z","updated_at":"2024-12-07T10:27:47.000Z","dependencies_parsed_at":"2024-07-08T09:18:41.864Z","dependency_job_id":"d05d30ee-af08-4bb6-a77f-a1bebb56c2bc","html_url":"https://github.com/kaiachain/caver-js","commit_stats":null,"previous_names":["kaiachain/caver-js"],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/kaiachain/caver-js","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaiachain%2Fcaver-js","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaiachain%2Fcaver-js/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaiachain%2Fcaver-js/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaiachain%2Fcaver-js/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kaiachain","download_url":"https://codeload.github.com/kaiachain/caver-js/tar.gz/refs/heads/dev","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kaiachain%2Fcaver-js/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28338986,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-12T12:22:26.515Z","status":"ssl_error","status_checked_at":"2026-01-12T12:22:10.856Z","response_time":98,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"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":["blockchain"],"created_at":"2025-01-17T00:02:48.621Z","updated_at":"2026-01-12T12:51:44.597Z","avatar_url":"https://github.com/kaiachain.png","language":"JavaScript","funding_links":[],"categories":["SDKs"],"sub_categories":[],"readme":"# caver-js\n\n[![Gitter](https://badges.gitter.im/klaytn/Caver-js.svg)](https://gitter.im/klaytn/Caver-js?utm_source=badge\u0026utm_medium=badge\u0026utm_campaign=pr-badge)\n\n\u003cp align=\"center\"\u003e\n  \u003cimg src=\"assets/logo/caver-js.png\" width=\"200\" alt=\"caver-js\" /\u003e\n\u003c/p\u003e\n\ncaver-js is a JavaScript API library that allows developers to interact with a\nkaia node using a HTTP or Websocket connection.\n\n**NOTE**\nKaikas Web Extension Wallet is recommended to be used with [features prior to common architecture](https://docs.kaia.com/dapp/sdk/caver-js/v1.4.1). New features provided in caver-js v1.5.0 (introduced common architecrue) or later are currently not compatible with Kaikas.\nKaikas web extension wallet works fine with functions prior to common architecture, so please use [functions prior to common architecture](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1).\nEven in the latest version of caver-js, [functions prior to common architecture](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1) are provided for backward compatibility. See [Trouble shooting and known issues](#connect-with-kaikas-web-extension) for more details.\n\n## Table of contents\n\n   * [Requirements](#requirements)\n   * [Installation](#installation)\n   * [Getting Started](#getting-started)\n      * [Check the Connection](#check-the-connection)\n      * [Using caver-js keyring/wallet](#using-caver-js-keyring/wallet)\n      * [Submitting a Transaction](#submitting-a-transaction)\n      * [Units for KLAY](#units-for-klay)\n   * [Documentation](#documentation)\n   * [API Specification](#api-specification)\n   * [Web3.js Similarity](#web3.js-similarity)\n   * [Error Code Improvement](#error-code-improvement)\n   * [Sample Projects](#sample-projects)\n   * [Github Repository](#github-repository)\n   * [Trouble shooting and known issues](#trouble-shooting-and-known-issues)\n   * [Related Projects](#related-projects)\n\n## Requirements\n\nThe following packages are required to use the caver-js library.\n- [Node.js](https://nodejs.org/en/download/)\n- [npm](https://www.npmjs.com/get-npm)\n- [gcc-c++](https://gcc.gnu.org/)\n\nTesting in caver-js is implemented using the mocha testing framework. If you want to run unit tests in caver-js, you need to install mocha first.\n- [mocha](https://mochajs.org/#installation)\n\n**Note** caver-js can run on Node.js versions 12 and 14, and the recommended versions are:\n- lts/erbium ([12.21.0](https://nodejs.org/dist/latest-v12.x/))\n- lts/fermium ([14.16.0](https://nodejs.org/dist/latest-v14.x/))\n\nIf you are already using a different version of the node(for example, node v15), use the Node Version Manager([NVM](https://github.com/nvm-sh/nvm)) to install and use the version supported by caver-js.\n\n\n## Installation\n\n### Node\n\nTo try it out, install caver-js with npm like following command:\n\n```\n$ npm install caver-js\n```\n\n**Note** `package.json` file should exist on the same install path.  If it\ndoes not exist, `package.json` should be generated via `npm init`.\n\nTo install a specific version of caver-js, try the following command:\n```\n$ npm install caver-js@X.X.X\n```\n\n### In the Browser\n\nBuild using the caver-js repository:\n\n```\n$ npm run build\n```\n\nThen include `dist/caver.min.js` in your html file. This will expose Caver on the window object.\n\n\n## Getting Started\n\nIf you want to run your own EN (Endpoint Node), see [EN Operation Guide](https://docs.kaia.io/docs/nodes/endpoint-node/) to set up. You can connect EN like below:\n```\n$ node\n\u003e const Caver = require('caver-js')\n\u003e const caver = new Caver('http://localhost:8551/')\n```\n**Note** The above example should be executed from the location where caver-js is installed, and the example is explained using [Node.js REPL](https://nodejs.org/api/repl.html#repl_the_node_js_repl).\n\n### Check the Connection\nYou can now use caver-js. You can send a basic request to the node as shown below and check the results.\n```\n\u003e caver.rpc.klay.getClientVersion().then(console.log)\nkaia/vX.X.X/linux-amd64/goX.X.X\n```\n\n### Using caver-js keyring/wallet\n\nYou can easily use your kaia account when signing a transaction or message by using the [Keyring] / [wallet].\n\nThe keyring is a new feature that contains an address and one or more private keys based on the key types ([SingleKeyring], [MultipleKeyring] or [RoleBasedKeyring]). Refer to [caver.wallet.keyring] for details.\n[caver.wallet], the **in-memory wallet**, is provided to easily manage multiple keyrings.\n\n**Note** Functions associated with `wallet` and `keyring` have no effect on the kaia blockchain platform. It just manipulates keyrings in the in-memory wallet.\n\nLet's create a random keyring as shown in the example below:\n```\n\u003e const keyring = caver.wallet.keyring.generate()\n\n\u003e keyring\nSingleKeyring {\n  _address: '0x64d221893cc628605314026f4c4e0879af5b75b1',\n  _key: PrivateKey { _privateKey: '0x{private key}' }\n}\n```\n\nYou can add the keyring object created in the above example to the caver.wallet, or you can add a keyring using an address and private key(s).\n```\n// Add a keyring instance to caver.wallet\n\u003e caver.wallet.add(keyring)\n\n// Add a keyring to caver.wallet with an address and a private key\n\u003e caver.wallet.newKeyring('0x{address in hex}', '0x{private key}')\n\n// Add a keyring to caver.wallet with an address and private keys\n\u003e caver.wallet.newKeyring('0x{address in hex}', ['0x{private key1}', '0x{private key2}', ...])\n\n// Add a keyring to caver.wallet with an address and private keys by roles\n\u003e caver.wallet.newKeyring('0x{address in hex}', [ ['0x{private key1}', ...], ['0x{private key2}', ...], ['0x{private key3}', ...] ])\n```\n\n### Submitting a Transaction\nYou can use caver-js to submit various types of transactions to a node. Please refer to the [caver.transaction](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-transaction/#class) to see how to create a transaction of each type.\n\n**Note** you should create a transaction instance via `create` function. From caver-js v1.8.2, constructors per transaction type are not supported.\n\nYou can sign the transaction using a keyring and send a signed transaction through `caver.rpc.klay.sendRawTransaction` as shown below, and the receipt is returned as a result.\n```\n// Add a keyring to caver.wallet\n\u003e const keyring = caver.wallet.newKeyring('0x{address in hex}', '0x{private key}')\n\u003e const vt = caver.transaction.valueTransfer.create({\n\t\tfrom: keyring.address,\n\t\tto: '0x176ff0344de49c04be577a3512b6991507647f72',\n\t\tvalue: caver.utils.convertToPeb(1, 'KLAY'),\n\t\tgas: 25000,\n\t})\n\u003e caver.wallet.sign(keyring.address, vt).then(signed =\u003e {\n  caver.rpc.klay.sendRawTransaction(signed).then(console.log)\n})\n{ \n  blockHash: '0x0a78b5c5b95456b2d6b6a9ba25fd2afd0000d16bcf03a8ae58a6557a59319a67',\n  blockNumber: 8021,\n  contractAddress: null,\n  from: '0x09a08f2289d3eb3499868908f1c84fd9523fe11b',\n  ...\n  type: 'TxTypeValueTransfer',\n  typeInt: 8,\n  value: '0xde0b6b3a7640000' \n}\n```\n\nThe above example uses `Promise` when sending a signed transaction to the kaia. You can also use `event emitter` like below.\n\n```\ncaver.rpc.klay.sendRawTransaction(signed).on('transactionHash', function(hash){\n    ...\n  }).on('receipt', function(receipt){\n    ...\n  })\n```\n\n### Units for KLAY\nUnits of KLAY is shown as below, and `peb` is the smallest currency unit.\n`peb` is the default unit unless the unit conversion is used.\n\n| Name | Unit |\n| --- | ---: |\n| peb | 1 |\n| kpeb | 1,000 |\n| Mpeb | 1,000,000 |\n| Gpeb | 1,000,000,000 |\n| ston | 1,000,000,000 |\n| uKLAY | 1,000,000,000,000 |\n| mKLAY | 1,000,000,000,000,000 |\n| KLAY | 1,000,000,000,000,000,000 |\n| kKLAY | 1,000,000,000,000,000,000,000 |\n| MKLAY | 1,000,000,000,000,000,000,000,000 |\n| GKLAY | 1,000,000,000,000,000,000,000,000,000 |\n| TKLAY | 1,000,000,000,000,000,000,000,000,000,000 |\n\ncaver-js provides the caver.utils.convertToPeb function for unit conversion. Please refer to the usage below.\n```\n\u003e caver.utils.convertToPeb(1, 'peb')\n'1'\n\n\u003e caver.utils.convertToPeb(1, 'Gpeb')\n'1000000000'\n\n\u003e caver.utils.convertToPeb(1, 'KLAY')\n'1000000000000000000'\n```\n\n## Documentation\n\nDocumentation can be found at [kaia Docs-caver-js](https://docs.kaia.io/docs/references/sdk/caver-js).\n\n## API Specification\n\nThe API lists of caver-js are described in folloinwg links:\n\n* [caver.account](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver.account)\n* [caver.wallet](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet)\n* [caver.wallet.keyring](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet/keyring)\n* [caver.transaction](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-transaction)\n* [caver.rpc.klay](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-rpc/klay)\n* [caver.rpc.net](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-rpc/net)\n* [caver.contract](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver.contract)\n* [caver.abi](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver.abi)\n* [caver.kct.kip7](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-kct/kip7)\n* [caver.kct.kip17](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-kct/kip17)\n* [caver.utils](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver.utils)\n* [caver.ipfs](https://docs.kaia.io/docs/references/sdk/caver-js/api/caver.ipfs)\n\n## Web3.js Similarity\n\nSince caver-js has been evolved from web3.js, usage pattern of caver-js is very similar to that of web3.js.\t\nThis means a software developed using web3.js can be easily converted to caver-js.\t\nThe following examples are code patterns used in web3.js and caver-js, respectively.\t\n\n```\t\nconst Web3 = require('web3');\t\nconst web3 = new Web3(new web3.providers.HttpProvider('http://localhost:8545'));\t\nweb3.eth.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1').then(console.log)\t\n```\t\n\n```\t\nconst Caver = require('caver-js');\t\nconst caver = new Caver(new Caver.providers.HttpProvider('http://localhost:8545'));\t\ncaver.rpc.klay.getBalance('0x407d73d8a49eeb85d32cf465507dd71d507100c1').then(console.log)\t\n```\t\n\n## Error Code Improvement\n\n\nkaia improves reporting transaction failure via txError in the receipt.\ncaver-js further improves the report by presenting the error string that corresponds to txError.\n\nThe below is an example of a receipt containing txError.\n\n```\nError: VM error occurs while running smart contract\n {\n  \"blockHash\": \"0xe7ec35c9fff1178d52cee1d46d40627d19f828c4b06ad1a5c3807698b99acb20\",\n  ...\n  \"txError\": \"0x2\",\n  ...\n}\n```\n\nThe meaning of error code can be found below:\n\n| Error Code | Description |\n|---|---|\n|0x02|VM error occurs while running smart contract|\n|0x03|max call depth exceeded|\n|0x04|contract address collision|\n|0x05|contract creation code storage out of gas|\n|0x06|evm: max code size exceeded|\n|0x07|out of gas|\n|0x08|evm: write protection|\n|0x09|evm: execution reverted|\n|0x0a|reached the opcode computation cost limit (100000000) for tx|\n|0x0b|account already exists|\n|0x0c|not a program account (e.g., an account having code and storage)|\n|0x0d|Human-readable address is not supported now|\n|0x0e|fee ratio is out of range [1, 99]|\n|0x0f|AccountKeyFail is not updatable|\n|0x10|different account key type|\n|0x11|AccountKeyNil cannot be initialized to an account|\n|0x12|public key is not on curve|\n|0x13|key weight is zero|\n|0x14|key is not serializable|\n|0x15|duplicated key|\n|0x16|weighted sum overflow|\n|0x17|unsatisfiable threshold. Weighted sum of keys is less than the threshold.|\n|0x18|length is zero|\n|0x19|length too long|\n|0x1a|nested composite type|\n|0x1b|a legacy transaction must be with a legacy account key|\n|0x1c|deprecated feature|\n|0x1d|not supported|\n|0x1e|smart contract code format is invalid|\n\n## Sample Projects\n\nThe BApp (Blockchain Application) Development sample projects using caver-js are the following:\n\n* [Count DApp](https://docs.kaia.io/docs/build/tutorials/count-dapp/)\n* [Klaystagram](https://docs.kaia.io/docs/build/tutorials/klaystagram/)\n\n## Trouble shooting and known issues\n\n### Connect with Kaikas Web Extension\n\nKaikas Web Extension Wallet works normally with [functions prior to common architecture](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1).\nFeatures provided in later versions (caver-js v1.5.0~) may not work with Kaikas Web Extension Wallet.\n\nIf the following error occurs when using with Kaikas, it must be modified to use the [functions supported by caver-js v1.4.1](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1).\nFor compatibility with the latest version, the same [functions provided by caver-js v1.4.1](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1) are provided.\n\n```\nKaikas only processes one transaction at a time. Open Kaikas and refresh the pending transaction. If the service doesn’t process your transaction for a while, cancel the pending transaction.\n```\n\n```\nKaikas는 한 번에 하나의 트랜잭션만 처리합니다. Kaikas를 열어 대기 중인 트랜잭션을 새로고침 해주세요. 만약 대기 상태가 계속된다면 이용 중인 서비스가 트랜잭션을 처리하지 않는 것이니 트랜잭션을 취소바랍니다.\n```\n\nAlthough the above error is mostly the case, other errors may occur besides the above error, so if you are using Kaikas Web Extension Wallet, please use the [functions supported by caver-js v1.4.1](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1).\nKeep in mind that you **cannot mix features** before and after common architecture.\n\nFor documents for the functions supported by caver-js v1.4.1, refer to [caver-js ~v1.4.1 Documentation](https://docs.klaytn.com/dapp/sdk/caver-js/v1.4.1).\n\n### Using webpack \u003e= 5\n\nNode.js module polyfills are not provided by default in webpack v5 and later.\nTherefore, you need to install the missing modules and add them to the `resolve.fallback` property of the webpack.config.js file in the form below.\n\n```\nmodule.exports = {\n    ...\n    resolve: {\n        fallback: {\n            fs: false,\n            net: false,\n            stream: require.resolve('stream-browserify'),\n            crypto: require.resolve('crypto-browserify'),\n            http: require.resolve('stream-http'),\n            https: require.resolve('https-browserify'),\n            os: require.resolve('os-browserify/browser'),\n            ...\n        },\n    },\n}\n```\n\nMore information on migrating to webpack v5 can be found [here](https://webpack.js.org/migrate/5/#clean-up-configuration).\n\nIf you are implementing an app using [create-react-app](https://create-react-app.dev/), you can use [react-app-rewired](https://www.npmjs.com/package/react-app-rewired) to add the above polyfills to the webpack.config.js file used by [CRA](https://create-react-app.dev/).\nMore information on using react-app-rewired with create-react-app can be found [here](https://www.npmjs.com/package/react-app-rewired).\n\n## Github Repository\n\n* [caver-js](https://github.com/kaiachain/caver-js)\n\n## Related Projects\n\n[caver-java](https://github.com/kaiachain/caver-java) for Java\n\n\n[Keyring]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet/keyring\n[caver.wallet.keyring]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet/keyring\n[wallet]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet\n[caver.wallet]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet\n[SingleKeyring]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet/keyring#singlekeyring\n[MultipleKeyring]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet/keyring#multiplekeyring\n[RoleBasedKeyring]: https://docs.kaia.io/docs/references/sdk/caver-js/api/caver-wallet/keyring#rolebasedkeyring\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaiachain%2Fcaver-js","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkaiachain%2Fcaver-js","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkaiachain%2Fcaver-js/lists"}