Could you please explain the following to me. If I look at the account with data dir specified, I get this:
./goal account list -d ~/net1/PrimaryNode Please enter the password for wallet 'PrimeWallet': [offline] Unnamed-0 BYKWRWA6LM26WGSWTZJCR2I4JCO3SR4X3H2P7NNYSKZ2L72ZITVVJVFOG4 0 microAlgos *Default
But when I look at the same address without the -d option and ask for the balance I get this:
./goal account balance -a BYKWRWA6LM26WGSWTZJCR2I4JCO3SR4X3H2P7NNYSKZ2L72ZITVVJVFOG4 100020400 microAlgos
which is correct, because I send some from the dispenser and the testnet.
So why do I see two different things with the same public key? Furthermore, the receiving and sender account both show the [offline] status. So how can one receive or send Algos in any case.
These are two different networks. The first looks like you are using a private network. The second looks like testnet and you have the data directory as an env variable. If you run ps aux | grep algod you will probably see multiple algod processes running. The dispenser only works with TestNet. The Online field only has to do with participating in consensus not sending or receiving algos.
OK, understood, and yes but I want to send Algos from/to accounts in my private network to experiment a bit. How can I obtain Algos for my private network?
read -p “Press enter to send tokens”
echo “### Sending money from one account to another”
goal clerk send -a 10000 -f $NODEKEY -t $PRIMKEY -d test/Node
echo
API=(cat test/Node/algod.net)
APITOK=(cat test/Node/algod.token)
echo “api {API}"
echo "apitok {APITOK}”
echo “### Fetching transaction info”
for i in seq 1 5
do
sleep 5
LATEST=$(goal node status -d test/Node | grep “Last committed” | awk ‘{print $4}’)
echo LATEST
TXINFO=(curl -s -H “X-Algo-API-Token: APITOK" "http://{API}/v1/account/{NODEKEY}/transactions?firstRound=1&lastRound={LATEST}”)
echo TXINFO
if [ {#TXINFO} -gt 2 ]; then
break
fi
done
echo
read -p “Press enter to see specific block”
echo “### Show a specific block”
curl -H “X-Algo-API-Token: APITOK" "http://{API}/v1/block/${LATEST}”
echo
read -p “Press enter to stop and delete network”
echo “### Stop private network”
goal network stop -r test
goal network delete -r test
I have little experience in Shell scripting, so maybe you can help me out here.
Regarding the if statement, I don’t understand how you can compare TXINFO to an integer? And {#TXINFO} gave an error. I changed this to $LATEST. Also I had to replace all naked variable names from, for example, VAR to $VAR ($ sign in front) otherwise values would not parse. In any case, below the new version of my fiddle. It works now.
Another thing I had to change was to capture the output into an array and then retrieve the first value otherwise it would take the second part of the KEY as command — obviously that doesn’t work.
In any case thanks for the pointers. Now I’m going to see if I can create Wallets as well and do some stuff with that.
#!/bin/bash
set -e
IFS=' '
echo "### Creating private network"
goal network create -n tn50e -t networktemplate.json -r test
echo
echo "### Starting private network"
goal network start -r test
echo
echo "### Checking node status"
goal network status -r test
echo "### Importing root keys"
NODEKEY1=$(goal account list -d test/Node | awk '{print $2}')
read -ra NODEKEY <<< "$NODEKEY1"
PRIMKEY1=$(goal account list -d test/Primary | awk '{print $2}')
read -ra PRIMKEY <<< "$PRIMKEY1"
echo "Imported NODEKEY ${NODEKEY[0]}"
echo "Imported PRIMKEY ${PRIMKEY[0]}"
echo
read -p "Press enter to send tokens"
echo "### Sending money from one account to another"
goal clerk send -a 10000 -f ${NODEKEY[0]} -t ${PRIMKEY[0]} -d test/Node
echo
API=$(cat test/Node/algod.net)
APITOKEN=$(cat test/Node/algod.token)
echo "api = $API"
echo "and apitoken = $APITOKEN"
echo "### Fetching transaction info"
for i in seq 1 5
do
sleep 5
LATEST=$(goal node status -d test/Node | grep "Last committed block" | awk '{print $4}')
echo "===================="
echo "LATEST is $LATEST"
TXINFO=$(curl -s -H "X-Algo-API-Token: $APITOKEN" "http://$API/v1/account/$NODEKEY/transactions?firstRound=1&lastRound=$LATEST")
echo "TXINFO is: $TXINFO"
if [ $LATEST -gt 2 ]; then
break
fi
done
echo
read -p "Press enter to see information on block $LATEST"
echo "### Show latest block"
curl -H "X-Algo-API-Token: $APITOKEN" "http://$API/v1/block/$LATEST"
echo
read -p "Press enter to stop and delete network"
echo "### Stop private network"
goal network stop -r test
goal network delete -r test
hmm #TXINFO should not return an error. That should be giving you the length of the string. I think an issue you may be having with the original script is that you have a different network template than I do. This is what I used: