Skip to main content
@chipi-stack/core is in development (v0.1.0). APIs may change before stable release.

What is @chipi-stack/core?

@chipi-stack/core provides opt-in transaction primitives for developers who need fine-grained control over StarkNet operations. It complements the existing hooks-based SDKs (Next.js, React, Expo) with lower-level building blocks.

When to use core vs hooks

Use CaseRecommendedWhy
Standard transfers in a React appHooks (useTransfer)Simpler, handles state management
Batch approve + transfer atomicallyCore (TxBuilder)Hooks don’t support multicall batching
Display formatted balancesEitherCore’s Amount class or shared’s formatAmount
Custom contract interactions with fee previewCore (TxBuilder.estimateFee())Hooks don’t expose fee estimation
Backend automation with programmatic signingCore (DirectSigner + TxBuilder)No React context available
Swap passkey for Argent/Braavos wallet signerCore (ExternalSigner)Hooks are hardwired to passkey flow
Gasless transactions with any wallet (Argent X, Braavos, Cartridge, DirectSigner)Core (TxBuilder.sendSponsored())Uses Chipi’s paymaster for gas sponsorship

Installation

npm install @chipi-stack/core @chipi-stack/backend

Quick Example

import { Amount, TxBuilder, Erc20, TokenRegistry, createAccount, DirectSigner } from "@chipi-stack/core";
import { ChipiServerSDK } from "@chipi-stack/backend";

// Create signer + account
const signer = new DirectSigner(process.env.PRIVATE_KEY!, myAddress);
const account = await createAccount({
  signer,
  provider: { nodeUrl: "https://starknet-mainnet.infura.io/v3/..." },
});

// Look up USDC from the built-in token registry
const registry = new TokenRegistry("mainnet");
const usdcInfo = registry.bySymbol("USDC")!;

// Parse a human-readable amount safely (no floating point)
const amount = Amount.parse("10.0", usdcInfo);

// Create a typed ERC20 wrapper
const usdc = new Erc20(usdcInfo, account);

// Check balance
const balance = await usdc.balanceOf(myAddress);
console.log(balance.toFormatted()); // "150.5 USDC"

// Gasless: approve + transfer via Chipi's paymaster
const sdk = new ChipiServerSDK({ apiPublicKey: "pk_...", apiSecretKey: "sk_..." });
const paymaster = sdk.createPaymasterAdapter();

const txHash = await new TxBuilder(account, { paymaster })
  .add(usdc.approveCall(spender, amount))
  .add(usdc.transferCall(recipient, amount))
  .sendSponsored(); // gasless!

// Or direct (user pays gas):
const result = await new TxBuilder(account)
  .add(usdc.approveCall(spender, amount))
  .add(usdc.transferCall(recipient, amount))
  .send();

Package Architecture

core depends only on @chipi-stack/types. It does not modify or depend on @chipi-stack/shared, keeping the two packages independent.

What’s Inside