Call Any StarkNet Smart Contract Gaslessly

Call any StarkNet smart contract through Chipi's gasless infrastructure. Build NFT minting, governance voting, token launches, custom DeFi, and more.

Overview

Call any StarkNet smart contract through Chipi's gasless infrastructure. This is the gateway to NFT minting, governance voting, token launches, gaming mechanics, custom DeFi protocols, loyalty points, and any on-chain logic your app needs. Users never pay gas. Chipi sponsors all transactions.

Basic Contract Call

Use the useCallAnyContract hook:

tsximport { useCallAnyContract } from "@chipi-stack/nextjs";

const { mutateAsync: callContract, isPending } = useCallAnyContract();

await callContract({
  encryptKey: passkeyCredential,
  wallet: userWallet,
  calls: [
    {
      contractAddress: "0x_YOUR_CONTRACT",
      entrypoint: "your_function",
      calldata: [
        // Parameters must match the contract ABI
      ],
    },
  ],
  bearerToken: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,
});

The calls array supports batching multiple contract calls into a single transaction. This is native to StarkNet's account abstraction. For example, approve + swap in one transaction.

Batched Calls with Token Approval

If your contract function spends the user's tokens, batch the approval with the call:

tsxawait callContract({
  encryptKey: passkeyCredential,
  wallet: userWallet,
  calls: [
    {
      // First: approve the contract to spend tokens
      contractAddress: "0x033068f6...USDC",
      entrypoint: "approve",
      calldata: [contractAddress, amountLow, amountHigh],
    },
    {
      // Second: the actual contract interaction
      contractAddress: "0x_YOUR_CONTRACT",
      entrypoint: "your_function",
      calldata: [/* your parameters */],
    },
  ],
  bearerToken: process.env.NEXT_PUBLIC_CHIPI_API_KEY!,
});

The user taps their passkey once for both operations. Much better UX than two separate transactions.

Calldata Encoding

StarkNet calldata is an array of felt252 values (big integers as strings):

  • - Addresses: pass as-is (0x + hex string)
  • - uint256: split into two felt252 values. [low_128_bits, high_128_bits]. For most amounts under 2^128, high = "0"
  • - Strings: convert to felt252 using Cairo's short string encoding
  • - Arrays: prepend the length, then each element

Key contract addresses on StarkNet:

  • - USDC: 0x033068f6539f8e6e6b131e6b2b814e6c34a5224bc66947c47dab9dfee93b35fb
  • - ETH: 0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7

Ready to build?

Connect the Chipi MCP server and start building in minutes.

Get Started