Skip to main content
This guide gets you from zero to a working deposit flow. You will install the SDK, set up a minimal signer endpoint, and trigger your first transfer.

Integrate with an AI agent

If you want an agent to scaffold this flow for you, use the AI Agent guide or paste this URL directly into Cursor, Claude Code, or your coding agent:
https://raw.githubusercontent.com/swype-org/docs/refs/heads/main/prompts/integrate-blink.md

1. Install the SDK

npm install @swype-org/deposit

2. Create a signer endpoint

Add a server route that signs payment requests. This minimal Express example covers the essentials:
const express = require('express');
const { randomUUID, createSign } = require('node:crypto');
const fs = require('node:fs');

const app = express();
app.use(express.json());

const MERCHANT_ID = process.env.MERCHANT_ID;
const PRIVATE_KEY_PEM = process.env.MERCHANT_PRIVATE_KEY
  || fs.readFileSync('./private.pem', 'utf8');

app.post('/api/sign-payment', (req, res) => {
  const { amount, chainId, address, token, callbackScheme = null, version = 'v1' } = req.body;

  const idempotencyKey = randomUUID();
  const signatureTimestamp = new Date().toISOString();

  const payloadObject = {
    amount, chainId, address, token,
    idempotencyKey, callbackScheme, signatureTimestamp, version,
  };

  const payload = Buffer.from(JSON.stringify(payloadObject), 'utf8').toString('base64url');

  const signer = createSign('SHA256');
  signer.update(payload);
  signer.end();
  const signature = signer.sign(PRIVATE_KEY_PEM).toString('base64url');

  res.json({
    merchantId: MERCHANT_ID,
    payload,
    signature,
    preview: { amount, chainId, address, token, idempotencyKey },
  });
});

app.listen(3001);
Set your environment variables:
export MERCHANT_ID="your-merchant-uuid"
export MERCHANT_PRIVATE_KEY="$(cat private.pem)"
See Build Your Signer Endpoint for the full implementation with validation, security, and a Python equivalent.

3. Trigger the transfer

import { Deposit, DepositError, getDisplayMessage } from '@swype-org/deposit';

const deposit = new Deposit({
  signer: '/api/sign-payment',
});

document.getElementById('transfer-btn').addEventListener('click', async () => {
  try {
    const { transfer: result } = await deposit.requestDeposit({
      amount: 50,
      chainId: 8453,
      address: '0x1a5FdBc891c5D4E6aD68064Ae45D43146D4F9f3a',
      token: '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913',
    });
    console.log('Transfer complete:', result.id, result.status);
  } catch (error) {
    if (error instanceof DepositError) {
      alert(getDisplayMessage(error));
    }
  }
});

What’s next

You now have a working deposit flow. To go to production:
1

Generate a production key pair

Key Generation. Create ECDSA P-256 keys and store the private key in a secrets manager.
2

Register your merchant account

Merchant Registration. Send your public key to Blink.
3

Harden your signer

Signer Endpoint. Add request validation, authentication, rate limiting, and CORS.
4

Handle errors gracefully

Error Handling. Use DepositError codes and getDisplayMessage() in your UI.
5

Run the production checklist

Production Checklist. Verify every item before going live.