@chipi-stack/core
v0.2.1
Published
Core primitives for Chipi Pay SDK: TxBuilder, Amount, SignerAdapter, TokenRegistry
Downloads
59
Keywords
Readme
@chipi-stack/core
Core primitives for Chipi Pay SDK: transaction building, token math, signer adapters, and fee estimation.
Install
npm install @chipi-stack/coreModules
TxBuilder
Build Starknet multicall transactions with a fluent API:
import { TxBuilder } from "@chipi-stack/core";
const tx = TxBuilder.new()
.transfer({ token: "USDC", to: "0x...", amount: "10.00" })
.approve({ token: "USDC", spender: "0x...", amount: "50.00" })
.build();TokenRegistry
Look up token metadata (address, decimals) by symbol and network:
import { TokenRegistry } from "@chipi-stack/core";
const usdc = TokenRegistry.get("USDC", "mainnet");
// { address: "0x033068...", decimals: 6, symbol: "USDC" }Amount
Safe token amount math with decimal precision:
import { Amount } from "@chipi-stack/core";
const amt = Amount.fromHuman("10.50", 6); // 10.5 USDC
amt.toRaw(); // 10500000n
amt.toHuman(); // "10.50"Signers
Unified SignerAdapter interface with three implementations:
import { DirectSigner, ExternalSigner, PasskeySigner } from "@chipi-stack/core";
// Local key (testing only)
const direct = new DirectSigner("0x...");
// External provider (Privy, Cartridge, etc.)
const external = new ExternalSigner({
getPublicKey: () => provider.getPublicKey(),
sign: (hash) => provider.sign(hash),
getAccountAddress: () => provider.getAddress(),
});
// Passkey-based signer
const passkey = new PasskeySigner({
authenticateFn: (challenge) => passkeyAuth(challenge),
publicKey: "0x...",
accountAddress: "0x...",
});Fee Estimation
Estimate Starknet transaction fees before execution:
import { estimateFee, preflight } from "@chipi-stack/core";
const fee = await estimateFee(calls, account);
const check = await preflight(calls, account); // fee + balance checkDocumentation
Full docs at docs.chipipay.com
License
MIT
