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

@fatsolutions/tongo-sdk

v1.3.0

Published

An SDK for interacting with Tongo contracts

Readme

Tongo SDK

An SDK for interacting with Tongo confidential ERC20 payment contracts on Starknet. Tongo enables private transactions and confidential balances while maintaining the programmability of smart contracts.

Installation

npm install @fatsolutions/tongo-sdk

Quick Start

import { Account as TongoAccount } from "@fatsolutions/tongo-sdk";
import { Account, RpcProvider } from "starknet";
import { getPublicKey } from "@scure/starknet";

// Setup provider and signer
const provider = new RpcProvider({
    nodeUrl: "https://starknet-mainnet.g.alchemy.com/starknet/version/rpc/v0_8/YOUR_API_KEY",
    specVersion: "0.8",
});

const signer = new Account(provider, "YOUR_ADDRESS", "YOUR_PRIVATE_KEY");

// Create two Tongo accounts controlled by the same signer
const privateKeyA = BigInt("0x123..."); // First account private key
const privateKeyB = BigInt("0x456..."); // Second account private key
const tongoAddress = "0x0415f2c3b16cc43856a0434ed151888a5797b6a22492ea6fd41c62dbb4df4e6c"; // Mainnet, wraps USDC with rate 1

const accountA = new TongoAccount(privateKeyA, tongoAddress, signer);
const accountB = new TongoAccount(privateKeyB, tongoAddress, signer);

// Fund the first account
const fundOp = await accountA.fund({
    amount: 5000000n // 5 USDC in base units (10^6 for USDC)
});
await fundOp.populateApprove();
const fundTx = await signer.execute([fundOp.approve!, fundOp.toCalldata()]);
console.log("Fund transaction:", fundTx.transaction_hash);

Wait for the transaction to be accepted on Starknet before proceeding:

const stateA = await accountA.stateDeciphered();
console.log("Account A balance:", stateA);  // { balance: 5000000n, pending: 0n, nonce: 1n }

// Transfer from account A to account B
const transferOp = await accountA.transfer({
    to: accountB.publicKey,
    amount: 500000n // 0.5 USDC
});
const transferTx = await signer.execute([transferOp.toCalldata()]);
console.log("Transfer transaction:", transferTx.transaction_hash);

After the transfer transaction is accepted, check the states:

// Check account B state - should show pending balance
const stateB = await accountB.stateDeciphered();
console.log("Account B balance:", stateB);  // { balance: 0n, pending: 500000n, nonce: 0n }

// Perform rollover to finalize the transfer
const rolloverOp = await accountB.rollover();
const rolloverTx = await signer.execute([rolloverOp.toCalldata()]);
console.log("Rollover transaction:", rolloverTx.transaction_hash);

Check decrypted balances after rollover

const stateA = await accountA.stateDeciphered();
const stateB = await accountB.stateDeciphered();
console.log("Account A balance:", stateA);  // { balance: 4500000n, pending: 0n, nonce: 2n }
console.log("Account B balance:", stateB);  // { balance: 500000n, pending: 0n, nonce: 1n }

Finally, withdraw funds from the confidential system:

// Withdraw from account B back to regular ERC20
const withdrawOp = await accountB.withdraw({
    to: signer.address, // Withdraw to signer's address
    amount: 250000n     // Withdraw 0.25 USDC
});
const withdrawTx = await signer.execute([withdrawOp.toCalldata()]);
console.log("Withdraw transaction:", withdrawTx.transaction_hash);

B balance should be

const stateB = await accountB.stateDeciphered();
console.log("Account B balance:", stateB);  // { balance: 250000n, pending: 0n, nonce: 2n }

Key Features

  • Confidential Transfers: Send tokens without revealing amounts or balances
  • Encrypted State: Account balances are encrypted on-chain
  • Withdraw: Exit confidential system back to regular ERC20 tokens
  • Audit Support: Opt-in built-in auditing capabilities for compliance

License

Apache-2.0