TypeScript SDK

Endless TypeScript SDK

Overview

Endless provides a fully supported TypeScript SDK with the source code in the endless-ts sdk Github repository. 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.

  • Developer experience Strongly typed APIs and Interfaces, autocomplete, comprehensive documentation.

  • Stability Test suite runs against Endless fullnode and indexer with a local network

  • Transaction Builder Intuitive and simplified transaction builder flow

  • Serialization/deserialization support Full nested serialization/deserialization support and Move sub-classes to easily serialize and deserialize Move types

Installation

 pnpm i @endlesslab/endless-ts-sdk
 npm i @endlesslab/endless-ts-sdk
 yarn add @endlesslab/endless-ts-sdk

Quick Start

Set up Endless

import { Account, AccountAddress, Endless, EndlessConfig, Network } from "@endlesslab/endless-ts-sdk";

const endless = new Endless(); // default to devnet

// with custom configuration
const endlessConfig = new EndlessConfig({ network: Network.TESTNET });
const endless = new Endless(endlessConfig);

Generate new Account

const alice = Account.generate();
const bob = Account.generate();

Faucet Alice

const fund_tx = await endless.fundAccount({ signer: alice });
await endless.waitForTransaction({ transactionHash: fund_tx.hash });

Fetch balance from chain

const balance = await endless.viewEDSBalance(alice.accountAddress);
console.log("alice balance:", balance);

Transfer EDS coin transaction

const transaction = await endless.transferEDS({
  sender: alice,
  recipient: bob.accountAddress,
  amount: 1000000,
});
const pendingTransaction = await endless.signAndSubmitTransaction({
  signer: alice,
  transaction,
});

Build and submit transaction

const transaction = await endless.transaction.build.simple({
  sender: alice.accountAddress,
  data: {
    function: "0x1::endless_account::transfer",
    typeArguments: [],
    functionArguments: [bob.accountAddress, 100],
  },
});

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

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

Last updated