Overview

The /v1/instructions/compose endpoint enables developers to combine multiple operations (intent, intent-simple, and build) into a single composable supertransaction. It supports runtime value injection, allowing dynamic responses to outputs from previous steps.

How It Works

The compose endpoint enables complex workflows by:
  1. Accepting multiple operations - Combine up to 10 operations in a single request
  2. Supporting all operation types - Mix intent, intent-simple, and build calls
  3. Runtime injection - Use runtimeErc20Balance to dynamically use outputs from previous operations
  4. Handling slippage - Subsequent instructions can adapt to actual outputs from swaps or bridges

Runtime Composability

Runtime injection allows instructions to use the actual output from previous operations. For example:
  • A swap might output slightly less than expected due to slippage
  • The next instruction (e.g., supply to a vault) can use runtimeErc20Balance to deposit the actual amount received

Request Structure

POST /v1/instructions/compose

Request Body

Array of operations (1-10 items), each specifying:
ParameterTypeDescription
typestringOperation type: /instructions/build, /instructions/intent-simple, or /instructions/intent
dataobjectOperation-specific data matching the respective endpoint

Example Request - Swap and Supply

This example shows a cross-chain swap followed by a supply operation using runtime balance:
curl -X POST https://api.biconomy.io/v1/instructions/compose \
  -H "Content-Type: application/json" \
  -d '[
    {
      "type": "/instructions/intent-simple",
      "data": {
        "srcToken": "0x833589fcd6edb6e08f4c7c32d4f71b54bda02913",
        "dstToken": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
        "srcChainId": 8453,
        "dstChainId": 10,
        "fromAddress": "0x742d35cc6639cb8d4b5d1c5d7b8b5e2e7c0c7a8a",
        "amount": "1000000",
        "mode": "smart-account",
        "slippage": 0.01
      }
    },
    {
      "type": "/instructions/build",
      "data": {
        "functionSignature": "function supply(address asset, uint256 amount, address onBehalfOf, uint16 referralCode)",
        "args": [
          "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
          {
            "type": "runtimeErc20Balance",
            "targetAddress": "0x742d35cc6639cb8d4b5d1c5d7b8b5e2e7c0c7a8a",
            "tokenAddress": "0x94b008aa00579c1307b0ef2c499ad98a8ce58e58",
            "constraints": {
              "gte": "0"
            }
          },
          "0x742d35cc6639cb8d4b5d1c5d7b8b5e2e7c0c7a8a",
          0
        ],
        "to": "0x8dFf5E27EA6b7AC08EbFdf9eB090F32ee9a30fcf",
        "chainId": 10,
        "value": "0"
      }
    }
  ]'

Response

Returns composed MEE instructions ready for execution:
{
  "instructions": [
    {
      "calls": [...],
      "chainId": 8453,
      "isComposable": true
    },
    {
      "calls": [...],
      "chainId": 10,
      "isComposable": true
    }
  ],
  "returnedData": []
}

Use Cases

Slippage Handling

When a swap outputs less than expected due to slippage, the next operation uses runtimeErc20Balance to work with the actual amount received.

Complex DeFi Operations

  1. Withdraw from lending protocol
  2. Bridge to another chain
  3. Supply to a vault
  4. Stake LP tokens
All in a single atomic supertransaction with runtime value injection between steps.

Supported Operations

  • /instructions/intent - Complex multi-asset intents
  • /instructions/intent-simple - Cross-chain swaps
  • /instructions/build - Direct contract calls
Mix and match up to 10 operations per request.