HomeDocsDeveloper Hub

Code Examples Hub

Explore platform-specific integration scripts. Switch tabs to preview and copy complete code blocks.

1. WebAuthn Credential Registration

// Requesting WebAuthn P-256 publicKey creation for modular smart accounts
const credential = await navigator.credentials.create({
  publicKey: {
    challenge: Uint8Array.from("secure-challenge-bytes", c => c.charCodeAt(0)),
    rp: { name: "MerchantPro Ltd." },
    user: { id: new Uint8Array(16), name: "corporate_owner", displayName: "Owner" },
    pubKeyCredParams: [{ alg: -7, type: "public-key" }], // ES256
    authenticatorSelection: { userVerification: "required" },
    timeout: 60000
  }
});

2. Package Sponsored UserOperations

import { ethers } from 'ethers';

// ERC-4337 Gasless UserOperation packaging
const userOp = await circleModularWallet.createUnsignedUserOp({
  calls: [
    { to: "0xEmployeeA...", value: ethers.parseUnits("1500", 6), data: "0x" },
    { to: "0xEmployeeB...", value: ethers.parseUnits("2300", 6), data: "0x" }
  ]
});

// Request Circle Gas Station Paymaster signature for sponsor
const signedUserOp = await circlePaymaster.sponsorUserOperation(userOp);
const txHash = await circleBundler.submitUserOperation(signedUserOp);

3. Reconcile Webhook Payments

import express from 'express';
import crypto from 'crypto';

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

app.post('/webhook/payment', (req, res) => {
  const signature = req.headers['x-circle-signature'];
  const computedHmac = crypto
    .createHmac('sha256', process.env.CIRCLE_WEBHOOK_SECRET!)
    .update(JSON.stringify(req.body))
    .digest('hex');
    
  if (signature !== computedHmac) {
    return res.status(401).send("Invalid Signature");
  }
  
  console.log("Validated Webhook payment reconciled:", req.body.data.txHash);
  res.sendStatus(200);
});

Was this page helpful?

Help us improve the developer experience at MerchantPro.