Manual TON DNS smart contract.
# 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 1GET methods can be queried by ./query.py <contract-name> <action> <arg1> .. <argN>.
-
dnsresolve(cat_id, name) -> (len, cell)-- resolvesnameinto address of given incat_idtype.namecan be domain or chain of subdomains separated by zero byte. Returnedlenis 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 zerocat_idwas 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 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 workchainwc. When running by means of./manage.fifspecial<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 indeployments/<contract-name>.pkanddeployments/<contract-name>.addrcorrespondigly. -
upsert(domain, seqno, cat_id, address)-- creates newaddressrecord withcat_idcategory for givendomain. In case when address with suchcat_idis already know for thisdomainit is replaced by a given new one. -
delete(domain, seqno, cat_id)-- deletes address record withcat_idcategory. If zerocat_idis given all records for this domain are dropped. -
upgrade(seqno, code)-- upgrades contract code with a new one. When running by means of./manage.fifcode is taken frommtdns.fif. -
transfer(seqno, pubkey)-- transfer contract account to a new owner with givenpubkey.
Tests assume that [ton-blockchain/ton#60] was applied to codebase. Run
make testto perform offline tesing of contract code.
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