Your customers hold your token. You want to give them a discount automatically. No coupon codes, no manual lists, no spreadsheets. Here is how to build it with Express.js and one API call.

The problem

Token-gated commerce is simple in theory: check what a customer holds, apply a discount. In practice, it means indexing balances across multiple chains, handling different token standards, normalizing decimals, and keeping everything up to date. Most teams build this themselves. Most teams regret it.

The Insumer API handles the chain reads and returns a structured discount response. You handle the business logic. The entire server fits in 20 lines.

Step 1: Get a free API key

Create a key with a single POST request:

curl -X POST https://api.insumermodel.com/v1/keys/create \
  -H "Content-Type: application/json" \
  -d '{
    "email": "dev@yourapp.com",
    "appName": "my-discount-app",
    "tier": "free"
  }'

You get 10 free verification credits. No credit card required.

Step 2: Scaffold the project

mkdir token-discount && cd token-discount
npm init -y
npm install express

Step 3: Build server.js

Create server.js with the following code. This is the entire server:

const express = require("express");
const app = express();

const API_KEY = process.env.INSUMER_API_KEY;
const MERCHANT = process.env.MERCHANT_ID;
const BASE = "https://api.insumermodel.com";

app.get("/check-discount", async (req, res) => {
  const { wallet } = req.query;
  if (!wallet) return res.status(400).json({ error: "wallet required" });

  const url = `${BASE}/v1/discount/check?wallet=${wallet}&merchant=${MERCHANT}`;
  const response = await fetch(url, {
    headers: { "x-api-key": API_KEY }
  });
  const { data } = await response.json();

  res.json({
    eligible: data.eligible,
    totalDiscount: data.totalDiscount,
    discountMode: data.discountMode,
    breakdown: data.breakdown
  });
});

app.listen(3000, () => console.log("Discount server on :3000"));

Run it:

INSUMER_API_KEY=your_key MERCHANT_ID=your_merchant_id node server.js

Then test:

curl "http://localhost:3000/check-discount?wallet=0xYourCustomerWallet"

What comes back

The /v1/discount/check endpoint is a GET request that accepts wallet, solanaWallet, xrplWallet, and merchant as query parameters. It checks the customer's holdings across 33 chains and returns a structured response:

{
  "eligible": true,
  "totalDiscount": 15,
  "discountMode": "stack",
  "breakdown": [
    {
      "symbol": "YOUR_TOKEN",
      "tier": "gold",
      "discount": 15,
      "chain": "ethereum"
    }
  ],
  "merchantId": "your_merchant_id",
  "merchantName": "Your Store",
  "chainsChecked": ["Ethereum", "Base", "Polygon"]
}

The breakdown array shows exactly which tokens qualified and at what tier. The totalDiscount gives you the final number to apply at checkout. No balance parsing, no decimal math, no multi-chain indexing on your end.

For custom conditions: /v1/attest

If the built-in discount tiers do not fit, the /v1/attest endpoint lets you define your own conditions. Specify a wallet, a contract address, a chain, and a minimum balance. The API returns an ECDSA-signed boolean: does this wallet meet the condition, yes or no.

curl -X POST https://api.insumermodel.com/v1/attest \
  -H "Content-Type: application/json" \
  -H "x-api-key: your_key" \
  -d '{
    "wallet": "0x...",
    "conditions": [{
      "type": "token_balance",
      "contractAddress": "0x...",
      "chainId": 1,
      "threshold": 100
    }]
  }'

The response includes a signed attestation you can verify offline using the JWKS endpoint. No trust required in the API itself. The cryptography is the proof.

AI agent tooling

If you are building with AI agents, the same verification primitives are available through three integration paths:

Same API, same signed responses, same verification. The agent just calls it instead of you.

Start building

The Insumer Model is free to start. 10 verification credits included. No credit card required.

Get Your API Key