{"_id":"@atlaschain/rpc","name":"@atlaschain/rpc","dist-tags":{"latest":"3.0.0"},"versions":{"3.0.0":{"name":"@atlaschain/rpc","version":"3.0.0","description":"A library for sending JSON RPC requests to Atlas RPCs","exports":{"edge-light":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"workerd":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"browser":{"import":"./dist/index.browser.mjs","require":"./dist/index.browser.cjs"},"node":{"import":"./dist/index.node.mjs","require":"./dist/index.node.cjs"},"react-native":"./dist/index.native.mjs","types":"./dist/types/index.d.ts"},"browser":{"./dist/index.node.cjs":"./dist/index.browser.cjs","./dist/index.node.mjs":"./dist/index.browser.mjs"},"main":"./dist/index.node.cjs","module":"./dist/index.node.mjs","react-native":"./dist/index.native.mjs","types":"./dist/types/index.d.ts","type":"commonjs","sideEffects":false,"keywords":["blockchain","atlas","web3"],"author":{"name":"Atlas Chain Foundation"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/anza-xyz/kit.git"},"bugs":{"url":"https://github.com/anza-xyz/kit/issues"},"browserslist":["supports bigint and not dead","maintained node versions"],"dependencies":{"@atlaschain/fast-stable-stringify":"3.0.0","@atlaschain/functional":"3.0.0","@atlaschain/rpc-spec-types":"3.0.0","@atlaschain/rpc-api":"3.0.0","@atlaschain/rpc-transformers":"3.0.0","@atlaschain/rpc-spec":"3.0.0","@atlaschain/rpc-transport-http":"3.0.0","@atlaschain/rpc-types":"3.0.0","@atlaschain/errors":"3.0.0"},"peerDependencies":{"typescript":">=5.3.3"},"engines":{"node":">=20.18.0"},"scripts":{"compile:docs":"typedoc","compile:js":"tsup --config build-scripts/tsup.config.package.ts","compile:typedefs":"tsc -p ./tsconfig.declarations.json","dev":"jest -c ../../node_modules/@atlaschain/test-config/jest-dev.config.ts --rootDir . --watch","publish-impl":"npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || (pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks && (([ -n \"${GITHUB_OUTPUT:-}\" ] && echo 'published=true' >> \"$GITHUB_OUTPUT\") || true) && (([ \"$PUBLISH_TAG\" != \"canary\" ] && ../build-scripts/maybe-tag-latest.ts $npm_package_name@$npm_package_version) || true))","publish-packages":"pnpm prepublishOnly && pnpm publish-impl","style:fix":"pnpm eslint --fix src && pnpm prettier --log-level warn --ignore-unknown --write ./*","test:lint":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-lint.config.ts --rootDir . --silent","test:prettier":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-prettier.config.ts --rootDir . --silent","test:treeshakability:browser":"agadoo dist/index.browser.mjs","test:treeshakability:native":"agadoo dist/index.native.mjs","test:treeshakability:node":"agadoo dist/index.node.mjs","test:typecheck":"tsc --noEmit","test:unit:browser":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-unit.config.browser.ts --rootDir . --silent","test:unit:node":"TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@atlaschain/test-config/jest-unit.config.node.ts --rootDir . --silent"},"_id":"@atlaschain/rpc@3.0.0","homepage":"https://github.com/anza-xyz/kit#readme","_integrity":"sha512-A8hGAFLcsCNhjF3HJ9tKiH+QNqf4HpKZLAAC0CZdzzBUAXPGF1ZLkb3JRyFrJ3cHzMJyufkwsyuzxmh4MltzYA==","_resolved":"/private/var/folders/q8/nr55p0wd491c6fjmbky17kd00000gn/T/5c2a17b4572098023f86f2b367616286/atlaschain-rpc-3.0.0.tgz","_from":"file:atlaschain-rpc-3.0.0.tgz","_nodeVersion":"22.12.0","_npmVersion":"10.9.0","dist":{"integrity":"sha512-A8hGAFLcsCNhjF3HJ9tKiH+QNqf4HpKZLAAC0CZdzzBUAXPGF1ZLkb3JRyFrJ3cHzMJyufkwsyuzxmh4MltzYA==","shasum":"890b4833c2c7eebfe546fb3f792994f8c2597fec","tarball":"https://registry.npmjs.org/@atlaschain/rpc/-/rpc-3.0.0.tgz","fileCount":5,"unpackedSize":18605,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCKxZedxU23MJvJWeXEMtQBpf+ONlXLPBF7LW4GV4+x1wIhAL/VM2bmJUb3nmG/rtRwkgp/YWYG28xYxrEW4EUq6A2Y"}]},"_npmUser":{"name":"atlaschain","email":"jq@atlaschain.org"},"directories":{},"maintainers":[{"name":"atlaschain","email":"jq@atlaschain.org"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/rpc_3.0.0_1764611552323_0.9031443041668568"},"_hasShrinkwrap":false}},"time":{"created":"2025-12-01T17:52:32.268Z","3.0.0":"2025-12-01T17:52:32.538Z","modified":"2025-12-01T17:52:32.773Z"},"maintainers":[{"name":"atlaschain","email":"jq@atlaschain.org"}],"description":"A library for sending JSON RPC requests to Atlas RPCs","homepage":"https://github.com/anza-xyz/kit#readme","keywords":["blockchain","atlas","web3"],"repository":{"type":"git","url":"git+https://github.com/anza-xyz/kit.git"},"author":{"name":"Atlas Chain Foundation"},"bugs":{"url":"https://github.com/anza-xyz/kit/issues"},"license":"MIT","readme":"[![npm][npm-image]][npm-url]\n[![npm-downloads][npm-downloads-image]][npm-url]\n<br />\n[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]\n\n[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square\n[code-style-prettier-url]: https://github.com/prettier/prettier\n[npm-downloads-image]: https://img.shields.io/npm/dm/@atlas/rpc?style=flat\n[npm-image]: https://img.shields.io/npm/v/@atlas/rpc?style=flat\n[npm-url]: https://www.npmjs.com/package/@atlas/rpc\n\n# @atlas/rpc\n\nThis package contains utilities for creating objects that you can use to communicate with a Atlas JSON RPC server. It can be used standalone, but it is also exported as part of Kit [`@atlas/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).\n\nUnless you plan to create a custom RPC interface, you can use the [`createAtlasRpc(clusterUrl)`](#createatlasrpcclusterurl-config) function to obtain a default implementation of the [Atlas JSON RPC API](https://atlas.com/docs/rpc/http).\n\n## Types\n\n### `RpcTransport{Devnet|Testnet|Mainnet}`\n\nThese types refine the base `RpcTransport` type. Each describes a transport that is specific in some way to a particular Atlas cluster.\n\nFor instance, a `RpcTransportDevnet` is understood to communicate with a RPC server related to devnet, and as such might only be accepted for use as the transport of a `RpcDevnet`.\n\nThis is useful in cases where you need to make assertions about what capabilities a RPC offers. For example, RPC methods like `requestAirdrop` are not available on mainnet. You can use the ability to assert on the type of RPC transport at compile time to prevent calling unimplemented methods or presuming the existence of unavailable capabilities.\n\n### `RpcTransportFromClusterUrl<TClusterUrl extends ClusterUrl>`\n\nGiven a `ClusterUrl`, this utility type will resolve to as specific a `RpcTransport` as possible.\n\n```ts\nfunction createCustomTransport<TClusterUrl extends ClusterUrl>(\n    clusterUrl: TClusterUrl,\n): RpcTransportFromClusterUrl<TClusterUrl> {\n    /* ... */\n}\nconst transport = createCustomTransport(testnet('http://api.testnet.atlas.com'));\ntransport satisfies RpcTransportTestnet; // OK\n```\n\n### `Rpc{Devnet|Testnet|Mainnet}<TRpcMethods>`\n\nThese types refine the base `Rpc` type. Each describes a RPC that is specific in some way to a particular Atlas cluster and a corpus of RPC methods.\n\nThis is useful in cases where you need to make assertions about the suitability of a RPC for a given purpose. For example, you might like to make it a type error to combine certain types with RPCs belonging to certain clusters, at compile time.\n\n```ts\nasync function getSpecialAccountInfo(\n    address: Address<'ReAL1111111111111111111111111111'>,\n    rpc: RpcMainnet<unknown>,\n): Promise<SpecialAccountInfo>;\nasync function getSpecialAccountInfo(\n    address: Address<'TeST1111111111111111111111111111'>,\n    rpc: RpcDevnet<unknown> | RpcTestnet<unknown>,\n): Promise<SpecialAccountInfo>;\nasync function getSpecialAccountInfo(address: Address, rpc: Rpc<unknown>): Promise<SpecialAccountInfo> {\n    /* ... */\n}\nconst rpc = createAtlasRpc(devnet('https://api.devnet.atlas.com'));\nawait getSpecialAccountInfo(address('ReAL1111111111111111111111111111'), rpc); // ERROR\n```\n\n### `RpcFromTransport<TRpcMethods, TRpcTransport extends RpcTransport>`\n\nGiven a `RpcTransport` and a set of RPC methods denoted by `TRpcMethods` this utility type will resolve to a `Rpc` that supports those methods on as specific a cluster as possible.\n\n```ts\nfunction createCustomRpc<TRpcTransport extends RpcTransport>(\n    transport: TRpcTransport,\n): RpcFromTransport<MyCustomRpcMethods, TRpcTransport> {\n    /* ... */\n}\nconst transport = createDefaultRpcTransport({ url: mainnet('http://rpc.company') });\ntransport satisfies RpcTransportMainnet; // OK\nconst rpc = createCustomRpc(transport);\nrpc satisfies RpcMainnet<MyCustomRpcMethods>; // OK\n```\n\n### AtlasRpcApiFromTransport<TTransport extends RpcTransport>\n\nGiven a `RpcTransport` this utility type will resolve to a union of all the methods of the Atlas RPC API supported by the transport's cluster.\n\n```ts\nfunction createAtlasRpcFromTransport<TTransport extends RpcTransport>(\n    transport: TTransport,\n): RpcFromTransport<AtlasRpcApiFromTransport<TTransport>, TTransport> {\n    /* ... */\n}\nconst transport = createDefaultRpcTransport({ url: mainnet('http://rpc.company') });\ntransport satisfies RpcTransportMainnet; // OK\nconst rpc = createAtlasRpcFromTransport(transport);\nrpc satisfies RpcMainnet<AtlasRpcApiMainnet>; // OK\n```\n\n## Constants\n\n### `DEFAULT_RPC_CONFIG`\n\nWhen you create `Rpc` instances with custom transports but otherwise the default RPC API behaviours, use this.\n\n```ts\nconst myCustomRpc = createRpc({\n    api: createAtlasRpcApi(DEFAULT_RPC_CONFIG),\n    transport: myCustomTransport,\n});\n```\n\n## Functions\n\n### `createDefaultRpcTransport(config)`\n\nCreates a `RpcTransport` with some default behaviours.\n\nThe default behaviours include:\n\n- An automatically-set `Atlas-Client` request header, containing the version of `@atlas/kit`\n- Logic that coalesces multiple calls in the same runloop, for the same methods with the same arguments, into a single network request.\n- [node-only] An automatically-set `Accept-Encoding` request header asking the server to compress responses\n\n#### Arguments\n\nA config object with the following properties:\n\n- `dispatcher_NODE_ONLY`: An optional `Undici.Dispatcher` instance that governs how the networking stack should behave. This option is only relevant in Node applications. Consult the documentation for the various subclasses of `Undici.Dispatcher`, such as `Agent`, `Client`, and `Pool`, at https://undici.nodejs.org/#/docs/api/Client.\n- `headers`: An optional object where the keys are HTTP header names and the values are HTTP header values. This parameter is typed to disallow certain headers from being overwritten.\n- `url`: A `ClusterUrl` at which the RPC server can be contacted.\n\n### `createAtlasRpc(clusterUrl, config)`\n\nCreates a `Rpc` instance that exposes the Atlas JSON RPC API given a cluster URL and some optional transport config. See `createDefaultRpcTransport` for the shape of the transport config.\n\n### `createAtlasRpcFromTransport(transport)`\n\nCreates a `Rpc` instance that exposes the Atlas JSON RPC API given the supplied `RpcTransport`.\n","readmeFilename":"README.md","_rev":"1-e90254fae95f36a7c466db41213990cc"}