Skip to main content

Metadata

Implements TZIP-16 norm for contract's metadata.

Repository


Author


Norm


Templates

Storage

metadata

The TZIP-16 metadata map is declared with the native with metadata declaration.

Entrypoints

set_metadata(k, d)

Adds or removes an entry to the metadata map.

Code


/* METADATA ---------------------------------------------------------------- */

entry set_metadata(k: string, d : option<bytes>) {
called by owner
require { md_r1 : is_not_paused() }
effect {
metadata.update(k, d)
}
}

entry string option bytes called by require effect metadata update

Parameters


k :

Medata entry name


v :

option<bytes>

Medata value option:
  • some(v) associates v to k
  • none removes entry k

Fails with

"INVALID_CALLER"

When caller is not owner


"CONTRACT_PAUSED"

When contract is already paused.


Related

Example

Below is a typical metadata file:

my_dapp_metadata.json
{
"name": "My Dapp",
"description": "A description of My Dapp",
"version": "1.0",
"license": { "name": "MIT" },
"authors": ["Mysterious team <contact@my_company.com>"],
"homepage": "https://my_dapp.com",
"interfaces": ["TZIP-012", "TZIP-016", "TZIP-017", "TZIP-021"]
}

There are 2 ways to associate this metadata to a contract:

  1. upload the file to a public URI (typically ipfs) and store the URI in the contract's metadata map (as the value of key "")
  2. store metadata fields in the contract's metadata map

The association may be done at deployment time with Completium CLI:

With public URI:

completium-cli deploy my_dapp.arl --metadata-uri "ipfs://..."

With stored metadata:

completium-cli deploy my_dapp.arl --metadata-storage "./my_dapp_metadata.json"

This can also be done once the contract is deployed with the set_metadata entrypoint:

completium-cli call my_dapp --entry set_metadata --arg '{ "k": "", "v": "0x697066733a2f2f ..." }'

Note that the URI is sent in bytes format.