Testnet - Communicating with Tezos
So far we have used the Edonet script to execute tezos-client commands. This client communicates with the tezos-node.
Communication works with the help of the JSON/RPC interface. The tezos-node responses are JSON based. Notice it is not the JSON-RPC protocol, the communication is done over HTTP protocol.
Let's first list what the RPC offers:
$ ./edonet.sh client rpc list
This should list you the
GET/POST queries you can do.
Analogous to the previous section we want to get the balance first.
First, we need to see all the addresses in our wallet:
$ ./edonet.sh client list known addresses
myFirstKey from the last section and use its address to get the balance, replace the
MYFIRSTKEY_ADDRESS string in the following command with it:
$ ./edonet.sh client rpc get /chains/main/blocks/head/context/contracts/MYFIRSTKEY_ADDRESS/balance
Now you should see the balance. But where is the JSON we are talking about? Let's add a flag and use the command again:
$ ./edonet.sh client -l rpc get /chains/main/blocks/head/context/contracts/MYFIRSTKEY_ADDRESS/balance
This time you should see the HTTP requests and the JSON responses the client does.
You can find the reference for the JSON/RPC interface at the Tezos Developer Resource Documentation.
We can use the flag
-l for all commands from previous section. So, if you run the command:
$ ./edonet.sh client transfer 1 from faucetWallet to myFirstKey --burn-cap 0.5
from last section, you will see all the queries and responses traveling in the background.
We can also use
curl for a request
if you start the network and with an exposed RPC port:
./edonet.sh start --rpc-port 8732
Let's request the balance again:
curl -s localhost:8732/chains/main/blocks/head/context/contracts/MYFIRSTKEY_ADDRESS/balance
We could continue endlessly listing how different requests and their responses look. For the interested reader, we recommend checking out the full description.