How to implement a Tezos alphanet node
It’s way easier to implement a node on a linux machine, if you’re on windows you can either run a virtual machine through virtual box or directly run every command through the docker command line.
For practical reasons I will work in a folder called “MyTezosAlphanet” but it should work in any folder. Once Created with “mkdir MyTezosAlphanet” navigate to your folder “cd MyTezosAlphanet”
mkdir MyTezosAlphanet
cd MyTezosAlphanet
once that is done we’ll download the docker image: alphanet.sh with the command
wget https://gitlab.com/tezos/tezos/raw/master/scripts/alphanet.sh
to make it executable we’ll use
chmod +x alphanet.sh
note that the command chmod +x alphanet.sh should be used everytime the image is updated.
we can now start the node with
sudo ./alphanet.sh start
the node is comprised of 3 entities: the client, the node and the baker.
the client is the side you’ll interact with the most, the node side is mostly used to manage the identities and comunicate with the rest of the network and last but not least the baker is the part used to “mine” blocks
For the node to connect to the network we need to generate a new identity we’ll go into the shell:
sudo ./alphanet.sh shell
once into the shell use
tezos-node identity generate
In order to synchronise the node with the rest of the network we need to use the command:
sudo ./alphanet.sh client bootstrapped
if the node is synced you should see something like that
if it’s already synced it will look like that
We’ll now create a simple wallet mine will use the alias BOB
with
sudo ./alphanet.sh client gen keys BOB
you can then get some tezies on the faucet: https://faucet.tzalpha.net this will download a json file that is a wallet.
to use it in our node we’ll have to activate an account to do so, exit the shell , place the json file in the same directory o alphanet.sh and enter the command:
sudo ./alphanet.sh client activate account alice with container:tz1___.json
replacing tz1__.json by the name of your file.
you can replace alice by any name for your account.
since I already had one mine will be alice2.
this step is a bit clunky don’t hesitate to retry it multiple times. if the error states that the file doesn’t exist in tmp, what worked for me was restarting the node.
once the wallet is active you can check the balance with:
sudo ./alphanet.sh client get balance for alice2
lets make your first transaction for that
we will use the the first keys we created “BOB” that has an account balance of 0tz and alice2 that has 3847.994464tz.
the command is :
sudo ./alphanet.sh client transfer 10 from alice2 to BOB --fee 0.05 --burn-cap 0.5
we can see that the trasaction has been processed and if we copy the transaction hash and copy it in th tezos explorer we can see the transaction.
lets see how smart contracts can be deployed
first of all you should get a contract, for that you can import the repo with “git clone https://gitlab.com/tezos/tezos.git”
this will add a folder to your current folder.
then deploy the first contract named first contract:
sudo ./alphanet.sh client originate contract FirstContract for alice2 transferring 1 from BOB running container:./tezos/src/bin_client/test/contracts/attic/id.tz -init ‘“hello”’ --burn-cap 0.0303
tezos-client transfer 0 from alice to id --arg '"world"' --dry-run
allows to test the way your call will behave.
but if you wan to use your contract you can use the following command
ezos-client transfer 0 from alice to id --arg '"world"' --gas-limit 1475 --storage-limit 46
you can also change the value written in te contract by recalling it and changing the value, you might need to update the burning cap if the cost of storage is bigger.