Libraries

DnsProver

DnsProver allows you to lookup a domainname for a given DNS type and returns the DNS record and proofs which you can submit into DNSSEC Oracle.

DnsProver.lookup(type, query)

lookup takes DNS record type and name and returns DnsResult object.

Arguments:
  • type (string) – eg: TXT
  • query (string) – eg: _ens.yourdomain.xyz
Returns:

Object – DnsResult - contains list of results retrieved from DNS record and proofs which are constructed from the record and used to submit into DNSSEC Oracle

DnsProver.getOracle(address)

getOracle returns Oracle object

Arguments:
  • address (string) – DNSSEC Oracle contract address
Returns:

Object – Oracle - allows you to call DNSSEC oracle functions

Oracle

Oracle interacts with DNSSEC Oracle smart contract.

Oracle.knownProof(proof)

kownProof

Arguments:
  • proof (Object) –
  • proof.name (string) – eg ‘ethlab.xyz’
  • proof.type (type) – eg ‘TXT’
Returns:

Object – oracle_proof - contains list of results retrieved from DNS record and proofs

Oracle.submitAll(result, params)

submitAll submits all required proofs into the DNSSEC oracle as one transaction in a batch.

Arguments:
  • result (Object) –
  • params (Object) – from, gas, gasPrice, etc
Oracle.getAllProofs(result)

getAllProofs returns all the proofs needs to be submitted into DNSSEC Oracle. It traverses from the leaf of the chain of proof to check if proof in DNSSEC Oracle and the one from DNS record matches with valid inception value. This function is used so that it can pass the necessary proof to dnsregistrar.proveAndClaim function.

Arguments:
  • result (Object) –
Returns:

string – data

Returns:

Object – prevProof

Oracle.submitProof(proof, prevProof, params)

submitProof submits a proof to Oracle contract. If prevProof is null, the oracle contract uses hard-coded root anchor proof to validate the validity of the proof given. params is used to pass any params to be sent to transaction, such as {from:address}.

Arguments:
  • proof (Object) –
  • prevProof (Object) –
  • params (Object) – from, gas, gasPrice, etc
Returns:

boolean – success - returns true unless transaction fails

Oracle.deleteProof(type, name, proof, prevProof, params)

deleteProof deletes a proof

Arguments:
  • type (string) – eg: TXT
  • name (string) – eg: _ens.matoken.xyz
  • proof (string) –
  • prevProof (string) –
  • params (Object) – from, gas, gasPrice, etc
OracleProof(proof)
Arguments:
  • proof (Object) –
  • proof.inception (number) – time the signature was generated
  • proof.inserted (number) – time the record was inserted into DNSSEC oracle
  • proof.hash (string) – hash of proof stored in DNSSEC oracle
  • proof.hashToProve (string) – hash of proof constructed from DNS record
  • proof.validInception (boolean) – true if inception in DNSSEC oracle is older than the one from DNS record.
  • proof.matched (boolean) – true if inception is valid and hash is matched

Proof

Proof contains rrset and signature data which is submitted into DNSSEC Oracle.

Proof(name, type, sig, inception, sigwire, rrdata)
Arguments:
  • name (string) –
  • type (string) –
  • sig (string) –
  • inception (number) –
  • sigwire (string) –
  • rrdata (string) –
Proof.toSubmit()

toSubmit returns an array consisting of hex string of sigwiredata (concatinatd string of sigwire and rrdata) and its signature

Returns:array – data

DnsResult

DnsResult is an object returned by calling lookup function and contains information about the DNS record.

DnsResult(dns_result)
Arguments:
  • dns_result (Object) –
  • dns_result.found (boolean) – true if the given record exists
  • dns_result.nsec (boolean) – true if the given record does not exist and NSEC/NSEC3 is enabled
  • dns_result.results (Array) – an array of SignedSet containing name, signature, and rrs
  • dns_result.proofs (Array) – an array of proofs constructed using results
  • dns_result.lastProof (string) – the last proof which you submit into Oracle contruct