Address Reconstruction
In a Native collection, when a new Item is minted, the generated objectId value corresponds, after hexadecimal conversion, to the address of the ERC20 token created.
1
//The function to call in a Native EthItem Collection is
2
//function mint(uint256 amount, string calldata tokenName, string calldata tokenSymbol, string calldata objectUri, bool editable) external returns(uint256 newObjectId, address interoperableInterfaceAddress);
3
4
//Let's suppose the call returns you the following values:
5
6
var objectId = "115229128895248074900976864697884278495202009447";
7
var interoperableInterfaceAddress = "0x142f0d872a9579c61098c783aed1c5f9404c6167"
8
9
//The HEX version of the objectId is EXACTLY the address of the created ERC20 Token
10
11
var builtAddress = web3.utils.toHex(objectId);
12
13
//-> will exactly return 0x142f0d872a9579c61098c783aed1c5f9404c6167, which is equal to the original interoperableInterfaceAddress value.
14
15
//Now let's retrieve back the objectId from the interoperableInterfaceAddress
16
17
//Convert in abi
18
var abiEncodedValue = web3.eth.abi.encodeParameter('address', interoperableInterfaceAddress);
19
20
//-> will generate the value "0x000000000000000000000000142f0d872a9579c61098c783aed1c5f9404c6167"
21
22
//Convert in uint256
23
var builtObjectId = web3.eth.abi.decodeParameter('uint256', abiEncodedValue);
24
25
//-> will exactly return "115229128895248074900976864697884278495202009447", which is equal to the original objectId value.
Copied!
Copy link