Quick Start: Copy-Paste Utilities

For TypeScript users: Copy the utilities below directly into your project.
Not using TypeScript? Implement your own version following the same logic shown in the code.

How It Works: Three Signature Types

  • The API returns an array of payloads to sign.
  • In most cases this array has just one item.
  • Each item in the payload is one of three signature types (simple, permit, onchain) depending on your execution mode and token support

Simple (Off-chain Message)

What: Signs a raw hex message
When: Smart accounts and EIP-7702 delegated EOAs
Result: Off-chain signature
// Example payload
{
  quoteType: "simple",
  signablePayload: {
    message: {
      raw: "0x68656c6c6f"
    }
  }
}

The Magic: Supertx Hash Embedding

For EOA mode, the API cleverly embeds the supertransaction hash into your signatures. This creates a cryptographic link between funding and execution, enabling single-signature cross-chain operations. For Permit: The supertx hash replaces the deadline field
// Before: deadline = 1700000000
// After:  deadline = "0xabcdef1234567890..." (supertx hash)
For Onchain: The supertx hash is appended to calldata
// Before: 0xa9059cbb000000000000000000000000...
// After:  0xa9059cbb000000000000000000000000...abcdef1234567890

Usage by Execution Mode

Signature Requirements:
  • One signature per funding token
  • Type depends on token support (permit or onchain)
// 1. Get quote
const quoteResponse = await fetch('/v1/mee/quote', {
  method: 'POST',
  headers: { 'X-API-Key': 'YOUR_API_KEY' },
  body: JSON.stringify({
    type: "eoa",
    fromAddress: "0x...",
    fundingTokens: [{
      tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
      chainId: 1,
      amount: "1000000000"
    }],
    instructions: [...]
  })
});

const { payloadToSign, quote, fee, quoteType } = await quoteResponse.json();

// 2. Sign each payload (one per funding token)
for (let i = 0; i < payloadToSign.length; i++) {
  const payload = payloadToSign[i];
  
  // Use the utility function - it handles all types
  const signature = await signQuoteSignablePayload(payload);
  
  // Add signature back to payload
  payloadToSign[i].signature = signature;
}

// 3. Execute with signed payloads
await fetch('/v1/mee/execute', {
  method: 'POST',
  body: JSON.stringify({
    fromAddress,
    fee,
    quoteType,
    quote,
    payloadToSign
  })
});

Summary

  1. Copy the utilities - They handle all signature types automatically
  2. Get a quote - The API returns the appropriate payload type
  3. Sign with utilities - signQuoteSignablePayload() routes to the right method
  4. Execute - Send signed payloads back to complete the supertransaction
The utilities abstract away the complexity while the API’s clever hash embedding enables powerful single-signature cross-chain operations.