JSPM

  • Created
  • Published
  • Downloads 86234
  • Score
    100M100P100Q54934F
  • License Apache-2.0

Aptos SDK

Package Exports

  • aptos
  • aptos/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (aptos) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Aptos TS/JS SDK

Discord NPM Package Version NPM Package Downloads

You need to connect to an Aptos node to use this library, or run one yourself locally.

Please read the [documentation][docs] for more.

Usage

// In Node.js
const Aptos = require("aptos");

const aptos = new AptosClient("https://fullnode.devnet.aptoslabs.com/");
console.log(aptos);
> { ... }

There you go, now you can use it:

const account = new AptosAccount();
const accountInfo = await client.getAccount(account.address());

Usage with TypeScript

You can use aptos like any other TypeScript module:

import { AptosAccount, AptosClient } from "aptos"
const aptos = new AptosClient("https://fullnode.devnet.aptoslabs.com/");
const account = new AptosAccount();
const accountInfo = await client.getAccount(account.address());

If you are using the types in a commonjs module, like in a Node app, you just have to enable esModuleInterop and allowSyntheticDefaultImports in your tsconfig for types compatibility:

"compilerOptions": {
  "allowSyntheticDefaultImports": true, 
  "esModuleInterop": true,
  ...

Requirements

sudo apt-get update
sudo apt-get install nodejs yarn

Generating Types

Originally created with this:

$  npx swagger-typescript-api -p ../api/doc/openapi.yaml -o ./src/api --modular --axios --single-http-client

Changes to make after generation:

  • OpenAPI/SpecHTML routes/types deleted as they're unneeded.
  • There are a few type errors in the http-client.ts as the axios types are incomplete, that were fixed via // @ts-ignore

Testing (jest)

yarn test

Semantic versioning

This project follows semver as closely as possible