Nameservice
Register and associate a DERO wallet with a username using the Nameservice. It includes instructions for checking the availability of a username and the process to register it with the associated DERO wallet using specific cURL commands. Additionally, it provides notes for replacing the placeholder username and the reserved scid for nameservice registration.
Step 1
Check whether the username is already registered. You cannot register the username if it's already taken.
curl http://127.0.0.1:40402/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"nametoaddress","params":{"name":"TESTUSERNAME" }}' -H 'Content-Type: application/json'
Step 2
Register and associate a DERO wallet with the username.
curl http://127.0.0.1:40403/json_rpc -d '{"jsonrpc":"2.0","id":"0","method":"scinvoke","params":{"scid":"0000000000000000000000000000000000000000000000000000000000000001","ringsize":2, "sc_rpc":[{"name":"entrypoint","datatype":"S","value":"Register"}, {"name":"name","datatype":"S","value":"TESTUSERNAME" }] }}' -H 'Content-Type: application/json'
Note:
- Replace "TESTUSERNAME" with your desired available username in the above steps.
"scid":"0000000000000000000000000000000000000000000000000000000000000001"
is reserved for nameservice registration.
nameservice.bas
/* Name Service SMART CONTRACT in DVM-BASIC.
Allows a user to register names which could be looked by wallets for easy to use name while transfer */
// This function is used to initialize parameters during install time
Function Initialize() Uint64
10 RETURN 0
End Function
// Register a name, limit names of 5 or less length
Function Register(name String) Uint64
10 IF EXISTS(name) THEN GOTO 50 // if name is already used, it cannot be re-registered
20 IF STRLEN(name) >= 6 THEN GOTO 40
30 IF SIGNER() != address_raw("deto1qyvyeyzrcm2fzf6kyq7egkes2ufgny5xn77y6typhfx9s7w3mvyd5qqynr5hx") THEN GOTO 50
40 STORE(name,SIGNER())
50 RETURN 0
End Function
// This function is used to change owner
// owner is a string form of address
Function TransferOwnership(name String,newowner String) Uint64
10 IF LOAD(name) != SIGNER() THEN GOTO 30
20 STORE(name,ADDRESS_RAW(newowner))
30 RETURN 0
End Function