npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

@endlesslab/endless-web3-sdk

v1.0.9

Published

endless web3 js sdk

Readme

Endless Web Wallet SDK Usage Guide

Installation

npm install @endlesslab/endless-ts-sdk
npm install @endlesslab/endless-web3-sdk

Import Modules

import {
  Network,
  EntryFunctionABI,
  TypeTagAddress,
  TypeTagU128,
  AccountAddress,
  EndlessConfig,
  Endless,
  AccountAuthenticator,
  Hex,
  Deserializer,
  AccountAuthenticator
} from '@endlesslab/endless-ts-sdk';

import {
  EndlessJsSdk,
  UserResponseStatus,
  EndlessSignAndSubmitTransactionInput,
  EndlessWalletTransactionType,
  EndLessSDKEvent,
} from '@endlesslab/endless-web3-sdk';

SDK Initialization

const jssdk = new EndlessJsSdk({
  // optional: Network.MAINNET
  network: Network.TESTNET,
  // optional: 'dark' | 'light'
  colorMode: 'dark'
});

Wallet Connection

Connect Wallet

const res = await jssdk.connect();
if (res.status === UserResponseStatus.APPROVED) {
  console.log('Account:', res.args.account);
}

Disconnect Wallet

await jssdk.disconnect();
console.log('Disconnect success');

Get Current Account

const res = await jssdk.getAccount();
if (res.status === UserResponseStatus.APPROVED) {
  console.log('Current account:', res.args.account);
}

Signing Features

Sign Message

signMessage({
  nonce: 1,
  message: 'Welcome to dapp!'
})

This would generate the fullMessage to be signed and returned as the signature:

Endless::Message
message: Welcome to dapp!
nonce: 1
export interface EndlessSignMessageInput {
  address?: boolean; // Should we include the address of the account in the message
  application?: boolean; // Should we include the domain of the dapp
  chainId?: boolean; // Should we include the current chain id the wallet is connected to
  message: string; // The message to be signed and displayed to the user
  nonce: string; // A nonce the dapp should generate
}
 
export interface EndlessSignMessageOutput {
  address: string;
  application: string;
  chainId: number;
  fullMessage: string; // The message that was generated to sign
  message: string; // The message passed in by the user
  nonce: string;
  prefix: string; // Should always be Endless::Message
  signature: string; // The signed full message
}

const signMessage = 'Welcome to dapp!';
const res = await jssdk.signMessage({
  address: true, // optional: include address in message
  application: true, // optional: include application in message
  chainId: true, // optional: include chainId in message
  message: signMessage,
  nonce: '1'
});
if (res.status === UserResponseStatus.APPROVED) {
  console.log(res.args);
}

Sign and Submit Transaction

const toAccountAddress = 'xxx';
const transferAmount = 1;
const abi: EntryFunctionABI = {
  typeParameters: [],
  parameters: [new TypeTagAddress(), new TypeTagU128()],
};

const txData: EndlessSignAndSubmitTransactionInput = {
  payload: {
    function: '0x1::endless_account::transfer',
    functionArguments: [
      AccountAddress.fromBs58String(toAccountAddress),
      BigInt(Number(transferAmount) * 1e8),
    ],
    abi,
  },
  // options (optional)
  // This parameter is optional and can be omitted in most cases.
  /* options: {
    maxGasAmount: 100,
    gasUnitPrice: 100,
    expireTimestamp: Math.floor(Date.now() / 1000 + 20),
    accountSequenceNumber: 0
  } */
};

const res = await jssdk.signAndSubmitTransaction(txData);
if (res.status === UserResponseStatus.APPROVED) {
  console.log('Transaction submitted:', res);
}

With Generic Type (typeArguments Required)

If the function uses generics, typeArguments must be provided:

