Developer SDK

Flow Protocol SDK

A TypeScript SDK for integrating programmable payment streams, conditional pacts, and instant multi-recipient transfers into any application built on Sui.

Overview

The Flow Protocol SDK wraps the on-chain smart contracts into a clean, type-safe TypeScript interface. It abstracts away transaction building, coin management, and clock object references so you can integrate payment primitives in minutes instead of hours.

All three payment primitives are supported — Streams for vesting and subscriptions, Pacts for escrow and milestone payments, and Instant for immediate multi-recipient transfers.

FlowClient.stream

Create, withdraw from, and cancel time-based payment streams.

FlowClient.pact

Create conditional escrow pacts with complete, dispute, and cancel flows.

FlowClient.instant

Send or split-send tokens to multiple recipients in a single transaction.

Who Is It For

Any developer or team that wants to add programmable payments to their product without writing Move contracts or managing transaction construction manually.

DeFi Protocols

Add token vesting for your tokenomics — stream tokens to team members, investors, or community contributors with cliffs and durations.

Freelance & Gig Platforms

Replace manual invoice flows with pacts. Lock funds on project start, release on delivery, and enable dispute resolution on-chain.

Subscription Businesses

Use streams to charge subscribers continuously rather than monthly lump sums. Recipients can claim accrued balance at any time.

DAOs & Treasuries

Automate contributor payroll with streams, fund working groups via pacts, and split treasury distributions with a single instant transfer.

Wallets & Consumer Apps

Expose stream and pact creation natively inside your wallet interface without needing to know Move.

Payroll & HR Tools

Build crypto payroll products on top of Flow. Create streams per employee, denominated in any supported coin type including stablecoins.

Installation

1

Install the SDK and its peer dependency

bash
npm install @flow-protocol/sdk @mysten/sui

The SDK requires @mysten/sui v2.x as a peer dependency. If your project already has it, no additional install is needed.

2

Ensure your tsconfig is compatible

The Sui SDK v2 uses modern ESM-style type declarations. Add these to your tsconfig.json:

json
{
  "compilerOptions": {
    "module": "ES2020",
    "moduleResolution": "bundler"
  }
}

Initialization

Create a single FlowClient instance and pass it to your components via context or props. It does not hold any wallet state — transaction signing is handled by your wallet adapter.

typescript
import { FlowClient } from "@flow-protocol/sdk";

const flow = new FlowClient({
  network: "testnet",
});

const flow = new FlowClient({
  network: "testnet",
  rpcUrl: "https://rpc-testnet.suiscan.xyz",
});

The client exposes three namespaces: flow.stream, flow.pact, and flow.instant. Each method returns a Transaction object that you sign and execute using your wallet.

Working with Streams

A stream locks tokens on-chain and releases them linearly over time. The recipient can withdraw accrued balance at any time. The sender can cancel early and reclaim the unstreamed portion.

1

Create a stream

typescript
import { FlowClient } from "@flow-protocol/sdk";
import { useSignAndExecuteTransaction } from "@mysten/dapp-kit";

const flow = new FlowClient({ network: "testnet" });
const { mutate: signAndExecute } = useSignAndExecuteTransaction();

async function createStream(coinObjectId: string) {
  const tx = flow.stream.create({
    coinObjectId,
    recipient: "0xRecipientAddress",
    amount: 1_000_000_000n,
    durationMs: 30 * 24 * 60 * 60 * 1000,
    coinType: "0x2::sui::SUI",
  });
  signAndExecute({ transaction: tx });
}
2

Withdraw from a stream (recipient)

typescript
const tx = flow.stream.withdraw({
  streamId: "0xStreamObjectId",
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });
3

Cancel a stream (sender)

typescript
const tx = flow.stream.cancel({
  streamId: "0xStreamObjectId",
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });
4

Check claimable balance

typescript
const claimable = await flow.stream.getClaimable({
  streamId: "0xStreamObjectId",
  coinType: "0x2::sui::SUI",
});
console.log(`Claimable: ${claimable} base units`);

Working with Pacts

A pact is a conditional escrow. The sender locks funds, and the recipient receives them only when the sender marks the pact complete. Either party can raise a dispute.

1

Create a pact

typescript
const tx = flow.pact.create({
  coinObjectId: "0xCoinObjectId",
  recipient: "0xRecipientAddress",
  amount: 500_000_000n,
  description: "Website redesign milestone 1",
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });
2

Complete a pact (release funds)

typescript
const tx = flow.pact.complete({
  pactId: "0xPactObjectId",
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });
3

Cancel a pact

typescript
const tx = flow.pact.cancel({
  pactId: "0xPactObjectId",
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });
4

Dispute a pact

typescript
const tx = flow.pact.dispute({
  pactId: "0xPactObjectId",
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });

Pact Status Values

0

PENDING

1

COMPLETED

2

DISPUTED

3

CANCELLED

Instant Payments

Instant payments transfer tokens immediately. Use send for a single recipient or splitSend to distribute across multiple addresses in one transaction.

1

Send to a single recipient

typescript
const tx = flow.instant.send({
  coinObjectId: "0xCoinObjectId",
  recipient: "0xRecipientAddress",
  amount: 200_000_000n,
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });
2

Split send to multiple recipients

typescript
const tx = flow.instant.splitSend({
  coinObjectId: "0xCoinObjectId",
  recipients: [
    "0xAddress1",
    "0xAddress2",
    "0xAddress3",
  ],
  amounts: [
    100_000_000n,
    150_000_000n,
    250_000_000n,
  ],
  coinType: "0x2::sui::SUI",
});
signAndExecute({ transaction: tx });

Supported Assets

All three primitives are generic — any coin type on Sui works. Pass the full coin type string as coinType.

AssetCoin Type
SUI0x2::sui::SUI
USDC0x5d4b302506645c37ff133b98c4b50a5ae14841659738d6d733d59d0d217a93bf::coin::COIN
USDT0xc060006111016b8a020ad5b33834984a437aaa7d3c74c18e09a95d48aceab08c::coin::COIN

Any other valid Sui coin type works — just pass its full type string.

Contract Reference

Package ID

0x3170c4670ac048b33460524a1ee6bad245f86bac32345e761257ff970540c94b

Network

Sui Testnet

Mainnet coming after audit

ModuleObject TypeFunctions
streamStream<T>create_stream, withdraw_stream, cancel_stream, get_claimable
pactPact<T>create_pact, complete_pact, cancel_pact, dispute_pact
instantsend, split_send

Ready to integrate?

Try the live app or browse the source on GitHub.