Skip to content

kelvich/mtdns

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

mtdns

Manual TON DNS smart contract.

Quick start

# compile func code
make

# inititalize new contract with name lunar
./manage.fif lunar touch 0

# now send some grams to non-bounceble address

# account state can be checked by running following command
./query.py acc lunar

# send query with initial code
./query.py send

# create message for domain creation and send it
./manage.fif lunar upsert gerty 1 1 0:d4cabf39992b9eac1f05584b608cf83dd569d9dd003f6a271ffafa7d2e2b7c47
./query.py send

# now it's possible to check how domain resolution works by running
./query.py dnsresolve lunar gerty 1 1

GET methods

GET methods can be queried by ./query.py <contract-name> <action> <arg1> .. <argN>.

  • dnsresolve(cat_id, name) -> (len, cell) -- resolves name into address of given in cat_id type. name can be domain or chain of subdomains separated by zero byte. Returned len is bit length of first found domain in chain if any. In other word for domain 'a.b.c' resolver will look up 'a.b.c', 'b.c' and 'c' and report first domain with requested category know by this contract. In case when requested domain or addres category are not found (0, null) is returned. If any of subdomain have address with special category '-1' (next resolver) then this address is returned irredargles of requested category. Returned address then should be used to resolve rest of subdomain chain. If zero cat_id was requested resolver will return dictionary with all registered records including records of type "-1". Domain names are case-sensitive and allow arbitrary utf symbols.

  • seqno() -- returns current seqno that should be used in next external message.

  • version() -- returns triple with current code version.

External message types

External messages can be generated by ./manage.fif <contract-name> <action> arg1 ... argN. Generated message will be saved in deployments/last-query.boc and can be sent by running ./query.py send. seqno for each external message should be looked up by the get method seqno().

  • touch(wc) -- create init message with code for the contract in workchain wc. When running by means of./manage.fif special <contract-name> handle should be given to store private key and address of this contract for later work. Private key and address will be saved in deployments/<contract-name>.pk and deployments/<contract-name>.addr correspondigly.

  • upsert(domain, seqno, cat_id, address) -- creates new address record with cat_id category for given domain. In case when address with such cat_id is already know for this domain it is replaced by a given new one.

  • delete(domain, seqno, cat_id) -- deletes address record with cat_id category. If zero cat_id is given all records for this domain are dropped.

  • upgrade(seqno, code) -- upgrades contract code with a new one. When running by means of./manage.fif code is taken from mtdns.fif.

  • transfer(seqno, pubkey) -- transfer contract account to a new owner with given pubkey.

Running tests

Tests assume that [ton-blockchain/ton#60] was applied to codebase. Run

make test

to perform offline tesing of contract code.

Error codes

33 -- wrong seqno

34 -- wrong signature

35 -- malformed domain name (name_bitlen % 8 != 0 or name_bitlen == 0 or name_bitlen > 126*8)

36 -- wrong cat_id (cat_id should be >= -1)

44 -- domain name intended for deletion was not found

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published