@sfpro/sdk

GDA Forwarder

API reference for General Distribution Agreement Forwarder

The GDA Forwarder provides a simplified interface for creating and managing distribution pools. It enables one-to-many token distributions with proportional allocations.

Contract Addresses

import { gdaForwarderAddress } from "@sfpro/sdk/abi"
import { mainnet } from "viem/chains"

// Get GDA Forwarder address for a specific chain
const forwarderAddress = gdaForwarderAddress[mainnet.id]

Read Functions

getPool

Get the address of a pool based on its parameters.

import { useReadGdaForwarder } from "@sfpro/sdk/hook"
import { keccak256, toHex } from "viem"

const { data: poolAddress } = useReadGdaForwarder({ 
  functionName: "getPool", 
  args: ["0x...", "0x...", keccak256(toHex("pool1"))] 
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { createPublicClient, http, keccak256, toHex } from "viem"
import { mainnet } from "viem/chains"

const client = createPublicClient({
  chain: mainnet,
  transport: http()
})

const poolAddress = await client.readContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "getPool", 
  args: [ 
    "0x...", // Super Token address
    "0x...", // Admin address
    keccak256(toHex("pool1")) // Pool ID
  ] 
}) 
import { readGdaForwarder } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { http, keccak256, toHex } from "viem"
import { mainnet } from "viem/chains"

const config = createConfig({
  chains: [mainnet],
  transports: { [mainnet.id]: http() }
})

const poolAddress = await readGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "getPool", 
  args: ["0x...", "0x...", keccak256(toHex("pool1"))] 
}) 

isPool

Check if an address is a valid GDA pool.

import { useReadGdaForwarder } from "@sfpro/sdk/hook"

const { data: isValidPool } = useReadGdaForwarder({ 
  functionName: "isPool", 
  args: ["0x...", "0x..."] // Token, pool address
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { createPublicClient, http } from "viem"
import { mainnet } from "viem/chains"

const client = createPublicClient({
  chain: mainnet,
  transport: http()
})

const isValidPool = await client.readContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "isPool", 
  args: [ 
    "0x...", // Super Token address
    "0x..."  // Pool address to check
  ] 
}) 
import { readGdaForwarder } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { http } from "viem"
import { mainnet } from "viem/chains"

const config = createConfig({
  chains: [mainnet],
  transports: { [mainnet.id]: http() }
})

const isValidPool = await readGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "isPool", 
  args: ["0x...", "0x..."] // Token, pool address
}) 

Write Functions

createPool

Create a new distribution pool.

import { useWriteGdaForwarder } from "@sfpro/sdk/hook"
import { useAccount } from "wagmi"
import { keccak256, toHex } from "viem"

const { address } = useAccount()

const { writeContract: createPool } = useWriteGdaForwarder({ 
  functionName: "createPool", 
  args: ["0x...", address!, keccak256(toHex("pool1"))] 
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { createWalletClient, http, keccak256, toHex } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const walletClient = createWalletClient({
  account,
  chain: mainnet,
  transport: http()
})

const hash = await walletClient.writeContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "createPool", 
  args: [ 
    "0x...", // Super Token address
    account.address, // Admin address
    keccak256(toHex("pool1")) // Pool ID
  ] 
}) 
import { writeGdaForwarder } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { createWalletClient, http, keccak256, toHex } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const config = createConfig({
  chains: [mainnet],
  client({ chain }) {
    return createWalletClient({ account, chain, transport: http() })
  },
})

const hash = await writeGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "createPool", 
  args: ["0x...", account.address, keccak256(toHex("pool1"))] 
}) 

distribute

Distribute tokens to all pool members proportionally.

import { useWriteGdaForwarder } from "@sfpro/sdk/hook"
import { useAccount } from "wagmi"
import { parseEther } from "viem"

const { address } = useAccount()

const { writeContract: distribute } = useWriteGdaForwarder({ 
  functionName: "distribute", 
  args: ["0x...", address!, "0x...", parseEther("100"), "0x"] 
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { createWalletClient, http, parseEther } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const walletClient = createWalletClient({
  account,
  chain: mainnet,
  transport: http()
})

const hash = await walletClient.writeContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "distribute", 
  args: [ 
    "0x...", // Super Token address
    account.address, // From address
    "0x...", // Pool address
    parseEther("100"), // Amount to distribute
    "0x"     // User data
  ] 
}) 
import { writeGdaForwarder } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { createWalletClient, http, parseEther } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const config = createConfig({
  chains: [mainnet],
  client({ chain }) {
    return createWalletClient({ account, chain, transport: http() })
  },
})

