Transaction
Overview of Anvil API Cardano Transaction Builder capabilities
Last updated
Was this helpful?
Overview of Anvil API Cardano Transaction Builder capabilities
Last updated
Was this helpful?
Cardano transactions are the fundamental way to move value and interact with the blockchain, whether it's moving ADA, native tokens, and NFTs. Or it's interacting with smart contracts. The Anvil API simplifies transaction creation with a flexible interface that supports:
Simple to complex outputs - from basic ADA transfers to multi-asset transactions with multiple recipients
Input methods - using changeAddress
and UTXOs
to source funds
Complete transaction lifecycle - building, signing, and submitting in a streamlined workflow
This documentation covers the various transaction types, payload structures, and best practices for creating transactions with the Anvil API.
BUILD: We structure a simple payload with changeAddress
, utxos
, and outputs
SIGN: We sign the transaction with your preferred signing method (See )
SUBMIT: We send the signed transaction to the Anvil API's transaction submit endpoint
CONFIRM: We handle the response from the submit endpoint
Below is a sequence diagram that illustrates the basic flow of a transaction between your application and the Anvil API.
The above flow diagram illustrates the basic flow of a transaction. The following sections will break down each step in detail. As you can see there are two API calls that are involved in the basic flow: Build and Submit. The Build API call is used to build a transaction, and the Submit API call is used to submit a transaction after the user or application has signed it.
The Build (POST /transaction/build
)API call is used to build a transaction. This call requires a payload that includes the sender address for change, UTXOs for inputs, and outputs.
Important Warning:
Use the
complete
format when you don't care about hiding metadata from the frontend client.For minting operations (NFTs/tokens), only exposing the
stripped
format of yourbuild
response helps hide metadata from the frontend client. Thecomplete
format will include those attributes allowing users to see the metadata before the transaction is submitted.
Once you have the signatures, we can submit POST /transaction/submit
the transaction in two ways:
Embed signatures in transaction: You can embed the signatures in the transaction. This is helpful when you are signing a transaction in a backend server (using CSL). Otherwise, option 2 is recommended.
Separate transaction and signatures: You can separate the transaction and signatures and send them to the API separately.
Cardano is Deterministic: The transaction hash returned by the build endpoint is the same hash that will appear on-chain. Unlike some other blockchains, Cardano's eUTXO model allows for deterministic transaction creation - the transaction ID is calculated before submission and remains unchanged when confirmed on the blockchain. This feature enables reliable transaction tracking from creation through confirmation.
Test on Preprod first to avoid risking real ADA.
Handle Errors gracefully: watch for 400 (bad request), 401 (unauthorized), or 429 (rate limit) responses.
Use CIP-30 for a user-friendly Web3 experience: fetch utxos
and changeAddress
directly from the user's connected wallet.
Validate JSON: Ensure your payload is correctly formed—typos in keys like lovelace can cause failures.
Include sufficient ADA: When sending native assets, include at least 2 ADA per output (due to min-UTXO requirements).
Verify addresses: Always double-check recipient addresses before submitting transactions.
Keep API keys secure: Never expose your API keys in client-side code.
Now that you have a basic understanding of how to send a transaction, explore how the Anvil API is flexible and can handle many types of transactions. Wether you are sending ADA and/or assets to multiple recipients, adding metadata to transactions, or handling multi-signature transactions, the Anvil API takes advantage of the full power of transactions on Cardano.
Review our guides below for more details. They provide practical examples of how to use the Anvil API transaction builder:
Sign the transaction with your preferred signing method (See ). This can be done using a CIP-30 compatible wallet, or by using a private key in your application, or by using a hardware wallet. We recommend using the wallet connector for a seamless experience handling interactions with Cardano wallets.