Documentation
¶
Overview ¶
Algorand Helper Tools
The open-source, command-line tools inspect the Algorand blockchain, and also compose, sign, and submit transactions to Algorand. See https://www.algorand.com/.
Install
go get src.d10.dev/algo/cmd/...
Configure ¶
Algo tools require an `algod` node. Set up the node first, then put the connection details into file `$HOME/.config/algo/algo.cfg`. For example if Algorand has provided you a token to use with the "hackathon" testnet node, the file looks like this:
[algod] address = http://hackathon.algodev.network:9100 token = _PASTE_TOKEN_HERE_
Using a testnet node is recommended to follow the tutorial below. When the time comes to use mainnet, your algo.cfg might look like this:
[algod] address = https://api.algoexplorer.io
Tutorial ¶
Here's a description of how to send algos from one account to another.
First, create two accounts:
algo-key generate -count=2
The `algo-key generate` operation saves secret key information to two files named ADDRESS.algo-key. These contain private key information, so do not share them with anyone. Don't move or rename the files, as `algo-key` will find them by address when signing later in the tutorial.
Next, create a (paper) backup of the private key information:
algo-key backup -nick DEMO *.algo-key
This command runs interactively, you will be prompted on the command line. When shown the secret mnemonic, write it down and store the copy securely. (Optionally, skip writing down the mnemonic for testnet accounts; however, do run `algo-key backup` because doing so create additional configuration files.)
The "-nick DEMO" argument gives the new accounts nicknames. This will make them easy to refer to. In this example, two configuration files "DEMO1.cfg" and "DEMO2.cfg" should be created by `algo-key backup`. These configuration files include newly created public addresses. The ".cfg" files are not secrets, the ".algo-key" files are secrets.
Next, move the address configuration files where `algo` can find them:
mv *.cfg $HOME/.config/algo/
Check the balances on these accounts. They are brand new, you will see zero algos.
algo account DEMO1 DEMO2
Note that the "-v" flag makes `algo` more verbose. Try:
algo -v account DEMO1
to see the entire address of the account with nicknam "DEMO1". Copy the full address. If using testnet, visit the Algorand testnet faucet. Paste the address there to receive testnet algos.
At this point, you should have a balance of algos in DEMO1 account. The remainder of this tutorial constructs a payment to send ten algos from DEMO1 to DEMO2.
Use `algo payment` to compose a pay transaction:
algo -as DEMO1 payment DEMO2 10
Note that "-as ADDRESS" is a flag on the `algo` command that specifies which account must sign the transaction. In the case of payment, it is the originating account. The next argument, `payment`, is the "operation" of the `algo` command; in this case, construct a payment transaction. The final arguments specify the beneficiary "DEMO2" and the amount, 10 algos.
The output of `algo payment` is a JSON-encoded transaction. The details are not important, but if you're curious, you can inspect the output and see the amount field (note that it is micro-algos), the transaction fee, and all the other details. Address are encoded differently in the JSON, so don't be surprised not to see the full address of DEMO1 or DEMO2.
Note that `algo payment` composed a transaction but did nothing else. To complete the payment, we must sign and submit the transaction. In Algo tools, the compose, sign, and submit steps are three distinct operations. This allows signing to be isolated to a secure environment. For convenience though, the three steps can be "pipelined" together, and that's what we'll do next:
algo -as DEMO1 payment DEMO2 10 | algo-key sign | algo submit
The above pipeline composes a transaction, exactly as before. The JSON-encoded transaction is sent to `algo-key sign`, which adds a signature. To do so, `algo-key` must find the ".algo-key" file that was created earlier. Finally the transaction with signature is sent to `algo submit`, which broadcasts the transaciton to our `algod` node, and from there to the entire network.
Lastly, check that our account balances have changed. You should see that DEMO2 now has a positive balance:
algo account DEMO1 DEMO2
Note that `algo` can compose other transaction types, which can be signed and submitting as described above. See `algo -h` for a description of all supported operations.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Amount ¶
type Amount struct {
// contains filtered or unexported fields
}
Directories
¶
Path | Synopsis |
---|---|
cmd
|
|
algo
Command algo Operation assetconfig Configure an Algorand Standard Asset.
|
Command algo Operation assetconfig Configure an Algorand Standard Asset. |
algo-key
Operation backup Shows a secret key, encoded as mnemonic string.
|
Operation backup Shows a secret key, encoded as mnemonic string. |