diff --git a/README.md b/README.md index cd41da7..3447b49 100644 --- a/README.md +++ b/README.md @@ -26,14 +26,14 @@ $ cat list Captain Azylem Nelbert442 -Hansen33 +KingZulo $ ./dero_ns_cli.pl --check-list ./list Dero Name Service Cli Tool - register name to wallet Name: (Captain) is taken by this address (dero1qy9s60kf40wcwhcf9ay6dgpz3gh748x6eq0cpghs4m39u55ecnrlzqg0vq5sy) Name: (Azylem) is taken by this address (dero1qyfk5w2rvqpl9kzfd7fpteyp2k362y6audydcu2qrgcmj6vtasfkgqq9704gn) Name: (Nelbert442) is taken by this address (dero1qytygwq00ppnef59l6r5g96yhcvgpzx0ftc0ctefs5td43vkn0p72qqlqrn8z) -Name: (Hansen33) is taken by this address (dero1qy3dspltmkakl4gzpfvhc35kxxqpp2ypd9ehz72puyxhgs0sqglj6qgqt28kd) +Name: (KingZulo) is AVAILABLE to register ``` @@ -42,14 +42,28 @@ Name: (Hansen33) is taken by this address (dero1qy3dspltmkakl4gzpfvhc35kxxqpp2yp $ ./dero_ns_cli.pl --name KingZulo --register Dero Name Service Cli Tool - register name to wallet Name: (KingZulo) is AVAILABLE - and will be registered in a little while +Waiting [75/120]... +Wallet connected (127.0.0.1:10103) Checking wallet RPC (127.0.0.1:10103) Wallet connected (127.0.0.1:10103) Name: (KingZulo) registered on the DERO Stargate with TX ID (5f0abf21b897dc432a52633cdcbb47d68fde749a18b58764f39a696bd6eabb88) -Name: (KingZulo) is now registered to this address (dero1qy3dspltmkakl4gzpfvhc35kxxqpp2ypd9ehz72puyxhgs0sqglj6qgqt28kd) - Congratulations! - +Waiting for registration to complete [2/120]... +Name: (KingZulo) is now registered to this address (dero1qy3dspltmkakl4gzpfvhc35kxxqpp2ypd9ehz72puyxhgs0sqglj6qgqt28kd) +Congratulations your name was successfully registered! ``` (PS: If anyone want KingZulo I'm kinda willing to give it up) +#### Run on Test Net + +Specify testnet wallet rpc port and a daemon wallet rpc port like below + +``` + +$ ./dero_ns_cli.pl --name KingZulo --register --wallet-rpc 127.0.0.1:40403 --daemon-rpc 127.0.0.1:40402 + + +``` + ## Installation @@ -70,7 +84,7 @@ Dero Stargate * [https://dero.io/](https://dero.io/) * [https://github.com/deroproject/derohe/](https://github.com/deroproject/derohe/) -## More Dero Smart Contracts Used Here +## More about Dero Smart Contracts and how to use them * [Nameservice](https://docs.dero.io/rtd_pages/dev_dvm.html#nameservice) * [DVM Example](https://github.com/deroproject/documentation/tree/master/DVMDOCS/examples/nameservice) diff --git a/dero_ns_cli.pl b/dero_ns_cli.pl index 8ee28c2..64ff615 100755 --- a/dero_ns_cli.pl +++ b/dero_ns_cli.pl @@ -115,27 +115,38 @@ if ($options{'register'}) { $count++; } - if (check_wallet_rpc()) { printf "Wallet connected (%s)\n", $wallet_rpc; - my $reg = register($name); + my $reg; + my $reg_count = 0; + while ((not defined $reg or not exists $reg->{'result'}) and $reg_count < 3) { + $reg = register($name); - if (defined $reg and $reg->{'result'}) { - printf "Name: (%s) registered on the DERO Stargate with TX ID (%s)\n", $name, $reg->{'result'}->{'txid'}; - } else { - print "Error, something went wrong!\n"; + if (defined $reg and $reg->{'result'}) { + printf "Name: (%s) registered on the DERO Stargate with TX ID (%s)\n", $name, $reg->{'result'}->{'txid'}; + } else { + printf "Error, something went wrong! log saved -> (%s.log)\n", $0; + open my $FILE, '>>', sprintf '%s.log', $0 or die "Faile to open logfile for writing"; + print $FILE Dumper($reg); + close $FILE; + } + $reg_count++; + } + + if (not defined $reg or not exists $reg->{'result'}) { + print "Failed to register, please check log file..\n"; print Dumper($reg); exit 1; } - + my $reg_check; $count = 0; while (not defined $reg_check) { my $reg_check = check_name($name); if (defined $reg_check and $reg_check->{'status'} eq 'OK') { - printf "\rName: (%s) is now registered to this address (%s) - Congratulations!\n", $reg_check->{'name'}, $reg_check->{'address'}; + printf "\rName: (%s) is now registered to this address (%s)\nCongratulations your name was successfully registered!\n", $reg_check->{'name'}, $reg_check->{'address'}; last; } else { printf "\rWaiting for registration to complete [%d/%d]... ", $count, $max_wait; @@ -185,7 +196,7 @@ sub register { my $url = sprintf 'http://%s/json_rpc', $wallet_rpc; - my $status = decode_json( post_url($url, $data) ); + my $status = decode_json( post_url($url, $data) ); return $status;