Minimal TypeScript SDK for the senditwithcelo app. Wraps the core on-chain interactions used by the app on the Celo blockchain.
npm install @uniquebeing-base-eth/senditwithcelo-sdk viemThe SDK uses viem clients and declares viem as a peer dependency, so the app
can pass its existing clients (including clients obtained from wagmi).
import {
createSendItClient,
sendTip,
getBalance,
CELOTIP_ADDRESS,
CELO_TOKENS,
CELO_CHAIN_ID,
} from "@uniquebeing-base-eth/senditwithcelo-sdk";Bind the app's viem clients and relayer once, then call SDK methods without repeating that configuration:
import { createPublicClient, createWalletClient, custom, http } from "viem";
import { celo } from "viem/chains";
import { createSendItClient, CELO_TOKENS } from "@uniquebeing-base-eth/senditwithcelo-sdk";
const publicClient = createPublicClient({ chain: celo, transport: http() });
const walletClient = createWalletClient({
chain: celo,
transport: custom(window.ethereum),
});
const sendit = createSendItClient({
publicClient,
walletClient,
relayerUrl: "https://<your-project>.functions.supabase.co/send-tip",
});
const cUSD = CELO_TOKENS.find((token) => token.symbol === "cUSD")!;
const balance = await sendit.getBalance({
address: "0xUserAddress",
tokenAddress: cUSD.address,
decimals: cUSD.decimals,
});
const result = await sendit.sendTip({
from: "0xSender",
to: "0xRecipient",
tokenAddress: cUSD.address,
amount: "1.5",
decimals: cUSD.decimals,
message: "thanks!",
});For browser wallet providers, use the provider supplied by the app or wallet
integration; window.ethereum is shown only as a simple viem setup example.
The current senditwithcelo app does not implement a
claimRewardflow, so it is intentionally not exported. It can be added later when the contract ships that function.
Reads an ERC20 token balance.
import { createPublicClient, http } from "viem";
import { celo } from "viem/chains";
import { getBalance, CELO_TOKENS } from "@uniquebeing-base-eth/senditwithcelo-sdk";
const publicClient = createPublicClient({ chain: celo, transport: http() });
const cUSD = CELO_TOKENS.find((t) => t.symbol === "cUSD")!;
const balance = await getBalance({
address: "0xUserAddress",
tokenAddress: cUSD.address,
decimals: cUSD.decimals,
publicClient,
});
console.log(balance.formatted, cUSD.symbol); // e.g. "12.345 cUSD"Sends a tip via the CeloTip contract. The on-chain sendTip call is performed
by a relayer (the senditwithcelo app uses a Supabase Edge Function named
send-tip). The SDK handles the ERC20 approval locally, then posts the tip
payload to your relayer URL.
import { sendTip, CELO_TOKENS } from "@uniquebeing-base-eth/senditwithcelo-sdk";
const cUSD = CELO_TOKENS.find((t) => t.symbol === "cUSD")!;
const result = await sendTip({
from: "0xSender",
to: "0xRecipient",
tokenAddress: cUSD.address,
amount: "1.5",
decimals: cUSD.decimals,
message: "thanks!",
relayerUrl: "https://<your-project>.functions.supabase.co/send-tip",
walletClient,
publicClient,
});
console.log(result.hash); // on-chain tx hash from the relayerThe relayer is expected to accept this JSON body:
{
"from": "0x...",
"to": "0x...",
"tokenAddress": "0x...",
"amount": "1500000000000000000",
"interactionType": "tip",
"castHash": "thanks!"
}…and respond with { "hash": "0x..." } on success or { "error": "..." } on
failure — matching the senditwithcelo send-tip Edge Function.
npm install
npm run build # compiles src/ -> dist/npm login
npm publish # runs `npm run build` via prepublishOnlyMIT