2. Metadata section

Now let’s start the "metadata" section.

ℹ️

The goal of the "metadata" section is to provide the metadata that can be displayed to the user when interacting with the contract/message defined in this file.

This section is typically used to:

  • Provide displayable information about the recipient of the contract call / message
  • Provide displayable values of enumeration or encoded id parameters, typically smart contract / message specific
  • Provide common constants used by the various formats defined in the file

In this example, the metadata section contains only the recipient information, in the form of a displayable name (owner key) and additional information (info key) that MAY be used by wallets to provide details about the recipient.

    "metadata": {
        "owner": "Tether",
        "info": {
            "legalName": "Tether Limited",
            "url": "https://tether.to/",
            "deploymentDate": "2017-11-28T12:41:21Z"  
        }
    },
For EIP-712 messages

We define what we want to display regarding the target of our EIP-712 message. In our previous example from 1inch:

"metadata": { 
    "owner": "1inch Limit Order Protocol" 
},

For EIP-712 messages, owner is the verifying contract.

a. Minimum: Owner & info

The most basic version is the one from this example, which only specifies Owner & Info. This info will be displayed on the screen when interacting with the contract.

Blind sign risk

b. Advanced

You can go further with the metadata section.

Using enums

You can define enums to convert values using referenced constant enumeration values. It is useful to replace specific parameters values with human-readable ones. Take a look at the following example in the Aave json file from the registry:

  "metadata": {
    "owner": "Aave",
    "info": { "url": "https://aave.com", "legalName": "Aave DAO", "deploymentDate": "2024-10-09T21:46:47Z" },
    "enums": { "interestRateMode": { "1": "stable", "2": "variable" } },
    "constants": { "max": "0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff" }
  },
  "display": {
   …
            "format": "enum",
            "label": "Interest rate mode",
            "params": { "$ref": "$.metadata.enums.interestRateMode" }
          },

Basically, the result is that if the value returned by interestRateMode is 1, the hardware wallet will display the text “stable”, and if it’s 2, it will display “variable”. By specifying the enum one time in the metadata section, you can refer to it easily wherever you want in the rest of the file.

Blind sign risk

Using constants

A constant can be defined in the metadata, and then be referenced in the rest of the file. This is mostly to keep your file as clean as possible, and avoid repeating longer strings, like addresses for instance. Take a look at the following example in the Paraswap json file from the registry:

  "metadata": {
    "owner": "Paraswap",
    "info": { "url": "https://www.paraswap.io/", "legalName": "ParaSwap", "deploymentDate": "2021-08-18T12:42:05Z" },
    "constants": { "addressAsEth": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" }
  },
  "display": {
    "definitions": {
      "sendAmount": {
        "label": "Amount to Send",
        "format": "tokenAmount",
        "params": { "tokenPath": "fromToken", "nativeCurrencyAddress": "$.metadata.constants.addressAsEth" }
      },
      "minReceiveAmount": {
        "label": "Minimum to Receive",
        "format": "tokenAmount",
        "params": { "tokenPath": "toToken", "nativeCurrencyAddress": "$.metadata.constants.addressAsEth" }
      },

As you can see, in the metadata section we define the constant "constants": { "addressAsEth": "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE" }. Thanks to this, in the rest of the file we can just call that constant with "$.metadata.constants.addressAsEth" instead of having to rewrite the address every time.

Using tickers

Instead of getting the default ticker from etherscan, you can specify it yourself. This is very situational, and in most cases the ticker from etherscan will be enough, but it’s good to know in some cases.

"metadata": {
        "owner": "Tether",
        "info": {
            "legalName": "Tether Limited",
            "url": "https://tether.to/",
            "deploymentDate": "2017-11-28T12:41:21Z"  
        },
        "token": {
            "ticker": "USDT",
            "name": "Tether USD",
            "decimals": 6
        }
    },

You can find more examples of metadata usage:

Ledger
Copyright © Ledger SAS. All rights reserved. Ledger, Ledger Stax, Ledger Nano S, Ledger Vault, Bolos are trademarks owned by Ledger SAS