Key Advantages

  • Native Batch Execution: Execute multiple operations atomically without additional setup
  • Built-in Sponsorship: Gasless transactions through integrated paymaster support
  • Simplified Flow: No EIP-7702 authorization or separate approval transactions

Execution Flow

Smart account execution follows a streamlined three-step process:
  1. Prepare Instructions: Define your multi-chain operations
  2. Generate Quote: Request execution parameters from the API
  3. Execute: Sign and submit the transaction
Unlike EOA modes, smart accounts handle token approvals internally, eliminating separate approval steps.

Implementation Steps

Step 0: Prepare Instructions

Build your transaction workflow using the /compose endpoint:
const instructions = await fetch('/v1/instructions/compose', {
  method: 'POST',
  body: JSON.stringify([
    {
      type: "/instructions/intent-simple",
      data: {
        srcToken: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        dstToken: "0x4200000000000000000000000000000000000006",
        srcChainId: 8453,
        dstChainId: 8453,
        fromAddress: smartAccount.address,
        amount: "1000000000",
        mode: "smart-account",
        slippage: 0.01
      }
    }
  ])
});

Step 1: Generate Quote

Request a quote with type: "smart-account":
const quoteRequest = {
  type: "smart-account",
  fromAddress: smartAccount.address,
  instructions: instructions.instructions,
  fundingTokens: [
    {
      tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
      chainId: 8453,
      amount: "1000000000"
    }
  ],
  // Optional: specify fee token for non-sponsored execution
  feeToken: {
    address: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
    chainId: 8453
  }
};

const quoteResponse = await fetch('/v1/mee/quote', {
  method: 'POST',
  body: JSON.stringify(quoteRequest)
});

Step 2: Sign User Operations

Smart accounts use ERC-4337 UserOperations which require specific signatures:
const { payloadToSign, quoteType, quote } = quoteResponse;

// Sign based on quote type
const signatures = await Promise.all(
  payloadToSign.map(async (payload) => {
    if (quoteType === 'permit') {
      // EIP-712 signature for permits
      return await smartAccount.signTypedData(payload.signablePayload);
    } else if (quoteType === 'simple') {
      // Simple message signature
      return await smartAccount.signMessage(payload.message.raw);
    }
    // Note: 'onchain' type not typically used with smart accounts
  })
);

Step 3: Execute Quote

Submit the signed quote for execution:
const executeRequest = {
  ...quoteResponse,
  payloadToSign: payloadToSign.map((payload, index) => ({
    ...payload,
    signature: signatures[index]
  }))
};

const executeResponse = await fetch('/v1/mee/execute', {
  method: 'POST',
  body: JSON.stringify(executeRequest)
});

const { supertxHash } = executeResponse;
console.log(`Supertransaction hash: ${supertxHash}`);

Sponsorship Options

Smart accounts support flexible fee payment through sponsorship:

UserOperation Structure

Smart accounts generate ERC-4337 UserOperations with MEE-specific extensions:
{
  "userOp": {
    "sender": "0x00000069E0Fb590E092Dd0E36FF93ac28ff11a3a",
    "nonce": "0",
    "initCode": "0x", // Empty for existing accounts
    "callData": "0x...", // Encoded smart account execution
    "callGasLimit": "100000",
    "verificationGasLimit": "50000",
    "preVerificationGas": "21000",
    "maxFeePerGas": "1000000000",
    "maxPriorityFeePerGas": "100000000",
    "paymasterAndData": "0x...", // Sponsorship data
    "signature": "0x" // Added after signing
  },
  "userOpHash": "0x...",
  "meeUserOpHash": "0x...", // MEE-specific hash
  "chainId": 8453,
  "lowerBoundTimestamp": 1710000000,
  "upperBoundTimestamp": 1710003600
}

Complete Example

