Skip to main content
Step-by-step instructions for calling the EVM-compatible Decentralized Identifier (DID) precompile and running its main functions. This applies to both the peaq and agung networks. The JavaScript SDK calls this precompile under the hood: a call triggers the corresponding Substrate extrinsic.

Prerequisites

  • Basic understanding of blockchain, EVM, and DID concepts.
  • Using the Remix IDE with MetaMask configured to interact with a peaq network.
  • You have token funds available in the wallet connected to a peaq network.

Instructions

1. Setup Remix IDE

  • Open the Remix website.
  • Create a new blank workspace for the precompiles.

2. Create a New File

  • In your Remix workspace, create a new file named DID.sol.
  • Copy the content of the DID precompile file from the peaq network node precompile page and paste it into the DID.sol file. The precompile is found at the peaq node source code.

3. Compile the Contract

  • Compile the DID.sol file by clicking on the Solidity Compiler tab and selecting the appropriate compiler version.
  • Ensure the compilation is successful and generates the ABI file needed for interacting with the smart contract.

4. Deploy and Interact with the Contract

  1. Under the Deploy and Run Transactions tab, select Injected Provider - MetaMask as the environment.
  2. Ensure your chain ID matches the selected network (peaq/agung).
  3. Choose the account with sufficient token funds.
  4. Set the contract address to 0x0000000000000000000000000000000000000800 (found at the top of the copied file).
  5. Click At Address to load the deployed contract into the interface.
On the bottom left of the Remix interface you will get the following functions you can interact with: did-precompile-1

5. Interact with the Functions

addAttribute

To add a DID Document as a value please generate the value via the Serialized DID section in the JavaScript SDK Reference. Otherwise you can set your own custom data to set with.
  • Parameters:
    • did_account: EVM address of the DID account (e.g., 0x…).
    • name: Hex representation of the DID name data.
    • value: Hex representation of the DID value data.
    • validity_for: Number of blocks the attribute stays valid. Set to 0 for no expiry.
  • Behavior: Adds a new attribute to the DID.
  • Result:
    • Verify the transaction in MetaMask or Remix.
    • Confirm EVM logs in the Remix terminal.
    • Confirm the attribute on the Substrate side in Subscan.

removeAttribute

  • Parameters:
    • did_account: EVM address of the DID account (e.g., 0x…).
    • name: Hex representation of the DID name data to be removed.
  • Behavior: Removes an existing attribute from the DID.
  • Result:
    • Verify the transaction in MetaMask or Remix.
    • Confirm EVM logs in the Remix terminal.
    • Ensure the attribute is removed on the Substrate side.

updateAttribute

  • Parameters:
    • did_account: EVM address of the DID account (e.g., 0x…).
    • name: Hex representation of the DID name data to be updated.
    • value: Hex representation of the new DID value data.
    • validity_for: Number of blocks the attribute stays valid. Set to 0 for no expiry.
  • Behavior: Updates an existing attribute of the DID.
  • Result:
    • Verify the transaction in MetaMask or Remix.
    • Confirm EVM logs in the Remix terminal.
    • Ensure the attribute is updated on the Substrate side.

readAttribute

  • Parameters:
    • did_account: EVM address of the DID account (e.g., 0x…).
    • name: Hex representation of the DID name data to be read.
  • Behavior: Reads the value of an existing DID attribute.
  • Result:
    • Confirm the attribute information in the readAttribute field.
    • Data is displayed as a tuple (e.g., tuple: xxxx).

For more exhaustive definitions please look at the DID Operations in the SDK.