Create Custom Transaction

Send ADA and assets to multiple recipients in a single transaction

Introduction

This guide demonstrates how to create a custom transaction that sends ADA and assets to multiple recipient addresses in a single transaction. This powerful feature allows you to efficiently distribute funds and tokens to several wallets at once, reducing transaction costs and improving throughput. Simply include multiple outputs in the payload to each recipient, and define what ADA and assets to send, and Anvil API will handle building the transaction for you.

For more information on transactions, please refer to the Transaction Overview.

Key Features

  • Send different amounts of ADA to multiple recipients

  • Distribute different native assets to different addresses

  • Customize each output independently

  • Handle complex transactions in a single API call

Requirements

  • A Cardano wallet with sufficient ADA

  • Native assets in your wallet (if sending assets)

  • Recipient wallet addresses

  • Valid API key for authentication

Full Examples

Using Bash and cURL

Bash & cURL

Using TS/JS Fetch

Deno & Fetch

Specifications

API Endpoint

POST /transactions/build

Request Structure

{
  "changeAddress": "<sender_address>",
  "outputs": [
    {
      "address": "<receiver_address_1>",
      "lovelace": <lovelace_amount>,
      "assets": [
        {
          "policyId": "<policy_id>",
          "assetName": "<asset_name>",
          "quantity": <lovelace_amount>
        }
      ]
    },
    {
      "address": "<receiver_address_2>",
      "lovelace": <lovelace_amount>,
      "assets": [
        {
          "policyId": "<policy_id>",
          "assetName": "<asset_name>",
          "quantity": <lovelace_amount>
        }
      ]
    }
    // Add as many outputs as needed
  ],
  // Optional bounds that determine when the transaction is valid. 
  // False can be used to disable a bound.
  // If transactions are submitted outside of the validity interval, they will be rejected.
  "validityInterval": {
    "start": <posix_timestamp_or_slot_number>, // Optional, default: current slot
    "end": <posix_timestamp_or_slot_number>    // Optional, default: current slot + 2 hours
  }
}

Best Practices

  • Always verify recipient addresses before submitting transactions

  • Include sufficient ADA in each output (minimum 2 ADA if sending native assets)

  • Test transactions on testnet before moving to mainnet

  • Consider transaction fees when planning outputs

  • Keep your API key secure and never expose it in client-side code

Last updated

Was this helpful?