### Install and Configure Build Host Source: https://github.com/algorand/go-algorand/blob/master/scripts/buildhost/README.md Clone the go-algorand repository, navigate to the buildhost directory, and run the configuration script. This is the initial setup for the build environment. ```bash git clone https://github.com/algorand/go-algorand cd go-algorand/scripts/buildhost sudo ./configure.sh ``` ```bash nano service_env.sh ``` ```bash sudo systemctl start buildhost ``` -------------------------------- ### Initial Development Environment Setup Source: https://github.com/algorand/go-algorand/blob/master/CLAUDE.md Run the 'configure_dev.sh' script for the initial setup of the development environment. ```bash ./scripts/configure_dev.sh # Initial environment setup ``` -------------------------------- ### Start go-algorand Node Source: https://github.com/algorand/go-algorand/blob/master/README.md Start the Algorand node using the 'goal' binary. Ensure the GOPATH is set correctly. ```bash ${GOPATH}/bin/goal node start -d ~/.algorand ``` -------------------------------- ### Install Participation Keys with goal CLI Source: https://github.com/algorand/go-algorand/blob/master/docs/participation_key_lifecycle.md The 'goal' command provides a convenient way to install participation keys. The --delete-input flag removes the key file after successful installation. ```bash goal account installpartkey --partkey keys.db --delete-input -d /path/to/data-dir ``` -------------------------------- ### Setup Project and Build Binaries Source: https://github.com/algorand/go-algorand/blob/master/test/e2e-go/cli/goal/expect/README.md Clone the go-algorand repository, configure the development environment, and build the project binaries. ```bash git clone https://github.com/algorand/go-algorand cd go-algorand ./scripts/configure_dev.sh ``` ```bash make clean install ``` -------------------------------- ### Build go-algorand Source: https://github.com/algorand/go-algorand/blob/master/README.md Install the go-algorand binaries after the environment is configured. ```bash make install ``` -------------------------------- ### Build All Binaries Source: https://github.com/algorand/go-algorand/blob/master/CLAUDE.md Use 'make build' to compile all project binaries. For installation into $GOPATH/bin, use 'make install'. 'make buildsrc' offers a faster build of the main source. ```bash make build # Build all binaries ``` ```bash make install # Build and install binaries to $GOPATH/bin ``` ```bash make buildsrc # Build main source (faster than full build) ``` -------------------------------- ### Start Algorand Network with Pre-generated Keys Source: https://github.com/algorand/go-algorand/blob/master/docker/README.md This command starts an Algorand network using the pre-generated keys. It maps the local `pregen` directory to the container's key storage and exposes the necessary port. ```bash docker run --rm -it --name algod-pregen-run \ -p 4190:8080 \ -v /tmp/big_keys.json:/etc/algorand/template.json \ -v $(pwd)/pregen:/etc/algorand/keys \ algorand/algod:stable ``` -------------------------------- ### Install Participation Keys via API Source: https://github.com/algorand/go-algorand/blob/master/docs/participation_key_lifecycle.md Use this endpoint to install participation keys from a local file to the node. Ensure the Authorization header is correctly set. ```bash curl -X POST --data-binary @keys.db -H "Authorization: Bearer admin-token-here" "localhost:1234/v2/participation" ``` -------------------------------- ### Install Participation Key Source: https://github.com/algorand/go-algorand/blob/master/docs/participation_key_lifecycle.md Installs participation keys by sending the keys.db file to the node's Admin API. This makes the keys available for the node to use. ```APIDOC ## POST /v2/participation/ ### Description Installs a participation key by uploading the keys.db file to the node. ### Method POST ### Endpoint /v2/participation/ ### Request Body - **@keys.db** (file) - Required - The participation key database file. ### Request Example ```bash curl -X POST --data-binary @keys.db -H "Authorization: Bearer admin-token-here" "localhost:1234/v2/participation" ``` ``` -------------------------------- ### Start Algod Docker Container Source: https://github.com/algorand/go-algorand/blob/master/docker/release/deploy_README.md Start a Docker container for a specified Algorand network. Replace NETWORK with 'devnet', 'testnet', 'betanet', or 'mainnet'. ```bash ./start_algod_docker.sh ${NETWORK} ``` -------------------------------- ### Configure Go-Algorand Development Environment Source: https://github.com/algorand/go-algorand/blob/master/scripts/windows/instructions.md Executes a script to install all required dependencies for Go-Algorand development after cloning the repository. ```bash ./scripts/configure_dev.sh ``` -------------------------------- ### Get go-algorand Node Status (REST API) Source: https://context7.com/algorand/go-algorand/llms.txt Retrieves the current status of the running algod node using the V2 REST API. Requires the X-Algo-API-Token header. Includes an example of waiting for a specific block. ```bash ALGOD_TOKEN=$(cat ~/.algorand/algod.token) ALGOD_PORT=$(cat ~/.algorand/algod.net | sed 's/.*://') # Get node status curl -s -H "X-Algo-API-Token: $ALGOD_TOKEN" \ "http://localhost:${ALGOD_PORT}/v2/status" | jq . # Example response: # { # "last-round": 38521000, # "last-version": "https://github.com/algorandfoundation/specs/tree/abc123", # "next-version": "https://github.com/algorandfoundation/specs/tree/abc123", # "next-version-round": 38521001, # "next-version-supported": true, # "time-since-last-round": 1234567890, # "catchup-time": 0, # "has-synced-since-startup": true, # "stopped-at-unsupported-round": false # } # Wait for a specific block (long-poll, up to 1 minute) curl -s -H "X-Algo-API-Token: $ALGOD_TOKEN" \ "http://localhost:${ALGOD_PORT}/v2/status/wait-for-block-after/38521000" | jq .last-round ``` -------------------------------- ### Build and Run go-algorand Node Source: https://context7.com/algorand/go-algorand/llms.txt Steps to clone the repository, configure the development environment, build binaries, run tests, and start a mainnet or testnet node. Also includes how to monitor node activity with carpenter. ```bash # Clone and configure dev environment git clone https://github.com/algorand/go-algorand cd go-algorand ./scripts/configure_dev.sh # Build all binaries into $GOPATH/bin make install # Run unit and integration tests make test make integration # Start a mainnet node (default data dir: ~/.algorand) ${GOPATH}/bin/goal node start -d ~/.algorand # Join testnet instead mkdir ~/testnet_data cp installer/genesis/testnet/genesis.json ~/testnet_data/genesis.json ${GOPATH}/bin/goal node start -d ~/testnet_data # Watch node activity ${GOPATH}/bin/carpenter -d ~/.algorand ``` -------------------------------- ### Starting Tealdbg Remote Debugger Source: https://github.com/algorand/go-algorand/blob/master/cmd/tealdbg/README.md Command to start the tealdbg remote debugger. This is a necessary step before rebuilding and restarting Algod for debugging. ```bash $ tealdbg remote ``` -------------------------------- ### Clone and Configure go-algorand Source: https://github.com/algorand/go-algorand/blob/master/README.md Clone the repository and run the configuration script to set up the development environment. ```bash git clone https://github.com/algorand/go-algorand cd go-algorand ./scripts/configure_dev.sh ``` -------------------------------- ### Install Git on MSYS2 Source: https://github.com/algorand/go-algorand/blob/master/scripts/windows/instructions.md Installs the Git version control system within the MSYS2 environment. The --noconfirm flag automatically confirms any prompts. ```bash pacman -S --disable-download-timeout --noconfirm git ``` -------------------------------- ### Initialize libgoal Client in Go Source: https://context7.com/algorand/go-algorand/llms.txt This Go code demonstrates how to create a full client using the libgoal library, which connects to both algod and kmd daemons. It shows how to retrieve node status, account information, and the genesis ID. ```go package main import ( "fmt" "github.com/algorand/go-algorand/libgoal" ) func main() { // Create a full client (connects to both algod and kmd) client, err := libgoal.MakeClient( "/home/user/.algorand", // algod data directory "/tmp/libgoal-cache", // cache directory libgoal.FullClient, // DynamicClient | KmdClient | AlgodClient | FullClient ) if err != nil { panic(err) } // Get node status status, err := client.Status() if err != nil { panic(err) } fmt.Printf("Last round: %d\n", status.LastRound) // Get account information acctInfo, err := client.AccountInformation( "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAY5HFKQ", false, // includeCreatables ) if err != nil { panic(err) } fmt.Printf("Balance: %d microAlgos\n", acctInfo.Amount) // Check genesis ID genesisID, err := client.GenesisID() if err != nil { panic(err) } fmt.Printf("Network: %s\n", genesisID) } ``` -------------------------------- ### Manage Participation Registry Source: https://github.com/algorand/go-algorand/blob/master/docs/participation_key_lifecycle.md Endpoints for managing the participation registry, which stores installed keys. Keys are assigned a unique participation ID upon installation. ```APIDOC ## DELETE /v2/participation/ ### Description Removes a participation key from the registry using its unique ID. ### Method DELETE ### Endpoint /v2/participation/ ### Parameters #### Path Parameters - **participation-id** (string) - Required - The unique ID of the participation key to remove. ``` ```APIDOC ## GET /v2/participation/ ### Description Retrieves a list of all currently registered participation keys. ### Method GET ### Endpoint /v2/participation/ ``` ```APIDOC ## GET /v2/participation/ ### Description Retrieves details for a specific participation key using its unique ID. ### Method GET ### Endpoint /v2/participation/ ### Parameters #### Path Parameters - **participation-id** (string) - Required - The unique ID of the participation key to retrieve. ``` -------------------------------- ### Initialize and Register Handlers for WebSocket Network Source: https://context7.com/algorand/go-algorand/llms.txt Demonstrates how to create a WebSocket network instance, register message handlers for specific protocol tags, and start/stop the network. Requires configuration and genesis information. ```go package main import ( "github.com/algorand/go-algorand/config" "github.com/algorand/go-algorand/logging" "github.com/algorand/go-algorand/network" "github.com/algorand/go-algorand/protocol" ) // WebSocket network creation (internal — shown for reference): // // cfg := config.GetDefaultLocal() // net, err := network.NewWebsocketNetwork( // log, // cfg, // []string{"r1.algorand-mainnet.network"}, // phone book / relay addresses // genesisID, // networkID, // nil, // node info // ) // // // Register a message handler for a protocol tag // net.RegisterHandlers([]network.TaggedMessageHandler{ // { // Tag: protocol.AgreementVoteTag, // Handler: network.HandlerFunc(myVoteHandler), // }, // }) // // net.Start() // defer net.Stop() // // Message tags (protocol.go): // protocol.AgreementVoteTag // "AV" — agreement votes // protocol.ProposalPayloadTag // "PP" — block proposals // protocol.TxnTag // "TX" — transactions // protocol.UniCatchupReqTag // "UR" — catchup requests _ = protocol.AgreementVoteTag _ = protocol.TxnTag ``` -------------------------------- ### Manage Wallets and Keys with libgoal Source: https://context7.com/algorand/go-algorand/llms.txt Create wallets, generate addresses, and manage multisig accounts using the kmd daemon via libgoal. Demonstrates generating new addresses, listing existing ones, creating multisig accounts, and looking up multisig metadata. ```go package main import ( "fmt" "github.com/algorand/go-algorand/libgoal" ) func main() { client, err := libgoal.MakeClient("/home/user/.algorand", "/tmp/cache", libgoal.FullClient) if err != nil { panic(err) } // Get handle to the default unencrypted wallet handle, err := client.GetUnencryptedWalletHandle() if err != nil { panic(err) } // Generate a new address in the wallet newAddr, err := client.GenerateAddress(handle) if err != nil { panic(err) } fmt.Printf("New address: %s\n", newAddr) // List all addresses in the wallet (including multisig) addresses, err := client.ListAddressesWithInfo(handle) if err != nil { panic(err) } for _, a := range addresses { fmt.Printf("Address: %s multisig=%v\n", a.Addr, a.Multisig) } // Create a 2-of-3 multisig address signers := []string{ "ADDR1AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "ADDR2AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "ADDR3AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", } msigAddr, err := client.CreateMultisigAccount(handle, 2, signers) if err != nil { panic(err) } fmt.Printf("Multisig address: %s\n", msigAddr) // Lookup multisig metadata info, err := client.LookupMultisigAccount(handle, msigAddr) if err != nil { panic(err) } fmt.Printf("Threshold: %d/%d\n", info.Threshold, len(info.PKs)) } ``` -------------------------------- ### Install NTPdate on Debian-based Systems Source: https://github.com/algorand/go-algorand/blob/master/scripts/release/README.md Use this command to install ntpdate on Debian-based systems to synchronize your system's clock with network time servers, resolving potential AWS authentication issues. ```bash $ sudo apt-get install ntpdate $ sudo ntpdate ntp.ubuntu.com ``` -------------------------------- ### Manage Algorand Applications with `goal app` Source: https://context7.com/algorand/go-algorand/llms.txt Commands for creating and calling smart contracts (applications). Provide creator address, TEAL programs, global/local state schema, and application ID as needed. ```bash # Smart contract operations goal app create \ --creator ADDR_HERE \ --approval-prog approval.teal \ --clear-prog clear.teal \ --global-byteslices 1 --global-ints 1 \ --local-byteslices 1 --local-ints 1 \ -d ~/.algorand goal app call \ --app-id 12345 \ --from ADDR_HERE \ -d ~/.algorand ``` -------------------------------- ### Create an Algorand App with `goal` Source: https://github.com/algorand/go-algorand/blob/master/cmd/goal/README.md Creates a new application on the Algorand network. Requires the creator account, and paths to the approval and clear programs. Note the 'app index' printed upon successful creation. ```sh TEALDIR=cmd/goal/examples echo $TEALDIR # create the app and TAKE NOTE of its "app index" goal app create --creator ${ACCOUNT} --approval-prog ${TEALDIR}/boxes.teal --clear-prog ${TEALDIR}/clear.teal ``` -------------------------------- ### Get Ledger Supply Source: https://context7.com/algorand/go-algorand/llms.txt Queries the total token supply of Algorand. ```APIDOC ## GET /v2/ledger/supply ### Description Retrieves the current total supply of ALGO tokens and related information. ### Method GET ### Endpoint /v2/ledger/supply ### Request Example ```bash curl -s -H "X-Algo-API-Token: $ALGOD_TOKEN" \ "http://localhost:8080/v2/ledger/supply" ``` ### Response #### Success Response (200) - **current_round** (integer) - The current blockchain round. - **online_money** (integer) - The amount of ALGO currently online. - **total_money** (integer) - The total amount of ALGO in existence. ### Response Example ```json { "current-round": 38521000, "online-money": 1000000000000000000, "total-money": 1000000000000000000 } ``` ``` -------------------------------- ### Manage Algorand Accounts with `goal` Source: https://context7.com/algorand/go-algorand/llms.txt Commands for listing accounts, creating new ones, and checking balances. Replace `ADDR_HERE` with the actual account address. ```bash # Account operations goal account list -d ~/.algorand goal account new -d ~/.algorand goal account balance -a ADDR_HERE -d ~/.algorand ``` -------------------------------- ### Get Specific Participation Key Source: https://context7.com/algorand/go-algorand/llms.txt Retrieves a specific participation key by its ID. ```APIDOC ## GET /v2/participation/{part_id} ### Description Fetches the details of a specific participation key using its unique identifier. ### Method GET ### Endpoint /v2/participation/${PART_ID} ### Parameters #### Path Parameters - **part_id** (string) - Required - The unique identifier of the participation key. ### Request Example ```bash PART_ID="ABCDEFGHIJKLMNOPQRSTUVWXYZ234567" curl -s -H "X-Algo-API-Token: $ALGOD_TOKEN" \ "http://localhost:8080/v2/participation/${PART_ID}" ``` ### Response #### Success Response (200) - A JSON object containing the details of the specified participation key, including its ID, address, and voting validity rounds. ### Response Example ```json { "id": "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567", "address": "...", "vote_first_valid": 1000, "vote_last_valid": 2000 } ``` ``` -------------------------------- ### Run go-algorand Container with Mainnet Configuration Source: https://github.com/algorand/go-algorand/blob/master/docker/README.md Launches a container configured for the mainnet. It maps ports, sets environment variables for network, fast catchup, telemetry, and API token, and mounts a local data directory. ```bash docker run --rm -it \ -p 4190:8080 \ -p 4191:7833 \ -e NETWORK=mainnet \ -e FAST_CATCHUP=1 \ -e TELEMETRY_NAME=name \ -e TOKEN=aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa \ -e START_KMD=1 \ -v ${PWD}/data:/algod/data/ \ --name mainnet-container \ algorand/algod:latest ``` -------------------------------- ### Docker Run Aptly Interactive Source: https://github.com/algorand/go-algorand/blob/master/scripts/release/mule/README.md Starts an interactive session within the aptly-test container. ```docker docker run --name aptly-algorand --rm -it aptly-test ``` -------------------------------- ### Build Go-Algorand Project Source: https://github.com/algorand/go-algorand/blob/master/scripts/windows/instructions.md Compiles the Go-Algorand project. This command is typically run after dependencies have been installed. ```bash make ``` -------------------------------- ### Docker Run Aptly Create and Push Source: https://github.com/algorand/go-algorand/blob/master/scripts/release/mule/README.md Runs the aptly-test container to create and push an Algorand repository. Mounts GPG agent and keys, and sets necessary environment variables. ```docker docker run --name aptly-algorand --rm -i -v "$XDG_RUNTIME_DIR/gnupg/S.gpg-agent":/root/.gnupg/S.gpg-agent -v "$HOME/.gnupg/pubring.kbx":/root/.gnupg/pubring.kbx -e AWS_SECRET_ACCESS_KEY="$AWS_SECRET_ACCESS_KEY" -e AWS_ACCESS_KEY_ID="$AWS_ACCESS_KEY_ID" -e CHANNEL=dev -e REPO=algorand -e VERSION=2.1.87522 aptly-test bash create_and_push ``` -------------------------------- ### Compile and Use convertAddress Binary Source: https://github.com/algorand/go-algorand/blob/master/tools/misc/README.md Builds a binary from the convertAddress tool and then uses it for address conversion. This is more efficient for repeated use than `go run`. ```sh # Build binary. ~$ go build convertAddress.go ``` ```sh # Use binary. ~$ ./convertAddress -addr JveKzg3B9BOje3Cwv6YQkRlx8I3/BZhv5ReJkp0BE2w= E33YVTQNYH2BHI33OCYL7JQQSEMXD4EN74CZQ37FC6EZFHIBCNWOWXIZ5M ``` -------------------------------- ### Create an ABI Box with Goal CLI Source: https://github.com/algorand/go-algorand/blob/master/cmd/goal/README.md Use this command to create a new application box. Ensure the ACCOUNT and APPID environment variables are set. ```bash goal app call --from ${ACCOUNT} --app-id ${APPID} --box "str:an_ABI_box" --app-arg "str:create" --app-arg "str:an_ABI_box" ``` -------------------------------- ### Get Per-Txn-Group State Deltas for a Round Source: https://context7.com/algorand/go-algorand/llms.txt Retrieves state deltas aggregated by transaction group for a specific round. ```APIDOC ## GET /v2/deltas/{round}/txn/group ### Description Fetches state deltas for a given round, aggregated at the transaction group level. Useful for analyzing changes within transaction groups. ### Method GET ### Endpoint /v2/deltas/${ROUND}/txn/group ### Parameters #### Path Parameters - **round** (integer) - Required - The round number for which to retrieve the deltas. ### Request Example ```bash ROUND=38521000 curl -s -H "X-Algo-API-Token: $ALGOD_TOKEN" \ "http://localhost:8080/v2/deltas/${ROUND}/txn/group" ``` ### Response #### Success Response (200) - **Deltas** (array) - An array of state deltas, each associated with a transaction group. ### Response Example ```json { "Deltas": [ { ... }, { ... } ] } ``` ``` -------------------------------- ### Create Single Node Dev Network with `goal` Source: https://github.com/algorand/go-algorand/blob/master/cmd/goal/README.md Sets up a new single-node Algorand development network. Ensure `${ALGORAND_DATA}` is set before proceeding with other commands. ```sh # set this to where you want to keep the network files (and data dirs will go beneath) NETWORKS=~/networks # create a networks directory if you don't already have it mkdir -p ${NETWORKS} # set this to "name" your network NAME=niftynetwork # assuming here that are currently working out of the root directory of the go-algorand repo goal network create -n ${NAME} -r ${NETWORKS}/${NAME} -t ./test/testdata/nettemplates/OneNodeFuture.json # after the next command and for the rest of the README, we assume that `${ALGORAND_DATA}` is set export ALGORAND_DATA=${NETWORKS}/${NAME}/Primary echo $ALGORAND_DATA # start the network goal node start # see if it worked (run a few times, note block increasing) goal node status sleep 4 # assuming you're copy/pasting this entire block goal node status sleep 4 goal node status # find the account with all the money goal account list # put it in a variable ACCOUNT=`goal account list | awk '{print $2}'` echo $ACCOUNT # send some money from the account to itself goal clerk send --to ${ACCOUNT} --from ${ACCOUNT} --amount 10 ```