const hash = await writeGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "distribute", 
  args: ["0x...", account.address, "0x...", parseEther("100"), "0x"] 
}) 

distributeFlow

Create a continuous distribution flow to a pool.

import { useWriteGdaForwarder } from "@sfpro/sdk/hook"
import { useAccount } from "wagmi"
import { calculateFlowrate } from "@sfpro/sdk/util"
import { parseEther } from "viem"

const { address } = useAccount()
const flowrate = calculateFlowrate({
  amountWei: parseEther("100"),
  timeUnit: "month"
})

const { writeContract: distributeFlow } = useWriteGdaForwarder({ 
  functionName: "distributeFlow", 
  args: ["0x...", address!, "0x...", flowrate, "0x"] 
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { calculateFlowrate } from "@sfpro/sdk/util"
import { createWalletClient, http, parseEther } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const walletClient = createWalletClient({
  account,
  chain: mainnet,
  transport: http()
})

const flowrate = calculateFlowrate({
  amountWei: parseEther("100"),
  timeUnit: "month"
})

const hash = await walletClient.writeContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "distributeFlow", 
  args: [ 
    "0x...", // Super Token address
    account.address, // From address
    "0x...", // Pool address
    flowrate, // Flowrate to pool
    "0x"     // User data
  ] 
}) 
import { writeGdaForwarder, calculateFlowrate } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { createWalletClient, http, parseEther } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const config = createConfig({
  chains: [mainnet],
  client({ chain }) {
    return createWalletClient({ account, chain, transport: http() })
  },
})

const flowrate = calculateFlowrate({
  amountWei: parseEther("100"),
  timeUnit: "month"
})

const hash = await writeGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "distributeFlow", 
  args: ["0x...", account.address, "0x...", flowrate, "0x"] 
}) 

connectPool

Connect to a pool as a member to receive distributions.

import { useWriteGdaForwarder } from "@sfpro/sdk/hook"

const { writeContract: connectPool } = useWriteGdaForwarder({ 
  functionName: "connectPool", 
  args: ["0x...", "0x"] // Pool address, user data
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { createWalletClient, http } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const walletClient = createWalletClient({
  account,
  chain: mainnet,
  transport: http()
})

const hash = await walletClient.writeContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "connectPool", 
  args: [ 
    "0x...", // Pool address
    "0x"     // User data
  ] 
}) 
import { writeGdaForwarder } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { createWalletClient, http } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const config = createConfig({
  chains: [mainnet],
  client({ chain }) {
    return createWalletClient({ account, chain, transport: http() })
  },
})

const hash = await writeGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "connectPool", 
  args: ["0x...", "0x"] // Pool address, user data
}) 

disconnectPool

Disconnect from a pool to stop receiving distributions.

import { useWriteGdaForwarder } from "@sfpro/sdk/hook"

const { writeContract: disconnectPool } = useWriteGdaForwarder({ 
  functionName: "disconnectPool", 
  args: ["0x...", "0x"] // Pool address, user data
}) 
import { gdaForwarderAbi, gdaForwarderAddress } from "@sfpro/sdk/abi"
import { createWalletClient, http } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const walletClient = createWalletClient({
  account,
  chain: mainnet,
  transport: http()
})

const hash = await walletClient.writeContract({ 
  address: gdaForwarderAddress[mainnet.id], 
  abi: gdaForwarderAbi, 
  functionName: "disconnectPool", 
  args: [ 
    "0x...", // Pool address
    "0x"     // User data
  ] 
}) 
import { writeGdaForwarder } from "@sfpro/sdk/action"
import { createConfig } from "@wagmi/core"
import { createWalletClient, http } from "viem"
import { mainnet } from "viem/chains"
import { privateKeyToAccount } from "viem/accounts"

const account = privateKeyToAccount(process.env.PRIVATE_KEY as `0x${string}`)
const config = createConfig({
  chains: [mainnet],
  client({ chain }) {
    return createWalletClient({ account, chain, transport: http() })
  },
})

const hash = await writeGdaForwarder(config, { 
  chainId: mainnet.id, 
  functionName: "disconnectPool", 
  args: ["0x...", "0x"] // Pool address, user data
}) 

Key Notes

  • Pool Creation: Pools are deterministic based on (token, admin, poolId)
  • Distribution: Instantly distributes to all connected members
  • Flow Distribution: Create continuous flows to pools
  • Member Connection: Members must connect to receive distributions