Minting sUDT on Nervos TestNet via the command line
This tutorial walks through the steps to mint an sUDT (simple user defined token) on Nervos testnet using command line tools and a Mac.
It is based on a video created by Cipher in Chinese which was translated into a new video by Luis. I go into a bit more detail than the videos and address some of the main issues I faced while following the previous tutorials.
Here is the original video by Cipher (reuploaded to Youtube)
And here is the video in English by Luis
My tutorial walks through what is shown in these videos. Sometimes it is easier to follow a written tutorial than a video, but the content is 99% identical.
First we need to download Golang
Direct Link
https://golang.org/doc/install?download=go1.14.4.darwin-amd64.pkg
Open the package installer
Next Download CKB 0.33.0
https://github.com/nervosnetwork/ckb/releases
Find the location of the CKB zip
Unzip locate the folder
Open terminal
Type “cd “ (note the space) and drag the folder you just downloaded. Press ENTER. This will navigate you to the folder containing CKB
Type “./ckb — version” hit enter, you will get an error message that ckb cannot be opened.
Press Cancel
Open up System Preferences
Click Security and Privacy
Click Allow anyways
Go back to terminal and press the up arrow, bringing up the last command “./ckb — version” press enter, this time you get a different pop up
Click Open. It will display your version number v0.33.0
Now we are going to do the same update to permissions for ckb-cli.
Type “./ckb-cli — version” press enter
Press Cancel. Now move over to System Preferences, and open Security and Privacy
Click Allow Anyway, now run the command again (press up) “./ckb-cli — version” press enter
Press Open, and you get the response ckb-cli 0.33.1
Now we need to initialise the blockchain.
Type “./ckb init — chain testnet”
WARN: mining feature is disabled because of lacking the block assembler config options
Initialised CKB directory in /Users/jonathancaras/Downloads/ckb_v0.33.0_x86_64-apple-darwin
create ckb.toml
create ckb-miner.toml
Now let’s run our node “./ckb run”
About 10 times while creating this tutorial something didn’t work, 100% of the time it was because the node had stopped running. Poor internet, putting my computer to sleep, changing wifi networks all seemed to crash the node. If you find something does not work in the tutorial, close the Terminal tab running the node, and perform this step to restart the node, that should fix the problem.
Open a new Terminal Tab
Download ckb-udt-cli from here https://github.com/ququzone/ckb-udt-cli
Open the ZIP in finder
Unzip the folder, and as we did before, open Terminal, type “cd “ and drag the folder you just unzipped, auto filling the correct path to the folder.
We are now going to follow the build instructions from the ReadMe file
Type in the following commands
export GOPROXY=https://goproxy.io
go mod download
go build .
It took a few minutes for these commands to finish
Now we need to go back to the folder where we have ckb-cli downloaded
Type “cd “ and drag in the folder and press enter.
Now we make a new account on testnet using commands from the mostly Chinese website https://docs.ckb.dev/
. Type “./ckb-cli account new”
Type in a password, write down your password somewhere so you dont lose it. You will need to type the password twice.
You will generate an address.
Copy this info in a text editor or somewhere else. My address wont be the same as yours, here is what I got.
address:
mainnet: ckb1qyq28r846gr5xzg8pg2gyplelhtapp40exvq0lrjck
testnet: ckt1qyq28r846gr5xzg8pg2gyplelhtapp40exvqj6ad52
lock_arg: 0xa38cf5d2074309070a148207f9fdd7d086afc998
lock_hash: 0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f
Now we will export
Type “./ckb-cli account export — extended-privkey-path wallet — lock-arg “ and then paste the lock_arg you got from the previous step.
My full line was “./ckb-cli account export — extended-privkey-path wallet — lock-arg 0xa38cf5d2074309070a148207f9fdd7d086afc998”
You will get a request to type in your password, after that hit enter and you should get a confirmation that a wallet file was created
You can take a look in the folder and confirm the wallet file was created
Now let’s get our private keys. Type “cat wallet”
Copy your private key so we can use it later. Notice how it’s two lines, as far as I am aware, we will only be using the first line.
9824f6d178e5dc14343d07e444f1a0553cd7c8617aa1e10cdb549f4e426cafd1
c7413827c6822eca5717dc573106730423a5320a824988aea779523b7d9e32c7
Next we will go get some sweet testnet CKB from a faucet.
Put in your testnet wallet address mine is ckt1qyq28r846gr5xzg8pg2gyplelhtapp40exvqj6ad52
You should see your claim pending
After a few minutes it will update
Now let’s check we have the CKB
https://explorer.nervos.org/aggron/
To look up the address I put in the faucet, I use this link
https://explorer.nervos.org/aggron/address/ckt1qyq28r846gr5xzg8pg2gyplelhtapp40exvqj6ad52
Now we go back to Terminal and navigate to the folder for ckb-udt-cli-master
No we can issue tokens, in order to do this we will need to make customize the command with the private key we generated.
The command for issuing is found on the Readme here https://github.com/ququzone/ckb-udt-cli
./ckb-udt-cli issue -c config.yaml -k YOUR_PRIVATE_KEY -a AMOUNT
My private key was exported in two lines from our previous “cat” action
9824f6d178e5dc14343d07e444f1a0553cd7c8617aa1e10cdb549f4e426cafd1
C7413827c6822eca5717dc573106730423a5320a824988aea779523b7d9e32c7
For amount, we are going to issue 500 tokens.
NOTE: I screwed up here. The default decimals of a token is 10^-8. which means you need to add 8 zeros after your token. I only learned that once I minted the tokens, so if you want to mint 500 tokens, you need to put
500 0000 0000
if I wanted to mint 21 million
that would be 21,000,000 0000 0000
So my complete command is
./ckb-udt-cli issue -c config.yaml -k 9824f6d178e5dc14343d07e444f1a0553cd7c8617aa1e10cdb549f4e426cafd1 -a 500
And my sUDTs have been minted!
I got the response
Jonathans-MacBook-Pro-2:ckb-udt-cli-master jonathancaras$ ./ckb-udt-cli issue -c config.yaml -k 9824f6d178e5dc14343d07e444f1a0553cd7c8617aa1e10cdb549f4e426cafd1 -a 500
Issued sUDT transaction hash: 0x13ad9fc234ae829992e9ddf781f446eda98af753e30c39aeb2a6f601059a0f86, uuid: 0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f
Notice here we never named the token, on the blockchain, the tokens are distinguished from one another by their UUIDs. Later when we want to send tokens, we will need to reference this UUID
0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f
Now I will check out the transaction hash on the explorer
Make sure you are looking at the testnet
My hash is 0x13ad9fc234ae829992e9ddf781f446eda98af753e30c39aeb2a6f601059a0f86
, so this is what I will search.
I clicked Cell info next to my UDT (Unknown Token)
And let’s look at the Type Script
And the Data
Here we can see we minted 500 tokens!
Lets convert that Little Endian HEX to a decimal
http://www.save-editor.com/tools/wse_hex.html#hex
Now let’s open the GUI Wallet Neuron, we will need to install it if you dont have it
Installing the Wallet
https://github.com/nervosnetwork/neuron/releases
I downloaded the DMG file and dragged it into my applications folder
I double clicked the application and tapped open
If you are opening the wallet for the first time, you will need to create a wallet
I created a new wallet with the seed
slide item middle veteran envelope climb dignity west box trick column never
passwordD1
Now take a look at the wallet address
Notice it starts with ckt not ckb, this means it is connected to testnet not mainnet.
This is a bit confusing, but click the word Mainnet
You will see that it is testnet you are connected to
Close this window
Click the Experimental button “Customized Assets” and “Asset Accounts”, you will get a warning, press ok.
You have no assets in this wallet now.
Now let’s get the address of this wallet so we can transfer some of our new UDTs, navigate to Receive on the left middle of the wallet
Click the address starting with ckt,
my address is ckt1qyqp2j44sgpzpd8jk9ydtl6g6635kudyxdsssvxqm5
Copy your address somewhere
If we want to transfer, we can look that up in the documentation
https://github.com/ququzone/ckb-udt-cli
We will use the command
./ckb-udt-cli transfer -c config.yaml -k YOUR_PRIVATE_KEY -u UUID -t RECIPIENT_ADDRESS -a AMOUNT
We need to replace some info here. I will transfer 15 tokens
The UUID is the one we got from
./ckb-udt-cli transfer -c config.yaml -k 9824f6d178e5dc14343d07e444f1a0553cd7c8617aa1e10cdb549f4e426cafd1 -u 0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f -t ckt1qyqp2j44sgpzpd8jk9ydtl6g6635kudyxdsssvxqm5 -a 15
Jonathans-MacBook-Pro-2:ckb-udt-cli-master jonathancaras$ ./ckb-udt-cli transfer -c config.yaml -k 9824f6d178e5dc14343d07e444f1a0553cd7c8617aa1e10cdb549f4e426cafd1 -u 0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f -t ckt1qyqp2j44sgpzpd8jk9ydtl6g6635kudyxdsssvxqm5 -a 15
transfer transaction hash: 0xb3c4375272f770fb2965608f6ea0434d9bd94e0e7165cc1537a012bed0efc626
Jonathans-MacBook-Pro-2:ckb-udt-cli-master jonathancaras$
Now we can look up the transaction based on the transfer transaction hash: 0xb3c4375272f770fb2965608f6ea0434d9bd94e0e7165cc1537a012bed0efc626
Now we hop over to Neuron, and check the history
We see that we got some tokens!
I click on the green explorer button on the bottom right and it takes me back to the explorer
Let’s see how many tokens we got, the first UDT output is probably the tokens we received in our Neuron wallet, lets look at the data.
0x0fhex
Jumping back to our HEX converter
http://www.save-editor.com/tools/wse_hex.html#hex
We see we received 15 tokens!
We can also look up the balance via the command line.
Hop over to Terminal and use this command
./ckb-udt-cli balance -c config.yaml -u UUID -a ADDRESS
Putting in my variables…
./ckb-udt-cli balance -c config.yaml -u 0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f -a ckt1qyqp2j44sgpzpd8jk9ydtl6g6635kudyxdsssvxqm5
Jonathans-MacBook-Pro-2:ckb-udt-cli-master jonathancaras$ ./ckb-udt-cli balance -c config.yaml -u 0x53d22825d8e8e0057b43c6dfb57133e054db159a2497c81e78a9dfbcdba0208f -a ckt1qyqp2j44sgpzpd8jk9ydtl6g6635kudyxdsssvxqm5
Address ckt1qyqp2j44sgpzpd8jk9ydtl6g6635kudyxdsssvxqm5 amount: 15
Tada!! 15 tokens at the recipient address!
Now we want our sUDT to be recognizable, I will name mine Caras
In order to do this we will need to submit the token information to the explorer
Navigate to the site
https://explorer.nervos.org/aggron/tokens
And click the link in the top right corner, Submit Token Info
This will open up an email form.
Make sure to open with gmail (its the best)
Now lets fill out this information
Ok, this is a lot of info they are asking.
We know that my token is currently called UDT #644a
I’m going to use the transaction hash that was generated when I created the tokens.
0x13ad9fc234ae829992e9ddf781f446eda98af753e30c39aeb2a6f601059a0f86
And click “Cell Info”
Title: Submit Token Information
Type Script:
Code Hash:
Hash Type:
Args:
Information:
Full Name: 32 length max
CARAS
Symbol: 8 length max / ASCII
CARAS
Decimal: 8 (default)
8
Description:
Caras Coin
Website:
Icon File: attachment (40 x 40)
Other Info:
And then press SEND
It will take 24 hours for the site to be updated, but we did it.
UPDATE: We are live, look at that good looking Caras token!
Thanks for following this tutorial.
Thanks to Cipher, and Luis for making this tutorial possible.
If you have any problems, please message me on telegram @madcapslaugh and follow me on twitter.