TypeScript SDK Example Code
For sample code which explains the core concepts of how to use the SDK, see:
Below are additional resources which may be more suited for your individual use case.
Code Snippets
The examples folder in the SDK repo has dozens of code snippets you can customize to your needs.
How to run examples
To run one of the example scripts:
Clone the aptos-ts-sdk repository
Terminal
git clone https://github.com/aptos-labs/aptos-ts-sdk.gitFrom the top-level of the package, install all dependencies.
Terminal
pnpm installBuild the package.
Terminal
pnpm buildGo to the folder of an example you would like to run.
Terminal
cd examples/typescriptInstall local dependencies.
Terminal
pnpm installRun the example.
Terminal
pnpm run simple_transferHelpful Reference Code
- The SDK’s end-to-end tests - This has the most comprehensive set of code that uses the SDK.
- SDK source code - This has in-line comments explaining what each function does.
- SDK reference docs - These are another way to view the in-line documentation with built-in search.