Full implementation for a cross-chain portfolio rebalance:
async function rebalancePortfolio() {
  // 1. Build complex intent
  const composeResponse = await fetch('/v1/instructions/compose', {
    method: 'POST',
    body: JSON.stringify([
      {
        type: "/instructions/intent",
        data: {
          slippage: 0.003,
          receiver: smartAccount.address,
          inputPositions: [
            {
              chainToken: {
                chainId: 8453,
                tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913"
              },
              amount: "10000000000" // 10,000 USDC
            }
          ],
          targetPositions: [
            {
              chainToken: {
                chainId: 8453,
                tokenAddress: "0x4200000000000000000000000000000000000006"
              },
              weight: 0.6 // 60% WETH
            },
            {
              chainToken: {
                chainId: 10,
                tokenAddress: "0x7F5c764cBc14f9669B88837ca1490cCa17c31607"
              },
              weight: 0.4 // 40% USDC on Optimism
            }
          ]
        }
      }
    ])
  });

  const instructions = await composeResponse.json();

  // 2. Generate quote
  const quoteRequest = {
    type: "smart-account",
    fromAddress: smartAccount.address,
    instructions: instructions.instructions,
    fundingTokens: [
      {
        tokenAddress: "0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913",
        chainId: 8453,
        amount: "10000000000"
      }
    ]
  };

  const quote = await fetch('/v1/mee/quote', {
    method: 'POST',
    body: JSON.stringify(quoteRequest)
  }).then(r => r.json());

  // 3. Sign payloads
  const signatures = await signWithSmartAccount(quote.payloadToSign);

  // 4. Execute
  const executeRequest = {
    ...quote,
    payloadToSign: quote.payloadToSign.map((p, i) => ({
      ...p,
      signature: signatures[i]
    }))
  };

  const result = await fetch('/v1/mee/execute', {
    method: 'POST',
    body: JSON.stringify(executeRequest)
  }).then(r => r.json());

  console.log(`Portfolio rebalanced: ${result.supertxHash}`);
}

Comparison with Other Modes

FeatureSmart AccountEOAEOA-7702
Setup ComplexityLowMediumHigh
Authorization RequiredNoNoYes
Token Approval MethodInternalExternalExternal
Sponsorship SupportNativeNoVia Delegation
Batch OperationsNativeNoYes
Gas EfficiencyHighMediumHigh

Biconomy Nexus Integration

When building with Biconomy Nexus smart accounts, the Supertransaction API seamlessly integrates with your existing infrastructure. The smart account address from your Nexus implementation can be directly used as the fromAddress in quote requests.

Best Practices

Optimization Tips:
  • Batch related operations in a single supertransaction to minimize gas costs
  • Use sponsorship for better user experience when possible
  • Set appropriate time bounds for time-sensitive operations
  • Monitor gas prices across chains for optimal fee token selection

Error Handling

Common error scenarios specific to smart accounts:
try {
  const quote = await generateQuote(request);
} catch (error) {
  switch(error.code) {
    case 'INSUFFICIENT_BALANCE':
      // Smart account lacks required tokens
      break;
    case 'INVALID_SMART_ACCOUNT':
      // Address is not a recognized smart account
      break;
    case 'SPONSORSHIP_UNAVAILABLE':
      // Sponsorship denied, provide feeToken
      break;
    default:
      // Handle other errors
  }
}

Security Considerations

Smart Account Security:
  • Verify the smart account implementation is from a trusted provider
  • Ensure proper access control for smart account signers
  • Monitor UserOperation expiration times
  • Validate sponsorship URLs if using custom paymasters

Advanced Features

Custom Paymaster Configuration

For advanced sponsorship scenarios:
const quoteRequest = {
  type: "smart-account",
  fromAddress: smartAccount.address,
  instructions: [...],
  paymentInfo: {
    sponsored: true,
    sponsorshipUrl: "https://custom-paymaster.example.com"
  }
};

Time-Bounded Execution

Ensure operations execute within specific timeframes:
const quoteRequest = {
  type: "smart-account",
  fromAddress: smartAccount.address,
  instructions: [...],
  lowerBoundTimestamp: Math.floor(Date.now() / 1000),
  upperBoundTimestamp: Math.floor(Date.now() / 1000) + 3600 // Valid for 1 hour
};