Using the blockchain
Checking status
Before continuing, you can verify things are working properly by entering into your browser:
http://<conainer_ip>:8732/chains/main/blocks/head
You should see some valid JSON being returned.
If not, try:
http://localhost:8732/chains/main/blocks/head
If things are not working correctly, you can look at the contents of the docker file:
base-dir/baker.log
Reminder: If you want to browse the file system inside your Docker container, you can run the command:
docker exec -it <container_name> bash
.
Transferring tokens
Once the protocol is activated, you can play with the new chain. For example, you can transfer some tokens from one account to another using octez-client
.
Importing a bootstrap account
We will use the alias 'alice' to refer to the bootstrap_account
entry with these values:
Hash: tz1akcPmG1Kyz2jXpS4RvVJ8uWr7tsiT9i6A
Public Key: edpktezaD1wnUa5pT2pvj1JGHNey18WGhPc9fk9bbppD33KNQ2vH8R
Secret Key: unencrypted:edsk2vKVH2BNwKrxJrvbRvuHnu4FW17Jrs2Uy2TzR2fxipikTJJ1aG
docker exec <container_name> /base-dir/octez-client \
--addr <container_ip> --port 8732 \
import secret key alice unencrypted:edpkubXzL1rs3dQAGEdTyevfxLw3pBCTF53CdWKdJJYiBFwC1xZSct
Account alice has 4,000,000 of Tez. Check it out with this command:
docker exec <container_name> /base-dir/octez-client \
--addr <container_ip> --port 8732 \
get balance for alice
The secret keys used here are unencrypted. This is unsafe in general but useful for the simplicity of the examples. Consider not using them if you care about security (even in a private blockchain without real money). In order to encrypt bakers and genesis secret keys, you can provide an
--encrypted
flag tofetch-binaries.sh
andstart-baker.sh
scripts.
Generate new account
Let's generate a new account named bob:
docker exec <container_name> /base-dir/octez-client \
--addr <container_ip> --port 8732 \
gen keys bob
You can acces to his address with this command:
docker exec <container_name> /base-dir/octez-client \
--addr <container_ip> --port 8732 \
show address bob
Hash: tz1UQiBLRbiWAUfGjZNUpNWKLvQez95ZXy2K
Public Key: edpkvRZrUoDqw7PpZ5wLHeDDjSLx9e1WJt3tGJKWUbXNt4CQz7tzFA
Bob has 0 Tez since we just created his account.
Now, let's transfer some Tez from alice to bob with this command:
docker exec <container_name> /base-dir/octez-client \
--addr <container_ip> --port 8732 \
--wait none transfer 100 from alice to bob --burn-cap 0.257
Finally, you can check that bob has indeed received 100 Tez
docker exec <container_name> /base-dir/octez-client \
--addr <container_ip> --port 8732 \
get balance for bob
100 ꜩ
Conclusion
To conclude, we have seen how to create a private blockchain by generating a genesis block and bootstrapping at least two bakers. These two bakers will validate the first blocks, allowing the realization of the first transactions of the blockchain.