Developer Guide
Resolve Utils

Resolve Utility Contract

A utility contract has been introduced to make the process of resolving names and addresses simpler, combining what used to be two steps into one. This contract is capable of resolving multiple names or addresses in a single operation.

The getNames() function implements a filter to return only names that have a forward pointing record to the same address, confirming the rightful ownership of those names.

Interface

pragma solidity >=0.7.0 <0.9.0;
 
interface IResolveUtils {
    function getAddresses(string[] names) returns (address[] addresses);
    function getNamehashes(string[] names) returns (bytes32[] nodes);
    function getNames(address[] addresses) returns (string[] names);
}

Functions

getAddresses(names)

  • Input a list of names to receive their corresponding addresses.
  • If a name is not configured, the function will return address(0).

ABI

{
  "inputs": [
    {
      "internalType": "string[]",
      "name": "names",
      "type": "string[]"
    }
  ],
  "name": "getAddresses",
  "outputs": [
    {
      "internalType": "address[]",
      "name": "addresses",
      "type": "address[]"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}

Example Calls

Connex
const {
  decoded: { addresses },
} = await connex.thor
  .account(contractAddress)
  .method({
    inputs: [
      {
        internalType: "string[]",
        name: "names",
        type: "string[]",
      },
    ],
    name: "getAddresses",
    outputs: [
      {
        internalType: "address[]",
        name: "addresses",
        type: "address[]",
      },
    ],
    stateMutability: "view",
    type: "function",
  })
  .call(["hello.vet", "test.vet"]);
Call-API
curl -XPOST https://api.vechain.energy/v1/call/main/0xA11413086e163e41901bb81fdc5617c975Fa5a1A \
-d '
{
  "clauses": [
    {
      "to": "0xA11413086e163e41901bb81fdc5617c975Fa5a1A",
      "abi": {
        "inputs": [
          {
            "internalType": "string[]",
            "name": "names",
            "type": "string[]"
          }
        ],
        "name": "getAddresses",
        "outputs": [
          {
            "internalType": "address[]",
            "name": "addresses",
            "type": "address[]"
          }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      "args": [
        ["hello.vet", "test.vet"]
      ]
    }
  ]
}
'

getNames(addresses)

  • Input a list of addresses to receive their verified primary names.
  • If a primary name is not configured or invalid, the function will return an empty string.

ABI

{
  "inputs": [
    {
      "internalType": "address[]",
      "name": "addresses",
      "type": "address[]"
    }
  ],
  "name": "getNames",
  "outputs": [
    {
      "internalType": "string[]",
      "name": "names",
      "type": "string[]"
    }
  ],
  "stateMutability": "view",
  "type": "function"
}

Example Calls

Connex
const {
  decoded: { names },
} = await connex.thor
  .account(contractAddress)
  .method({
    inputs: [
      {
        internalType: "address[]",
        name: "addresses",
        type: "address[]",
      },
    ],
    name: "getNames",
    outputs: [
      {
        internalType: "string[]",
        name: "names",
        type: "string[]",
      },
    ],
    stateMutability: "view",
    type: "function",
  })
  .call([
    "0x981ebf8f1f98465f93fd0208a0b5e531ddc37815",
    "0x105199a26b10e55300cb71b46c5b5e867b7df427",
  ]);
Call-API
curl -XPOST https://api.vechain.energy/v1/call/main/0xA11413086e163e41901bb81fdc5617c975Fa5a1A \
-d '
{
  "clauses": [
    {
      "to": "0xA11413086e163e41901bb81fdc5617c975Fa5a1A",
      "abi": {
        "inputs": [
          { "internalType": "address[]", "name": "addresses", "type": "address[]" }
        ],
        "name": "getNames",
        "outputs": [
          { "internalType": "string[]", "name": "names", "type": "string[]" }
        ],
        "stateMutability": "view",
        "type": "function"
      },
      "args": [
        ["0x981ebf8f1f98465f93fd0208a0b5e531ddc37815", "0x105199a26b10e55300cb71b46c5b5e867b7df427"]
      ]
    }
  ]
}
'

getNamehashes(names)

  • Input a list of names to receive their hashed node ids as bytes32.
  • Provides an on-chain-hashing procedure as ethers.namehash() replacement

ABI

{
  "inputs": [
    {
      "internalType": "string[]",
      "name": "names",
      "type": "string[]"
    }
  ],
  "name": "getNamehashes",
  "outputs": [
    {
      "internalType": "bytes32[]",
      "name": "nodes",
      "type": "bytes32[]"
    }
  ],
  "stateMutability": "pure",
  "type": "function"
}

Example Calls

Connex
const {
  decoded: { nodes },
} = await connex.thor
  .account(contractAddress)
  .method({
    inputs: [
      {
        internalType: "string[]",
        name: "names",
        type: "string[]",
      },
    ],
    name: "getNamehashes",
    outputs: [
      {
        internalType: "bytes32[]",
        name: "nodes",
        type: "bytes32[]",
      },
    ],
    stateMutability: "pure",
    type: "function",
  })
  .call(["hello.vet", "test.vet"]);
Call-API
curl -XPOST https://api.vechain.energy/v1/call/main/0xA11413086e163e41901bb81fdc5617c975Fa5a1A \
-d '
{
  "clauses": [
    {
      "to": "0xA11413086e163e41901bb81fdc5617c975Fa5a1A",
      "abi": {
        "inputs": [
          {
            "internalType": "string[]",
            "name": "names",
            "type": "string[]"
          }
        ],
        "name": "getNamehashes",
        "outputs": [
          {
            "internalType": "bytes32[]",
            "name": "nodes",
            "type": "bytes32[]"
          }
        ],
        "stateMutability": "pure",
        "type": "function"
      },
      "args": [
        ["hello.vet", "test.vet"]
      ]
    }
  ]
}
'