{"bugs":{"url":"https://github.com/dfinity/ic-js"},"dist":{"shasum":"c7e9b413ad6efedce178c3ba54a7cef93287a880","tarball":"https://registry.npmjs.org/@dfinity/ledger/-/ledger-0.0.11-next-2023-06-21.tgz","fileCount":41,"integrity":"sha512-uFQHQORClhK8NYXjkAYnFJUeqzh7xCpA1OonBBxQ2yYCoUQTYsbRB+ZO1nQbSuOUTQMPsshrwpcuEfmGbnMuOg==","signatures":[{"sig":"MEUCIQCG5pOGPKUrS2oqjKGHc0kDRo9iLF9+GWGCR7rpy8GbcQIgEhasRBshu4ae658FRHpRQERtvyir3aR+Il8RWHL4BGo=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/@dfinity%2fledger@0.0.11-next-2023-06-21","provenance":{"predicateType":"https://slsa.dev/provenance/v0.2"}},"unpackedSize":131909},"main":"dist/cjs/index.cjs.js","name":"@dfinity/ledger","types":"dist/types/index.d.ts","module":"dist/esm/index.js","readme":"# ledger-js\n\nA library for interfacing with [ICRC ledger](https://github.com/dfinity/ic/tree/master/rs/rosetta-api/icrc1) on the Internet Computer.\n\n[![npm version](https://img.shields.io/npm/v/@dfinity/ledger.svg?logo=npm)](https://www.npmjs.com/package/@dfinity/ledger) [![GitHub license](https://img.shields.io/badge/license-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\n## Table of contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Features](#features)\n- [Resources](#resources)\n\n## Installation\n\nYou can use `ledger-js` by installing it in your project.\n\n```bash\nnpm i @dfinity/ledger\n```\n\nThe bundle needs peer dependencies, be sure that following resources are available in your project as well.\n\n```bash\nnpm i @dfinity/agent @dfinity/candid @dfinity/principal @dfinity/utils\n```\n\n## Usage\n\nThe features are available through the class `LedgerCanister`. It has to be instantiated with a canister ID.\n\ne.g. fetching a token metadata.\n\n```ts\nimport { IcrcLedgerCanister } from \"@dfinity/ledger\";\nimport { createAgent } from \"@dfinity/utils\";\n\nconst agent = await createAgent({\n  identity,\n  host: HOST,\n});\n\nconst { metadata } = LedgerCanister.create({\n  agent,\n  canisterId: MY_LEDGER_CANISTER_ID,\n});\n\nconst data = await metadata();\n```\n\n## Features\n\n`ledger-js` implements following features:\n\n<!-- TSDOC_START -->\n\n### :toolbox: Functions\n\n- [encodeIcrcAccount](#gear-encodeicrcaccount)\n- [decodeIcrcAccount](#gear-decodeicrcaccount)\n\n#### :gear: encodeIcrcAccount\n\nEncodes an Icrc-1 account compatible into a string.\nFormatting Reference: https://github.com/dfinity/ICRC-1/pull/55/files#diff-b335630551682c19a781afebcf4d07bf978fb1f8ac04c6bf87428ed5106870f5R238\n\n| Function            | Type                                              |\n| ------------------- | ------------------------------------------------- |\n| `encodeIcrcAccount` | `({ owner, subaccount, }: IcrcAccount) => string` |\n\nParameters:\n\n- `account`: : Principal, subaccount?: Uint8Array }\n\n#### :gear: decodeIcrcAccount\n\nDecodes a string into an Icrc-1 compatible account.\nFormatting Reference: https://github.com/dfinity/ICRC-1/pull/98\n\n| Function            | Type                                     |\n| ------------------- | ---------------------------------------- |\n| `decodeIcrcAccount` | `(accountString: string) => IcrcAccount` |\n\nParameters:\n\n- `accountString`: string\n\n### :factory: IcrcLedgerCanister\n\n#### Constructors\n\n`public`\n\nParameters:\n\n- `id`\n- `service`\n- `certifiedService`\n\n#### Methods\n\n- [create](#gear-create)\n- [metadata](#gear-metadata)\n- [transactionFee](#gear-transactionfee)\n- [balance](#gear-balance)\n- [transfer](#gear-transfer)\n- [totalTokensSupply](#gear-totaltokenssupply)\n\n##### :gear: create\n\n| Method   | Type                                                                   |\n| -------- | ---------------------------------------------------------------------- |\n| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcLedgerCanister` |\n\n##### :gear: metadata\n\nThe token metadata (name, symbol, etc.).\n\n| Method     | Type                                                          |\n| ---------- | ------------------------------------------------------------- |\n| `metadata` | `(params: QueryParams) => Promise<IcrcTokenMetadataResponse>` |\n\n##### :gear: transactionFee\n\nThe ledger transaction fees.\n\n| Method           | Type                                       |\n| ---------------- | ------------------------------------------ |\n| `transactionFee` | `(params: QueryParams) => Promise<bigint>` |\n\n##### :gear: balance\n\nReturns the balance for a given account provided as owner and with optional subaccount.\n\n| Method    | Type                                         |\n| --------- | -------------------------------------------- |\n| `balance` | `(params: BalanceParams) => Promise<bigint>` |\n\nParameters:\n\n- `params`: The parameters to get the balance of an account.\n\n##### :gear: transfer\n\nTransfers tokens from the sender to the given account.\n\n| Method     | Type                                          |\n| ---------- | --------------------------------------------- |\n| `transfer` | `(params: TransferParams) => Promise<bigint>` |\n\nParameters:\n\n- `params`: The parameters to transfer tokens.\n\n##### :gear: totalTokensSupply\n\nReturns the total supply of tokens.\n\n| Method              | Type                                       |\n| ------------------- | ------------------------------------------ |\n| `totalTokensSupply` | `(params: QueryParams) => Promise<bigint>` |\n\n### :factory: IcrcIndexCanister\n\n#### Constructors\n\n`public`\n\nParameters:\n\n- `id`\n- `service`\n- `certifiedService`\n\n#### Methods\n\n- [create](#gear-create)\n- [getTransactions](#gear-gettransactions)\n\n##### :gear: create\n\n| Method   | Type                                                                  |\n| -------- | --------------------------------------------------------------------- |\n| `create` | `(options: IcrcLedgerCanisterOptions<_SERVICE>) => IcrcIndexCanister` |\n\n##### :gear: getTransactions\n\nGet the transactions of an account\n\nAlways certified.\n`get_account_transactions` needs to be called with an update\nbecause the index canisters makes a call to the ledger canister to get the transaction data.\nIndex Canister only holds the transactions ids in state, not the whole transaction data.\n\n| Method            | Type                                                                 |\n| ----------------- | -------------------------------------------------------------------- |\n| `getTransactions` | `(params: GetAccountTransactionsParams) => Promise<GetTransactions>` |\n\n<!-- TSDOC_END -->\n\n## Resources\n\n- [Ledger & Tokenization Working Group Standards](https://github.com/dfinity/ICRC-1/)\n- [ICRC-1 Ledger](https://github.com/dfinity/ic/tree/master/rs/rosetta-api/icrc1)\n","gitHead":"24aeafabf01aadc67f837649796a44e1f44f47d5","license":"Apache-2.0","scripts":{"test":"jest","build":"npm run rmdir && mkdir -p dist && cp -R candid dist && node esbuild.mjs && npm run ts-declaration","rmdir":"node ../../scripts/rmdir.mjs","prepack":"npm run build","ts-declaration":"tsc --emitDeclarationOnly --outDir dist/types"},"_npmUser":{"name":"bitdivine","email":"bitdivine69@gmail.com"},"homepage":"https://github.com/dfinity/ic-js#readme","keywords":["internet computer","internet-computer","ic","dfinity","Ledger","ICRC-1 ledger","token"],"deprecated":"Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.","repository":{"url":"git+https://github.com/dfinity/ic-js.git","type":"git","directory":"packages/ledger"},"_npmVersion":"9.5.1","description":"A library for interfacing with ICRC ledgers on the Internet Computer.","directories":{},"maintainers":[{"name":"nathan.mcgrath.dfinity","email":"nathan.mcgrath@dfinity.org"},{"name":"frederikrothenberger","email":"frederik.rothenberger@dfinity.org"},{"name":"bitdivine","email":"bitdivine69@gmail.com"},{"name":"ielashi","email":"diner-rodding@ic8.org"},{"name":"liadrit","email":"lia.bajraliu@dfinity.org"},{"name":"dayyildiz","email":"dominik.ayyildiz@dfinity.org"},{"name":"anthony_dfinity","email":"anthony@dfinity.org"},{"name":"eric-swanson-dfinity","email":"eric.swanson@dfinity.org"},{"name":"krpeacock","email":"kylpeacock@gmail.com"},{"name":"terrorjack","email":"astrohavoc@gmail.com"},{"name":"npm-dfinity-org","email":"npm@dfinity.org"}],"_nodeVersion":"18.16.0","_hasShrinkwrap":false,"readmeFilename":"README.md","peerDependencies":{"@dfinity/agent":"*","@dfinity/utils":"*","@dfinity/candid":"*","@dfinity/principal":"*"},"_npmOperationalInternal":{"tmp":"tmp/ledger_0.0.11-next-2023-06-21_1687343966326_0.3998518516381835","host":"s3://npm-registry-packages"},"_id":"@dfinity/ledger@0.0.11-next-2023-06-21","version":"0.0.11-next-2023-06-21"}