const coinAddress = 'xxx';
const txData: EndlessSignAndSubmitTransactionInput = {
  payload: {
    function: '0x1::endless_account::transfer_coins',
    functionArguments: [
      AccountAddress.fromBs58String(toAccountAddress),
      BigInt(Number(transferAmount) * 1e8),
      coinAddress,
    ],
    typeArguments: ['0x1::fungible_asset::Metadata'],
  },
};

const res = await jssdk.signAndSubmitTransaction(txData);
console.log('transactionRes:', res);

Sign Transaction Only (Without Submit)

const config = new EndlessConfig({ network: Network.TESTNET });
const endless = new Endless(config);

const abi: EntryFunctionABI = {
  typeParameters: [],
  parameters: [new TypeTagAddress(), new TypeTagU128()],
};

const txData: EndlessSignAndSubmitTransactionInput = {
  payload: {
    function: '0x1::endless_account::transfer',
    functionArguments: [
      AccountAddress.fromBs58String(toAccountAddress),
      BigInt(Number(transferAmount) * 1e8),
    ],
    abi,
  },
};

const txn = await endless.transaction.build.simple({
  sender: accountAddress,
  data: txData.payload,
});
const hexTxn = txn.bcsToHex().toString();
const res = await jssdk.signTransaction(hexTxn, EndlessWalletTransactionType.SIMPLE);
if (res.status === UserResponseStatus.APPROVED) {
  const data = Hex.fromHexString(res.args.data).toUint8Array();
  const deserializer = new Deserializer(data);
  const auth = AccountAuthenticator.deserialize(deserializer);
  console.log('AccountAuthenticator:', auth);
}

Change Network

jssdk.changeNetwork({
  network: Network.MAINNET,
});

Change Color Mode (Dark / Light)

jssdk.setWalletColorMode({ colorMode: 'dark' });
jssdk.setWalletColorMode({ colorMode: 'light' });

Event Listeners

jssdk.on(EndLessSDKEvent.CONNECT, (res) => {
  console.log('Wallet connected:', res);
});

jssdk.on(EndLessSDKEvent.DISCONNECT, (res) => {
  console.log('Wallet disconnected:', res);
});

jssdk.on(EndLessSDKEvent.ACCOUNT_CHANGE, (res) => {
  if (res.account) {
    console.log('Account changed:', res);
  }
});

jssdk.on(EndLessSDKEvent.NETWORK_CHANGE, (networkInfo) => {
  console.log('Network changed:', networkInfo);
});

jssdk.on(EndLessSDKEvent.COLOR_MODE_CHANGE, (res) => {
  console.log('Color Mode Change:', res);
});

Optional: UI Panel Open/Close Events

const openHandler = () => {};
jssdk.on(EndLessSDKEvent.OPEN, openHandler);
jssdk.off(EndLessSDKEvent.OPEN, openHandler);

const closeHandler = () => {};
jssdk.on(EndLessSDKEvent.CLOSE, closeHandler);
jssdk.off(EndLessSDKEvent.CLOSE, closeHandler);

Notes

  • All amounts are assumed to be in smallest unit (e.g., 1 EDS = 1e8 units).
  • If ABI is not passed, the SDK will try to auto-resolve it. But if the contract function uses generics, you must pass typeArguments manually.
  • Make sure accountAddress, toAccountAddress, and transferAmount are correctly set before performing transactions.
  • The SDK supports multiple wallet events and operations; use .on() and .off() to bind/unbind custom handlers.
  • Color mode can be configured at initialization or dynamically via setWalletColorMode().
  • To override a user-customized color mode, remove the ENDLESS_WALLET_WEB3_SDK_ENABLETHEME_TOGGLE_KEY from localStorage before calling setWalletColorMode().
import { ENDLESS_WALLET_WEB3_SDK_ENABLETHEME_TOGGLE_KEY } from '@endlesslab/endless-web3-sdk';

localStorage.removeItem(ENDLESS_WALLET_WEB3_SDK_ENABLETHEME_TOGGLE_KEY);
jssdk.setWalletColorMode({ colorMode: 'light' });