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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@ditto-research/staking-sdk

v0.6.0

Published

Ditto SDK

Readme

SDK

Smart contract address

| Network | Value | | ------- | :------------------------------------------------------------------: | | Devnet | 0x6567b43f1448e03430c4cac31a337d8d96d136a23063a6d2bf5db52b35109338 | | Testnet | 0x6567b43f1448e03430c4cac31a337d8d96d136a23063a6d2bf5db52b35109338 |

How to use it

Basic functionality

Loading ditto state

import * as aptos from "aptos";
import {
  Ditto,
  Client,
  types,
  utils,
  wallet,
  payload,
} from "@ditto-research/staking-sdk";

// Load the Ditto object singleton, needed to do all operations with the SDK
await Ditto.load(
  new wallet.DummyWallet(), // Wallet object
  types.Network.DEVNET,
  "https://fullnode.devnet.aptoslabs.com/v1", // REST url endpoint
  new aptos.HexString(SMART_CONTRACT_ADDRESS),
  5000 // Txn confirmation timeout - unused for now
);

Create a local node wallet

// Parameters for your aptos transactions.
const DEFAULT_TXN_CONFIG: types.AptosTxnConfig = {
  maxGasAmount: 1000n,
  gasUnitPrice: 1n,
  txnExpirationOffset: 10n,
};

let wallet: wallet.DittoWallet = new wallet.DittoWallet(
  new aptos.HexString(USER_PRIVATE_KEY),
  DEFAULT_TXN_CONFIG
);

Using a wallet adapter

The SDK's Client constructor just expects a wallet that implements this interface.

// All objects that implement this interface (including wallet adapter).
export interface Wallet {
  account: AccountKeys;
  signAndSubmitTransaction(transaction: any): Promise<any>;
  signTransaction(transaction: any): Promise<any>;
}

Creating a ditto client

// Any wallet object implementing the interface can be passed in.
let client = new Client(wallet, types.Network.DEVNET, 5000);

// Example of how to stake aptos:
let txResponse = await client.stakeAptos(STAKE_AMOUNT);

// These functions will return an object of type -
// interface TxnResponse {
//  hash: string; // The txn hash
//  msg: string; // Whether the transaction was successful
// }

console.log(`Stake aptos txn reponse =`, txResponse);

// How to instant unstake stAPT (subject to instant unstake fee).
await client.instantUnstake(<amount>);

// *** Note delayed unstake and claim functionality is not available on devnet ***.
// How to delayed unstake stAPT.
await client.delayedUnstake(<amount>);

// View user delayed unstake state.
let userClaimState = await Ditto.getUserClaimStateFromTable(client.address);

// How to claim processed delayed unstake tickets.
await client.claimAptos();

// For the rest of the client functionality you can look at `client.ts`

Getting payloads

// Example of creating an add validator payload
let addValidatorPayload = payload.addValidatorPayload();

// Example of creating a stake aptos payload
let stakeAptosPayload = payload.stakeAptosPayload(STAKE_AMOUNT);

// For the rest of the payload generation functionality you can look at payload.ts

Useful utility functions

// Get staked aptos index.
let index = await Ditto.staptosIndex();

// Get aptos balance for an account
let aptosBalance = await getAccountAptosBalance(ACCOUNT_ADDR);

// Get staked aptos balance for an account
let stAptosBalance = await getAccountStaptosBalance(ACCOUNT_ADDR);

// Get staked aptos coin info: returns CoinInfo
// interface CoinInfo {
// decimals: number;
// name: string;
// supply: bigint;
// symbol: string;
// }
let stAptosCoinInfo = await getStAptosInfo();

// For the rest of the utility functionality you can look at utils.ts

Extra state fetching

// This will refresh the smart contract's resources with up-to-date on chain data.
// This is called on load as well.
await Ditto.refreshDittoResources();

// You can check Ditto's smart contract resources via the Ditto object
console.log(Ditto.dittoConfig);
console.log(Ditto.dittoPool);
console.log(Ditto.validatorWhitelist);

// You can query on chain state from Ditto as well- some examples
// This will get validator state for a certain validator
let validatorState = await Ditto.getValidatorStateFromTable(VALIDATOR_KEY);

// This will get how much aptos users can claim from their delayed unstake requests
let userClaimState = await Ditto.getUserClaimStateFromTable(USER_KEY);

// For the rest of Ditto functionality you can look at client.ts
// This includes more available entry-points and on chain state queries

Permissionless cranking

There are several permissionless entry-points that can be called via the Ditto singleton.

// Distribute pending stake to validators.
await Ditto.distributeUnstakedCoins();

// Update Ditto's smart contract state on new epochs.
await Ditto.updateDittoState();

// Reactive inactive validator.
await Ditto.joinValidatorSet(validatorPoolAddress);