Create Transaction with Metadata (CIP-20)

Adding human-readable messages to transactions (CIP-20)

Overview

Sometimes you want to attach a message, comment, or memo to a Cardano transaction—whether it's a receipt reference, a note for future auditing, or just user-friendly text. CIP-20 standardizes how these messages appear on-chain by using label 674 in transaction metadata. With the Anvil API, you can easily attach messages to your transactions with minimal configuration.

The Anvil API lets you supply a simple message or array of messages. Under the hood, Anvil auto-formats them for CIP-20 compliance:

  • Single string["Your message"]

  • Array of strings["Line 1", "Line 2"]

  • Long string → Automatically split across multiple array entries if it exceeds 64 bytes

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

Key Features

  • Simple message attachment to transactions

  • Automatic CIP-20 compliance formatting

  • Support for single strings or arrays of strings

  • Automatic handling of messages exceeding 64 bytes

Requirements

  • A Cardano wallet with sufficient ADA

  • 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>",
  "message": "Your message" // String or array of strings
}

CIP-20 Formatting

The Anvil API automatically formats your messages for CIP-20 compliance:

  • Single string["Your message"]

  • Array of strings["Line 1", "Line 2"]

  • Long string → Automatically split across multiple array entries if it exceeds 64 bytes

Best Practices

  • Keep messages concise and relevant

  • Consider privacy implications of on-chain messages

  • Test transactions on testnet before moving to mainnet

  • Remember that all on-chain metadata is publicly visible

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

Last updated

Was this helpful?