Skip to main content

DID

This page shows how to interact with the EVM compatible DID smart contract. Please refer to the Remix setup page if this is your first time using our network with Remix. This will teach you how to setup a remix environment, add our networks, deploy, and interact with your smart contract.

NOTE

Compatible Networks: agung, peaq

1. Setup Remix IDE

Get the proper setup in the Remix IDE website. Please visit the link:

When you go to Remix for the first time please create a new blank workspace for the precompiles.

2. Create new File

The next step is to create a file for the runtime module. These precompiles have been previously generated and the DID one in particular can be accessed at the file. Copy this file and paste it into a new file called DID.sol in your blank Remix environment.

3. Compile the Contract

After you have copied and pasted the DID.sol file from the peaq network node precompile page you are free to compile. Compilation generates an abi file that is needed for interaction of the previously deployed smart contract.

4. Get Contract

For environment select the Injected Provider - MetaMask and confirm that your chain id matches. Choose the account that has the token funds and for contract pick DID.sol.

  • Set 0x0000000000000000000000000000000000000800 found on top of the file in the address and click At Address. Doing so will allow you to interact with the peaq DID contract. Open up the contract as shown below to test functionality.

5. Interact with the Functions

The peaq did contract has 4 main functionalities that you can interact with: addAttribute, updateAttribute, removeAttribute, and readAttribute. evm-did-1

addAttribute

  • Parameters:

    • did_account: public's hex key (0x…)

      Substrate account - converted to hex format with website.

      Ethereum account - no conversion necessary.

    • name: hex representation of DID name data

    • value: hex representation of DID value data

    • validity_for: if you don't want to set it, please fill 0

  • Behavior: The same as extrinsic, peaqDid -> addAttribute

  • Result:

    • Please check the eth transaction (in MetaMask or in Remix)

    • Please check whether the EVM log appears in Remix's terminal

    • Please check whether this DID exist on the Substrate side (in agung polkadot.js recent events)

evm-did-2

removeAttribute

  • Parameters:

    • did_account: should be the public's hex key (0x…)

    • name: hex representation of DID name data you want to remove

  • Behavior: The same as extrinsic, peaqDid -> removeAttribute

  • Result:

    • Please check the eth transaction is okay

    • Please check whether the EVM log appears

    • Please check whether this DID remove on the Substrate side

evm-did-3

updateAttribute

  • Parameters:

    • did_account: should be the public's hex key (0x…)

    • name: hex representation of DID name data you want to update

    • value: hex representation of DID value data you want to update it to

    • validity_for: if you don't want to set it, please fill 0

  • Behavior: The same as extrinsic, peaqDid -> updateAttribute

  • Result:

    • Please check the eth transaction is okay

    • Please check whether the EVM log appears

    • Please check whether this DID change on the Substrate side

evm-did-4

readAttribute

  • Parameters:

    • did_account: should be the public's hex key (0x…)

    • name: hex representation of DID name data you want to read

  • Behavior: The same as RPC, peaqDid -> readAttributes

  • Result: Please check that you can get the related information under the readAttribute fields, information is displayed in "tuple: xxxx'

evm-did-5