Skip to content
A tool to convince an Ethereum DNSSEC oracle of the contents of DNS records
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
contracts
docs
lib
migrations
test
.babelrc
.gitignore
.npmignore
.readthedocs.yml
.travis.yml
README.md
package-lock.json
package.json
truffle-config.js
truffle.js

README.md

dnsprove.js

Functionalities

  • Fetches DNS information of given domain name and type
  • Validates DNS reponses and constructs proofs
  • Submits the proofs into DNSSEC(Domain Name System Security Extensions) Oracle smart contract
  • Works from both browser and from node.js

Installing

npm install '@ensdomains/dnsprovejs' --save

Usage

    var provider  = web3.currentProvider;
    var DnsProve  = require('dnsprove');
    var dnsprove  = new DnsProve(provider);
    var textDomain = '_ens.matoken.xyz';
    var dnsResult = await dnsprove.lookup('TXT', textDomain);
    var oracle    = await dnsprove.getOracle('0x123...');
    var proofs = dnsResult.proofs;

    if(dnsResult.found){
        await oracle.submitAll(dnsResult, {from:nonOwner});
    }else if (dnsResult.nsec){
        await oracle.deleteProof(
            'TXT', textDomain,
            proofs[proofs.length -1],
            proofs[proofs.length -2],
            {from:nonOwner}
        );
    }else{
        throw("DNSSEC is not supported")
    }

Alternatively, if you want to submit the proof not only to Oracle contract but also to claim via dnsregistrar, then you can call getAllProofs and pass the result into the proveAndClaim function.

    let dnsResult = await dnsprove.lookup('TXT', '_ens.matoken.xyz', address);
    let oracle    = await dnsprove.getOracle(address);
    let data = await oracle.getAllProofs(dnsResult, params);
    await registrar.methods
        .proveAndClaim(encodedName, data[0], data[1])
        .send(params)

API

Please refer to the doc

Testing

  npm run test
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.