{"_id":"f-aptos-ts-sdk","name":"f-aptos-ts-sdk","dist-tags":{"latest":"1.11.0"},"versions":{"1.11.0":{"name":"f-aptos-ts-sdk","description":"Aptos TypeScript SDK","packageManager":"pnpm@8.9.0","license":"Apache-2.0","engines":{"node":">=11.0.0"},"bugs":{"url":"https://github.com/aptos-labs/aptos-ts-sdk/issues/new/choose"},"homepage":"https://aptos-labs.github.io/aptos-ts-sdk/","main":"dist/common/index.js","module":"dist/esm/index.mjs","exports":{".":{"source":"./src/index.ts","require":{"types":"./dist/common/index.d.ts","default":"./dist/common/index.js"},"import":{"types":"./dist/esm/index.d.mts","default":"./dist/esm/index.mjs"}},"./package.json":"./package.json"},"scripts":{"build:clean":"rm -rf dist","build":"pnpm build:clean && tsup","_fmt":"prettier 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.js' 'examples/**/*.ts' '.eslintrc.js'","fmt":"pnpm _fmt --write","lint":"eslint 'src/**/*.ts' 'tests/**/*.ts' 'examples/**/*.ts'","test":"pnpm jest","unit-test":"pnpm jest tests/unit","e2e-test":"pnpm jest tests/e2e","indexer-codegen":"graphql-codegen --config ./src/types/codegen.yaml && pnpm fmt","doc":"scripts/generateDocs.sh","check-version":"scripts/checkVersion.sh","update-version":"scripts/updateVersion.sh && pnpm doc"},"dependencies":{"@aptos-labs/aptos-client":"^0.1.0","@noble/curves":"^1.2.0","@noble/hashes":"^1.3.3","@scure/bip32":"^1.3.3","@scure/bip39":"^1.2.1","@simplewebauthn/browser":"^9.0.1","eventemitter3":"^5.0.1","form-data":"^4.0.0","tweetnacl":"^1.0.3"},"devDependencies":{"@aptos-labs/aptos-cli":"^0.1.2","@babel/traverse":"^7.23.6","@graphql-codegen/cli":"^5.0.0","@graphql-codegen/import-types-preset":"^3.0.0","@graphql-codegen/typescript":"^4.0.1","@graphql-codegen/typescript-graphql-request":"^6.0.1","@graphql-codegen/typescript-operations":"^4.0.1","@types/jest":"^29.5.11","@types/node":"^20.10.4","@typescript-eslint/eslint-plugin":"^6.14.0","@typescript-eslint/parser":"^6.14.0","dotenv":"^16.3.1","eslint":"^8.55.0","eslint-config-airbnb-base":"^15.0.0","eslint-config-airbnb-typescript":"^17.1.0","eslint-config-prettier":"^9.1.0","eslint-plugin-import":"^2.29.0","graphql":"^16.8.1","graphql-request":"^6.1.0","jest":"^29.7.0","prettier":"^3.1.1","tree-kill":"^1.2.2","ts-jest":"^29.1.1","ts-loader":"^9.5.1","ts-node":"^10.9.2","tsup":"^8.0.1","typedoc":"^0.25.4","typescript":"^5.3.3"},"version":"1.11.0","_id":"f-aptos-ts-sdk@1.11.0","gitHead":"c76b474d215a32fed71a2a00e0d8c5e1d74ed55c","types":"./dist/common/index.d.ts","_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-Vh27RU9vvdsnBabNuLur3Vm6SOS2bGFTFTTv4nBumZpdA+yNlHV3R/7xNyCDgxovikMANv8DpBsWf0o/YatPIg==","shasum":"a62d761f7f1106367cbd813fd298f5cfcf7c6b45","tarball":"https://registry.npmjs.org/f-aptos-ts-sdk/-/f-aptos-ts-sdk-1.11.0.tgz","fileCount":660,"unpackedSize":4792842,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAyL/n1C1wNa+c4Y7/XSCsF/cW4AQw+ZgyDiH391FaSeAiEA+T1/uDvKBlzMgYF9pujNhB/xxLe+uOeosK71RJlEk1I="}]},"_npmUser":{"name":"frostynova","email":"frostynova@gmail.com"},"directories":{},"maintainers":[{"name":"frostynova","email":"frostynova@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/f-aptos-ts-sdk_1.11.0_1711770432538_0.8000219588222244"},"_hasShrinkwrap":false}},"time":{"created":"2024-03-30T03:47:12.537Z","1.11.0":"2024-03-30T03:47:12.846Z","modified":"2024-03-30T03:47:13.111Z"},"maintainers":[{"name":"frostynova","email":"frostynova@gmail.com"}],"description":"Aptos TypeScript SDK","homepage":"https://aptos-labs.github.io/aptos-ts-sdk/","bugs":{"url":"https://github.com/aptos-labs/aptos-ts-sdk/issues/new/choose"},"license":"Apache-2.0","readme":"# Typescript SDK for Aptos\n\n![License][github-license]\n[![Discord][discord-image]][discord-url]\n[![NPM Package Downloads][npm-image-downloads]][npm-url]\n\n### Latest Version\n\n[![NPM Package Version][npm-image-version]][npm-url]\n![Node Version](https://img.shields.io/node/v/%40aptos-labs%2Fts-sdk)\n![NPM bundle size](https://img.shields.io/bundlephobia/min/%40aptos-labs/ts-sdk)\n\n### Experimental Development Version\n\n[![NPM Experimental Version](https://img.shields.io/npm/v/%40aptos-labs/ts-sdk/experimental)][experimental-url]\n![Experimental Node Version](https://img.shields.io/node/v/%40aptos-labs%2Fts-sdk/experimental)\n![Experimental bundle size](https://img.shields.io/bundlephobia/min/%40aptos-labs/ts-sdk/experimental)\n\nThe Aptos TypeScript SDK provides a convenient way to interact with the Aptos blockchain using TypeScript. It offers a\nset of utility functions, classes, and types to simplify the integration process and enhance developer productivity.\n\nThis repository supports version >= 0.0.0 of the [Aptos SDK npm package](https://www.npmjs.com/package/@aptos-labs/ts-sdk).\n\n## Installation\n\n##### For use in Node.js or a web application\n\nInstall with your favorite package manager such as npm, yarn, or pnpm:\n\n```bash\npnpm install @aptos-labs/ts-sdk\n```\n\n##### For use in a browser (<= 1.9.1 version only)\n\nYou can add the SDK to your web application using a script tag:\n\n```html\n<script src=\"https://unpkg.com/@aptos-labs/ts-sdk/dist/browser/index.global.js\" />\n```\n\nThen, the SDK can be accessed through `window.aptosSDK`.\n\n## Usage\n\nInitialize `Aptos` to access the SDK API.\n\n```ts\n// initiate the main entry point into Aptos SDK\nconst aptos = new Aptos();\n```\n\nIf you want to pass in a custom config\n\n```ts\n// an optional config information for the SDK client instance.\nconst config = new AptosConfig({ network: Network.LOCAL }); // default network is devnet\nconst aptos = new Aptos(config);\n```\n\n### Read data from chain\n\n---\n\n```ts\nconst modules = await aptos.getAccountModules({ accountAddress: \"0x123\" });\n```\n\n### Account management (default to Ed25519)\n\n> Note: We introduce a Single Sender authentication (as introduced in [AIP-55](https://github.com/aptos-foundation/AIPs/pull/263)). Generating an account defaults to Legacy Ed25519 authentication with the option to use the Single Sender unified authentication\n\n---\n\n#### Generate new keys\n\n```ts\nconst account = Account.generate(); // defaults to Legacy Ed25519\nconst account = Account.generate({ scheme: SigningSchemeInput.Secp256k1Ecdsa }); // Single Sender Secp256k1\nconst account = Account.generate({ scheme: SigningSchemeInput.Ed25519, legacy: false }); // Single Sender Ed25519\n```\n\n#### Derive from private key\n\n```ts\n// Create a private key instance for Ed25519 scheme\nconst privateKey = new Ed25519PrivateKey(\"myEd25519privatekeystring\");\n// Or for Secp256k1 scheme\nconst privateKey = new Secp256k1PrivateKey(\"mySecp256k1privatekeystring\");\n\n// Derive an account from private key\n\n// This is used as a local calculation and therefore is used to instantiate an `Account`\n// that has not had its authentication key rotated\nconst account = await Account.fromPrivateKey({ privateKey });\n\n// Also, can use this function that resolves the provided private key type and derives the public key from it\n// to support key rotation and differentiation between Legacy Ed25519 and Unified authentications\n// Read more https://github.com/aptos-labs/aptos-ts-sdk/blob/main/src/api/account.ts#L364\nconst aptos = new Aptos();\nconst account = await aptos.deriveAccountFromPrivateKey({ privateKey });\n```\n\n#### Derive from private key and address\n\n```ts\n// Create a private key instance for Ed25519 scheme\nconst privateKey = new Ed25519PrivateKey(\"myEd25519privatekeystring\");\n// Or for Secp256k1 scheme\nconst privateKey = new Secp256k1PrivateKey(\"mySecp256k1privatekeystring\");\n\n// Derive an account from private key and address\n\n// create an AccountAddress instance from the account address string\nconst address = AccountAddress.from(\"myaccountaddressstring\");\n// Derieve an account from private key and address\nconst account = await Account.fromPrivateKeyAndAddress({ privateKey, address });\n```\n\n#### Derive from path\n\n```ts\nconst path = \"m/44'/637'/0'/0'/1\";\nconst mnemonic = \"various float stumble...\";\nconst account = Account.fromDerivationPath({ path, mnemonic });\n```\n\n### Submit transaction\n\n---\n\n#### Single Signer transaction\n\nUsing transaction submission api\n\n```ts\nconst alice: Account = Account.generate();\nconst bobAddress = \"0xb0b\";\n// build transaction\nconst transaction = await aptos.transaction.build.simple({\n  sender: alice.accountAddress,\n  data: {\n    function: \"0x1::coin::transfer\",\n    typeArguments: [\"0x1::aptos_coin::AptosCoin\"],\n    functionArguments: [bobAddress, 100],\n  },\n});\n\n// using sign and submit separately\nconst senderAuthenticator = aptos.transaction.sign({ signer: alice, transaction });\nconst committedTransaction = await aptos.transaction.submit.simple({ transaction, senderAuthenticator });\n\n// using signAndSubmit combined\nconst committedTransaction = await aptos.signAndSubmitTransaction({ signer: alice, transaction });\n```\n\nUsing built in `transferCoinTransaction`\n\n```ts\nconst alice: Account = Account.generate();\nconst bobAddress = \"0xb0b\";\n// build transaction\nconst transaction = await aptos.transferCoinTransaction({\n  sender: alice,\n  recipient: bobAddress,\n  amount: 100,\n});\n\nconst pendingTransaction = await aptos.signAndSubmitTransaction({ signer: alice, transaction });\n```\n\n## Documentation and examples\n\n- For full SDK documentation, check out the [TypeScript SDK documentation](https://aptos.dev/sdks/new-ts-sdk/)\n- For reference documenation, check out the [API reference documentation](https://aptos-labs.github.io/aptos-ts-sdk/) for the associated version.\n- For in-depth examples, check out the [examples](./examples) folder with ready-made `package.json` files to get you going quickly!\n\n### Testing\n\nTo run the SDK tests, simply run from the root of this repository:\n\n> Note: for a better experience, make sure there is no aptos local node process up and running (can check if there is a process running on port 8080).\n\n```bash\npnpm i\npnpm test\n```\n\n## Troubleshooting\n\nIf you see import error when you do this\n\n```typescript\nimport { Aptos, AptosConfig, Network } from \"@aptos-labs/ts-sdk\";\n```\n\nIt could be your `tsconfig.json` is not incompatible, make sure your `moduleResolution` is set to `node` instead of `bundler`.\n\n## Contributing\n\nIf you found a bug or would like to request a feature, please file an [issue](https://github.com/aptos-labs/aptos-ts-sdk/issues/new/choose).\nIf, based on the discussion on an issue you would like to offer a code change, please make a [pull request](https://github.com/aptos-labs/aptos-ts-sdk/CONTRIBUTING.md).\nIf neither of these describes what you would like to contribute, checkout out the [contributing guide](https://github.com/aptos-labs/aptos-ts-sdk/CONTRIBUTING.md).\n\n[npm-image-version]: https://img.shields.io/npm/v/%40aptos-labs%2Fts-sdk.svg\n[npm-image-downloads]: https://img.shields.io/npm/dm/%40aptos-labs%2Fts-sdk.svg\n[npm-url]: https://npmjs.org/package/@aptos-labs/ts-sdk\n[experimental-url]: https://www.npmjs.com/package/@aptos-labs/ts-sdk/v/experimental\n[discord-image]: https://img.shields.io/discord/945856774056083548?label=Discord&logo=discord&style=flat~~~~\n[discord-url]: https://discord.gg/aptosnetwork\n[github-license]: https://img.shields.io/github/license/aptos-labs/aptos-ts-sdk\n[discord-url]: https://discord.gg/aptosnetwork\n","readmeFilename":"README.md"}