This example demonstrates how to create a transaction with metadata using the Anvil API. CIP-20 provides a standardized way to include human-readable messages in Cardano transactions using metadata label 674.
For more information about transactions, please refer to the .
Objectives
This example creates a transaction with a CIP-20 compliant message on the Preprod network.
Requirements
A Cardano wallet with ADA
A valid API key
Bash shell environment
API Request Structure
Payload Format
{
"changeAddress": "addr_sender...",
"message": "Your message" // String or array of strings
}
{
"changeAddress": "addr_sender...",
"message": ["Receipt 42", "Minted by Anvil"]
}
Auto-split for Long Messages
For messages exceeding 64 bytes, the API automatically splits them:
{
"changeAddress": "addr_sender...",
"message": "A very long message to demonstrate the auto-split feature. I need more words"
}
Will be formatted as:
{
"msg": [
"A very long message to demonstrate the auto-split feature. I nee",
"d more words"
]
}
Implementation
Configuration and Parameters (using Bash and cURL)
Using a preprod wallet for the transaction
ADDRESS="addr_test1qrvx8wgdndrk98qf62vka3q4fglchk7h940vepdtgcv9fuu0e0aeuac6j2xhz77esaaudku68ha89qesqvd29pmuzw6qk8xkcn"
# See Authentication page for API key details.
X_API_KEY="testnet_EyrkvCWDZqjkfLSe1pxaF0hXxUcByHEhHuXIBjt9"
API_URL="https://preprod.api.ada-anvil.app/v2/services"