In addition to direct queries, I'd also like to subscribe to events to listen for whenever the expiry date changes (e.g. when it is renewed)
I've found that NodeOwner.sol
has an
available
function
whose implementation looks promising:
function available(uint256 tokenId) public view returns(bool) {
return expirationTime[tokenId] < now;
}
and that same file also defines an
ExpirationChanged
event:
event ExpirationChanged(uint256 tokenId, uint expirationTime);
What I haven't been able to figure out is:
NodeOwner
- which contract/ address should be queried?NodeOwner
, or there's only one of them.Checking the expiration date of a domain name is an easy process, by using the whatsmydns.net domain name expiry checker tool you can quickly and easily see the expiry date of a domain. When will a domain name expire?
As you can see above, the DomainSherpa.com domain name is due to expire on March 14, 2020, if not renewed prior to that date. ... If the domain name is renewed prior to the expiration date, or within 30 days thereafter (many registrars allow a grace period), an additional 1+ years is added to the domain name registration.
Depending on the type of domain name, they can take different periods to expire after registration or renewal. Some domain names have a minimum registration period of 2 years, however it is most common that they are registered for only 1. How long can a domain name be registered for?
This tool is quite simple – copy/paste a domain name into the text box and click “CHECK”. Our domain expiration checker will tell you if the domain is available (and give you a link to purchase it), or if the domain is registered and has an expiration date. You can add a reminder about the expiration date via our “Add to Google Calendar” button.
To get the expiration time of a single domain, you can use the RSKOwner
contract with the expirationTime
method. You can query this contract to with the domain you are interested in.
On Mainnet, the contract’s address is 0x45d3E4fB311982a06ba52359d44cB4f5980e0ef1
, which can be verified on the RSK explorer. The ABI for this contract can be found here.
Using Web3 library, you can query a single domain (such as testing.rsk) like this:
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)
})
You can see a working example of this on the RNS Manager.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With