{"_id":"eth-rpc-errors","_rev":"4629414","name":"eth-rpc-errors","description":"Ethereum RPC and Provider errors.","dist-tags":{"latest":"4.0.3"},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"time":{"modified":"2026-04-10T18:47:57.000Z","created":"2020-05-12T02:45:08.113Z","4.0.3":"2021-03-11T05:24:29.894Z","4.0.2":"2020-11-17T19:10:12.965Z","4.0.1":"2020-11-03T17:58:48.178Z","4.0.0":"2020-11-03T00:55:40.250Z","3.0.0":"2020-07-29T23:12:24.251Z","2.1.1":"2020-05-12T14:07:45.770Z","2.1.0":"2020-05-12T02:45:08.113Z"},"users":{},"author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"versions":{"4.0.3":{"name":"eth-rpc-errors","version":"4.0.3","description":"Ethereum RPC and Provider errors.","license":"MIT","author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"scripts":{"build":"tsc --project .","test":"yarn build && node test","test:coverage":"yarn build && nyc tape test","lint":"eslint . --ext ts,js,json","lint:fix":"eslint . --ext ts,js,json --fix","prepublishOnly":"yarn test"},"main":"dist/index.js","dependencies":{"fast-safe-stringify":"^2.0.6"},"devDependencies":{"@metamask/eslint-config":"^4.1.0","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0","eslint":"^7.12.1","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.1","eslint-plugin-node":"^11.1.0","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0","typescript":"^4.0.5"},"bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"gitHead":"a41b1cc9b89f0db29413a8a1350cf4b22c99d062","_id":"eth-rpc-errors@4.0.3","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","dist":{"shasum":"6ddb6190a4bf360afda82790bb7d9d5e724f423a","size":13472,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-4.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-4.0.3.tgz"},"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_4.0.3_1615440269676_0.7259934415879781"},"_hasShrinkwrap":false,"publish_time":1615440269894,"_cnpm_publish_time":1615440269894,"_cnpmcore_publish_time":"2021-12-16T15:32:41.058Z"},"4.0.2":{"name":"eth-rpc-errors","version":"4.0.2","description":"Ethereum RPC and Provider errors.","license":"MIT","author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"scripts":{"build":"tsc --project .","test":"yarn build && node test","test:coverage":"yarn build && nyc tape test","lint":"eslint . --ext ts,js,json","lint:fix":"eslint . --ext ts,js,json --fix","prepublishOnly":"yarn test"},"main":"dist/index.js","dependencies":{"fast-safe-stringify":"^2.0.6"},"devDependencies":{"@metamask/eslint-config":"^4.1.0","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0","eslint":"^7.12.1","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.1","eslint-plugin-node":"^11.1.0","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0","typescript":"^4.0.5"},"bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"gitHead":"2a699ebf130cff6312f486a332da595e0ee30f4b","_id":"eth-rpc-errors@4.0.2","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","dist":{"shasum":"11bc164e25237a679061ac05b7da7537b673d3b7","size":13428,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-4.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-4.0.2.tgz"},"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_4.0.2_1605640212778_0.8323278985273934"},"_hasShrinkwrap":false,"publish_time":1605640212965,"_cnpm_publish_time":1605640212965,"_cnpmcore_publish_time":"2021-12-16T15:32:41.307Z"},"4.0.1":{"name":"eth-rpc-errors","version":"4.0.1","description":"Ethereum RPC and Provider errors.","license":"MIT","author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"scripts":{"build":"tsc","test":"yarn build && node test","test:coverage":"yarn build && nyc tape test","lint":"eslint . --ext ts,js,json","lint:fix":"eslint . --ext ts,js,json --fix","prepublishOnly":"yarn test"},"main":"dist/index.js","dependencies":{"fast-safe-stringify":"^2.0.6"},"devDependencies":{"@metamask/eslint-config":"^4.1.0","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0","eslint":"^7.12.1","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.1","eslint-plugin-node":"^11.1.0","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0","typescript":"^4.0.5"},"bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"gitHead":"d1a4a9f5635031330cf833d665927f13cd8e36e2","_id":"eth-rpc-errors@4.0.1","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","dist":{"shasum":"bb95cc6de85b59dcbd5453b661a9e99545eff550","size":13317,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-4.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-4.0.1.tgz"},"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_4.0.1_1604426328026_0.08306015800783473"},"_hasShrinkwrap":false,"publish_time":1604426328178,"_cnpm_publish_time":1604426328178,"_cnpmcore_publish_time":"2021-12-16T15:32:41.518Z"},"4.0.0":{"name":"eth-rpc-errors","version":"4.0.0","description":"Ethereum RPC and Provider errors.","license":"MIT","author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"scripts":{"build":"tsc","test":"yarn build && node test","test:coverage":"yarn build && nyc tape test","lint":"eslint . --ext ts,js,json","lint:fix":"eslint . --ext ts,js,json --fix","prepublishOnly":"yarn test"},"main":"dist/index.js","dependencies":{"fast-safe-stringify":"^2.0.6"},"devDependencies":{"@metamask/eslint-config":"^4.1.0","@typescript-eslint/eslint-plugin":"^4.6.0","@typescript-eslint/parser":"^4.6.0","eslint":"^7.12.1","eslint-plugin-import":"^2.22.1","eslint-plugin-json":"^2.1.1","eslint-plugin-node":"^11.1.0","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0","typescript":"^4.0.5"},"bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"gitHead":"b83d06cefb73c3379c26ea21ed94333d5ae62796","_id":"eth-rpc-errors@4.0.0","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","dist":{"shasum":"6a2c075c5f02df12cc949e8450d72f1aba3ebdc4","size":13345,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-4.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-4.0.0.tgz"},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_4.0.0_1604364940130_0.5707381145448533"},"_hasShrinkwrap":false,"publish_time":1604364940250,"_cnpm_publish_time":1604364940250,"_cnpmcore_publish_time":"2021-12-16T15:32:41.729Z"},"3.0.0":{"name":"eth-rpc-errors","version":"3.0.0","description":"Ethereum RPC and Provider errors.","license":"MIT","author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"scripts":{"build":"echo","test":"node test","test:coverage":"nyc tape test","lint":"eslint . --ext js,json","lint:fix":"eslint . --ext js,json --fix"},"main":"index.js","dependencies":{"fast-safe-stringify":"^2.0.6"},"devDependencies":{"@metamask/eslint-config":"^2.1.1","eslint":"6.8.0","eslint-plugin-import":"^2.20.2","eslint-plugin-json":"^2.1.1","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0"},"bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"gitHead":"62b5ff7d8aaec0388b1a89c67f44bdfc41e2e78b","_id":"eth-rpc-errors@3.0.0","_nodeVersion":"10.18.1","_npmVersion":"6.13.4","dist":{"shasum":"d7b22653c70dbf9defd4ef490fd08fe70608ca10","size":7500,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-3.0.0.tgz"},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_3.0.0_1596064344114_0.6718400329957823"},"_hasShrinkwrap":false,"publish_time":1596064344251,"_cnpm_publish_time":1596064344251,"_cnpmcore_publish_time":"2021-12-16T15:32:42.004Z"},"2.1.1":{"name":"eth-rpc-errors","version":"2.1.1","description":"Ethereum RPC and Provider errors.","license":"MIT","author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"scripts":{"build":"echo","test":"node test","test:coverage":"nyc tape test","lint":"eslint . --ext js,json","lint:fix":"eslint . --ext js,json --fix"},"main":"index.js","dependencies":{"fast-safe-stringify":"^2.0.6"},"devDependencies":{"@metamask/eslint-config":"^2.1.1","eslint":"6.8.0","eslint-plugin-import":"^2.20.2","eslint-plugin-json":"^2.1.1","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0"},"bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"gitHead":"e5f4991f43c9caafb7886007689865f4474c41f3","_id":"eth-rpc-errors@2.1.1","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"00a7d6c8a9c864a8ab7d0356be20964e5bee4b13","size":7325,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-2.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-2.1.1.tgz"},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_2.1.1_1589292465670_0.576338135247451"},"_hasShrinkwrap":false,"publish_time":1589292465770,"_cnpm_publish_time":1589292465770,"_cnpmcore_publish_time":"2021-12-16T15:32:42.238Z"},"2.1.0":{"name":"eth-rpc-errors","version":"2.1.0","description":"Ethereum RPC and Provider errors.","main":"index.js","scripts":{"build":"echo","test":"node test","test:coverage":"nyc tape test","lint":"eslint . --ext js,json","lint:fix":"eslint . --ext js,json --fix"},"repository":{"type":"git","url":"git+https://github.com/MetaMask/eth-rpc-errors.git"},"keywords":["rpc","ethereum","errors","utility"],"author":{"name":"Erik Marks","email":"rekmarks@protonmail.com"},"license":"MIT","bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","devDependencies":{"@metamask/eslint-config":"^2.1.1","eslint":"6.8.0","eslint-plugin-import":"^2.20.2","eslint-plugin-json":"^2.1.1","fast-deep-equal":"^2.0.1","nyc":"^15.0.1","tape":"^5.0.0"},"dependencies":{"fast-safe-stringify":"^2.0.6"},"gitHead":"1275c426989376fd0f713b70736d754d5ab59afc","_id":"eth-rpc-errors@2.1.0","_nodeVersion":"10.16.0","_npmVersion":"6.9.0","dist":{"shasum":"05c68c52a0bb4cefa14e2c42b3269f5ed0c074ae","size":9809,"noattachment":false,"key":"/eth-rpc-errors/-/eth-rpc-errors-2.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/eth-rpc-errors/download/eth-rpc-errors-2.1.0.tgz"},"maintainers":[{"name":"danfinlay","email":"dan@danfinlay.com"},{"name":"kumavis","email":"aaron@kumavis.me"},{"name":"rekmarks","email":"rekmarks@protonmail.com"},{"name":"whymarrh","email":""}],"_npmUser":{"name":"rekmarks","email":"rekmarks@protonmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/eth-rpc-errors_2.1.0_1589251508007_0.24284183909754087"},"_hasShrinkwrap":false,"publish_time":1589251508113,"_cnpm_publish_time":1589251508113,"_cnpmcore_publish_time":"2021-12-16T15:32:42.432Z"}},"readme":"# eth-rpc-errors\n\nEthereum RPC errors, including for\n[Ethereum JSON RPC](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1474.md)\nand\n[Ethereum Provider](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-1193.md),\nand [making unknown errors compliant with either spec](#parsing-unknown-errors).\n\n## Basic Usage\n\nIn TypeScript or JavaScript:\n\n```js\nimport { ethErrors } from 'eth-rpc-errors'\n\nthrow ethErrors.provider.unauthorized()\n// or\nthrow ethErrors.provider.unauthorized('my custom message')\n```\n\n## Supported Errors\n\n- Ethereum JSON RPC\n  - Per [EIP-1474](https://eips.ethereum.org/EIPS/eip-1474#error-codes)\n    - This includes all\n    [JSON RPC 2.0 errors](https://www.jsonrpc.org/specification#error_object)\n- Ethereum Provider errors\n  - Per [EIP-1193](https://eips.ethereum.org/EIPS/eip-1193#provider-errors)\n    - Does **not** yet support [`CloseEvent` errors or status codes](https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent#Status_codes).\n\n## Usage\n\nInstallation: `npm install eth-rpc-errors` or `yarn add eth-rpc-errors`\n\n`import` or `require` as normal (no default export).\n\nThe package is implemented in TypeScript, and all exports are typed.\n\n### Errors API\n\n```js\nimport { ethErrors } from 'eth-rpc-errors'\n\n// Ethereum RPC errors are namespaced under \"ethErrors.rpc\"\nresponse.error = ethErrors.rpc.methodNotFound({\n  message: optionalCustomMessage, data: optionalData\n})\n\n// Provider errors namespaced under ethErrors.provider\nresponse.error = ethErrors.provider.unauthorized({\n  message: optionalCustomMessage, data: optionalData\n})\n\n// each error getter takes a single \"opts\" argument\n// for most errors, this can be replaced with a single string, which becomes\n// the error message\nresponse.error = ethErrors.provider.unauthorized(customMessage)\n\n// if an error getter accepts a single string, all arguments can be omitted\nresponse.error = ethErrors.provider.unauthorized()\nresponse.error = ethErrors.provider.unauthorized({})\n\n// omitting the message will produce an error with a default message per\n// the relevant spec\n\n// omitting the data argument will produce an error without a\n// \"data\" property\n\n// the JSON RPC 2.0 server error requires a valid code\nresponse.error = ethErrors.rpc.server({\n  code: -32031\n})\n\n// custom Ethereum Provider errors require a valid code and message\n// valid codes are integers i such that: 1000 <= i <= 4999\nresponse.error = ethErrors.provider.custom({\n  code: 1001, message: 'foo'\n})\n```\n\n### Parsing Unknown Errors\n\n```js\n// this is useful for ensuring your errors are standardized\nimport { serializeError } from 'eth-rpc-errors'\n\n// if the argument is not a valid error per any supported spec,\n// it will be added as error.data.originalError\nresponse.error = serializeError(maybeAnError)\n\n// you can add a custom fallback error code and message if desired\nconst fallbackError = { code: 4999, message: 'My custom error.' }\nresponse.error = serializeError(maybeAnError, fallbackError)\n\n// Note: if the original error has a \"message\" property, it will take\n// precedence over the fallback error's message\n\n// the default fallback is:\n{\n  code: -32603,\n  message: 'Internal JSON-RPC error.'\n}\n```\n\n### Other Exports\n\n```js\n/**\n * Classes\n */\nimport { EthereumRpcError, EthereumProviderError } from 'eth-rpc-errors'\n\n/**\n * getMessageFromCode and errorCodes\n */\nimport { getMessageFromCode, errorCodes } from 'eth-rpc-errors'\n\n// get the default message string for the given code, or a fallback message if\n// no message exists for the given code\nconst message1 = getMessageFromCode(someCode)\n\n// you can specify your own fallback message\nconst message2 = getMessageFromCode(someCode, myFallback)\n// it can be anything, use at your own peril\nconst message3 = getMessageFromCode(someCode, null)\n\n// {\n//   rpc: { [errorName]: code, ... },\n//   provider: { [errorName]: code, ... },\n// }\nconst code1 = errorCodes.rpc.parse\nconst code2 = errorCodes.provider.userRejectedRequest\n\n// all codes in errorCodes have default messages\nconst message4 = getMessageFromCode(code1)\nconst message5 = getMessageFromCode(code2)\n```\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/MetaMask/eth-rpc-errors#readme","bugs":{"url":"https://github.com/MetaMask/eth-rpc-errors/issues"},"license":"MIT"}