1.0.44 • Published 4 months ago

endless-ts-sdk v1.0.44

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
4 months ago

Typescript SDK for Endless

Reference Docs

  1. For SDK documentation, check out the TypeScript SDK documentation
  2. For in-depth examples, check out the examples folder with ready-made package.json files to get you going quickly!

The Endless TypeScript SDK provides a convenient way to interact with the Endless blockchain using TypeScript. It offers a set of utility functions, classes, and types to simplify the integration process and enhance developer productivity.

This repository supports version >= 0.0.0 of the Endless SDK npm package.

Installation

For use in Node.js or a web application

Install with your favorite package manager such as npm, yarn, or pnpm:

pnpm install endless-ts-sdk

Usage

Initialize Endless to access the SDK API.

// initiate the main entry point into Endless SDK
const endless = new Endless();

If you want to pass in a custom config

// an optional config information for the SDK client instance.
const config = new EndlessConfig({
  network: Network.LOCAL,
  // If it is a mini program environment, set miniprogram to true
  // miniprogram: true
}); // default network is devnet
const endless = new Endless(config);

Account management (default to Ed25519)

Note: We introduce a Single Sender authentication. Generating an account defaults to Legacy Ed25519 authentication with the option to use the Single Sender unified authentication

Generate new keys

const account = Account.generate(); // defaults to Legacy Ed25519

Derive from private key

// Create a private key instance for Ed25519 scheme
const privateKey = new Ed25519PrivateKey("myEd25519privatekeystring");

// Derive an account from private key

// This is used as a local calculation and therefore is used to instantiate an `Account`
// that has not had its authentication key rotated
const account = await Account.fromPrivateKey({ privateKey });

Derive from private key and address

// Create a private key instance for Ed25519 scheme
const privateKey = new Ed25519PrivateKey("myEd25519privatekeystring");

Derive from path

const path = "m/44'/637'/0'/0'/1";
const mnemonic = "various float stumble...";
const account = Account.fromDerivationPath({ path, mnemonic });

Submit transaction


Single Signer transaction

Using transaction submission api

const alice: Account = Account.generate();
const bobAddress = "0xb0b";
// build transaction
const transaction = await endless.transaction.build.simple({
  sender: alice.accountAddress,
  data: {
    function: "0x1::coin::transfer",
    typeArguments: ["0x1::endless_coin::EndlessCoin"],
    functionArguments: [bobAddress, 100],
  },
});

// using sign and submit separately
const senderAuthenticator = endless.transaction.sign({ signer: alice, transaction });
const committedTransaction = await endless.transaction.submit.simple({ transaction, senderAuthenticator });

// using signAndSubmit combined
const committedTransaction = await endless.signAndSubmitTransaction({ signer: alice, transaction });

Using built in transferCoinTransaction

const alice: Account = Account.generate();
const bobAddress = "0xb0b";
// build transaction
const transaction = await endless.transferCoinTransaction({
  sender: alice,
  recipient: bobAddress,
  amount: 100,
});

const pendingTransaction = await endless.signAndSubmitTransaction({ signer: alice, transaction });

Troubleshooting

If you see import error when you do this

import { Endless, EndlessConfig, Network } from "endless-ts-sdk";

It could be your tsconfig.json is not incompatible, make sure your moduleResolution is set to node instead of bundler.

1.0.44

4 months ago

1.0.43

4 months ago

1.0.42

5 months ago

1.0.41

6 months ago

1.0.40

7 months ago

1.0.39

7 months ago

1.0.38

7 months ago

1.0.37

7 months ago

1.0.36

7 months ago

1.0.35

8 months ago

1.0.34

8 months ago

1.0.29

10 months ago

1.0.33

9 months ago

1.0.31

10 months ago

1.0.28

10 months ago

1.0.27

10 months ago

1.0.26

10 months ago

1.0.2

11 months ago

1.0.1

11 months ago

1.0.3

11 months ago

0.1.12

11 months ago

0.1.8

11 months ago

0.1.7

11 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.1

1 year ago