Register Names

Registration params

{
    chainId: 97,
    domainName: 'test001',
    duration: 1, // Unit (year)
    bulkRegistrarControllerAddress: '0xbd418F36bC5cAB3B3A81ecd9a6a461b454328d92',
    registrarAddress: '0xFe166d97c891A47c732c8b564A842e05dac10eD9'
}

import { Services, evm } from '@jazdid/jaz-did-sdk';

Get the price of registering a domain name

const renewPrice = await evm.bulkRegistrarController.getRenewPrice({
  bulkRegistrarControllerAddress,
  data: [
    {
      registrarAddress,
      domainNames: [{ name: domainName, duration: 1 }],
    },
  ],
}, {chainId});

// Response:
console.log('renewPrice, \n', JSON.stringify(renewPrice, null, 2));
{
  "0xFe166d97c891A47c732c8b564A842e05dac10eD9": {
    "test001": {
      "domainName": "test001",
      "durations": "31556952",
      "currency": "0x441950B67fc906756Dc0a1648bD07762182Db403", // Tokens used for payment
      "cost": "5000000000000000000"
    }
  }
}

Generate registration order

const { registarOrdersPrice, registarOrders } = await evm.bulkRegistrarController.registerByOrders(
  renewPrice, {chainId, account}
);

// Response:

// Subsequent, used when signing the order
console.log('registarOrders, \n', JSON.stringify(registarOrders, null, 2));
[
  {
    "chainId": 97,
    "registrar": "0xFe166d97c891A47c732c8b564A842e05dac10eD9",
    "name": "test001",
    "walletAddress": "0x089279aC5a9305B3F530d8439ae16cb678F48e31",
    "duration": "31556952"
  }
]

// Fees for registering a domain name
console.log('registarOrdersPrice, \n', JSON.stringify(registarOrdersPrice, null, 2));
{
  "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE": "0",
  "0x441950B67fc906756Dc0a1648bD07762182Db403": "5000000000000000000"
}

Coroutine Task

const coroutineTask = [
  // approve token
  evm.bulkRegistrarController.registerByApprove({ mixedRegistrarControllerAddress, registarOrdersPrice }),
  
  // Sign order
  evm.bulkRegistrarController.registerBySigner({
    registarOrders,
  }),
];

const [_1, registerSig, _2] = await Promise.all(coroutineTask);

// Execute wait time after signature
await evm.bulkRegistrarController.registerByWaitTime(mixedRegistrarControllerAddress, {chainId});

// Response

// Signed order data
console.log(JSON.stringify(registerSig, null, 2));

{
  "signed": [
    {
      "issuer": "0xa076C59bc18973861325BAec94A7BD010d94EC41",
      "registrar": "0xFe166d97c891A47c732c8b564A842e05dac10eD9",
      "owner": "0x089279aC5a9305B3F530d8439ae16cb678F48e31",
      "resolver": "0xDeDcF005618C8c130212ff29EBA2EeaD1125737E",
      "currency": "0x441950B67fc906756Dc0a1648bD07762182Db403",
      "duration": "31556952",
      "applyingTime": "1665554712",
      "name": [ 109, 117, 110, 105, 122, 48, 48, 50 ],
      "params": "0x",
      "v": 27,
      "r": "0xa026fba661c82e38d4a9126d46ec568d6c596c55e6806d7999776ef659c19385",
      "s": "0x2b6dc98b2c47cc887766734566e31e0eb100e6efb1d3c45c8b070942ee46da83"
    }
  ],
  "unsigned": []
}

Registeration name

const registerByPay = await Api.evm.bulkRegistrarController.registerByPay({
  mixedRegistrarControllerAddress,
  registarOrdersPrice,
  registerSig,
});

// This variable is used in the following (step 6) as a parameter 
// for judging the successful and failed registration of the domain name
const nameRegistered = registerByPay.events; 

Registration result

const registerByResult = await evm.bulkRegistrarController.registerByResult({
  registersByPay: nameRegistered,
  registarOrders,
});

// Response
console.log(JSON.stringify(registerByResult, null, 2));

{
  "success": [],
  "fail": []
}

Last updated