JSPM

caver-js

0.0.2w
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1360
  • Score
    100M100P100Q138372F
  • License ISC

TBA

Package Exports

  • caver-js
  • caver-js/packages/caver-core-helpers
  • caver-js/packages/caver-klay/caver-klay-accounts/src/makeRawTransaction
  • caver-js/packages/caver-utils

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (caver-js) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

caver.js

caver.js is a JavaScript API library that allows developers to interact with a Klaytn node using a HTTP or Websocket connection. It is available on npm.

To try it out, install caver-js with npm like following command:

$ npm install caver-js

Note that package.json file should exist on the same install path. If it does not exist, package.json should be generated via npm init.

API Specification

The API lists of caver.js are described in folloinwg links:

Error Code Improvement

The error messages from Ethereum via web3.js are hardly figuring out where the error occurs. caver.js improves the interface to catch error messages from Klaytn.

More details can be found in the value of txError of the transaction receipt like the below:

Error: runtime error occurred in interpreter
 {
  "blockHash": "0xe7ec35c9fff1178d52cee1d46d40627d19f828c4b06ad1a5c3807698b99acb20",
  "blockNumber": 7811,
  "contractAddress": null,
  "from": "0xa8a2d37727197cc0eb827f8c5a3a3aceb26cf59e",
  "gasUsed": 9900000000,
  "logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
  "status": false,
  "to": "0xf8425b0f65147969621f9390ca06139c7b439497",
  "transactionHash": "0x85ce2b307899c90144442d9b3236827ac57375c522be2435093aebfd920b8c58",
  "transactionIndex": 0,
  "txError": "0x2",
  "events": {}
}

The meaning of error code can be found below:

{
  "0x2": 'runtime error occurred in interpreter',
  "0x3": 'max call depth exceeded',
  "0x4": 'contract address collision',
  "0x5": 'contract creation code storage out of gas',
  "0x6": 'evm: max code size exceeded',
  "0x7": 'out of gas',
  "0x8": 'evm: write protection',
  "0x9": 'evm: execution reverted',
  "0xa": 'reached the opcode count limit',
  "0xb": 'account already exists',
  "0xc": 'not a program account (e.g., an account having code and storage)',
  "0xd": 'not a human readable address',
  "0xe": "fee ratio is out of range [1, 99]", 
  "0xf": "AccountKeyFail is not updatable", 
  "0x10": "different account key type", 
  "0x11": "AccountKeyNil cannot be initialized to an account", 
  "0x12": "public key is not on curve", 
  "0x13": "key weight is zero", 
  "0x14": "key is not serializable", 
  "0x15": "duplicated key", 
  "0x16": "weighted sum overflow", 
  "0x17": "unsatisfiable threshold. Weighted sum of keys is less than the threshold.", 
  "0x18": "length is zero", 
  "0x19": "length too long", 
  "0x1a": "nested role-based key", 
}

Tutorials

The BApp(Blockchain Application) Development Tutorial using caver.js is following: