【问题标题】:How to query the expiry date for an RNS domain?如何查询RNS域名的到期日?
【发布时间】:2021-09-28 15:23:51
【问题描述】:

除了直接查询之外,我还想订阅事件以在到期日期更改时(例如续订时)进行监听

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

    function available(uint256 tokenId) public view returns(bool) {
        return expirationTime[tokenId] < now;
    }

并且同一个文件还定义了一个 ExpirationChanged event:

    event ExpirationChanged(uint256 tokenId, uint expirationTime);

我一直想不通的是:

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

【问题讨论】:

    标签: solidity rsk


    【解决方案1】:

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

    在主网上,合约地址为0x45d3E4fB311982a06ba52359d44cB4f5980e0ef1,可以在RSK explorer上验证。该合约的 ABI 可以在here找到。

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

    const rskOwner = new web3.eth.Contract(rskOwnerAbi, rskOwnerAddress);
    
    const hash = `0x${sha3('testing')}`;
    
    rskOwner.methods.expirationTime(hash).call((error, result) => {
        console.log('expires at: ', result)
    })
    

    你可以看到working example of this on the RNS Manager

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-03-22
      • 1970-01-01
      相关资源
      最近更新 更多