如何查询RNS域名的有效期?

bgu*_*uiz 6 solidity rsk

除了直接查询之外,我还想订阅事件,以便在到期日期发生变化时(例如,续订时)监听事件

我发现NodeOwner.sol有一个 available函数 ,其实现看起来很有希望:

    function available(uint256 tokenId) public view returns(bool) {
        return expirationTime[tokenId] < now;
    }
Run Code Online (Sandbox Code Playgroud)

该文件还定义了一个 ExpirationChanged事件

    event ExpirationChanged(uint256 tokenId, uint expirationTime);
Run Code Online (Sandbox Code Playgroud)

我一直无法弄清楚的是:

  • 如何获取NodeOwner- 应查询哪个合约/地址?
  • 如果存在多个可能的地址/实例NodeOwner,或者只有其中之一。

Jes*_*ark 7

要获取单个域的过期时间,您可以使用RSKOwner带有该expirationTime方法的契约。您可以使用您感兴趣的域名查询此合同。

\n

在主网上,合约\xe2\x80\x99s 地址为,可以在RSK 浏览器0x45d3E4fB311982a06ba52359d44cB4f5980e0ef1上验证。可以在此处找到此合同的 ABI 。

\n

使用Web3库,您可以像这样查询单个域(例如testing.rsk):

\n
const rskOwner = new web3.eth.Contract(rskOwnerAbi, rskOwnerAddress);\n\nconst hash = `0x${sha3(\'testing\')}`;\n\nrskOwner.methods.expirationTime(hash).call((error, result) => {\n    console.log(\'expires at: \', result)\n})\n
Run Code Online (Sandbox Code Playgroud)\n

您可以在 RNS Manager 上看到一个工作示例

\n