How to Connect to Algorand Mainnet

Learn how to connect to your Algorand infrastructure via REST API.

Step 1 - Select a Node

Select your Algorand node from your list of Blockdamon nodes


Step 2 - Copy the Node Info

Copy the following information:

  • Your Algorand node URL
  • Your Algo API Token (this can be found in your dashboard actions menu - lower right in your dashboard, Actions>connect)

Step 3 - Read the Documentation

For participation keys, go to the node's settings in the actions dropdown of the overview tab to generate a new key or upload a registered key. The Algorand REST API is available for this node. The most current documentation is available from Algorand here. You can also access a sample Go SDK for Algorand here. You can import this SDK and use it to build applications that explore the Algorand blockchain.


Step 4 - Connect to Algorand

Step 4.1 - Connect to Algorand via the REST API

From a command line, you may use the REST API calls in the Algorand documentation and connect using the following pattern:

curl https://algorand-testnet.bdnodes.net/v1/status?auth=[your auth token] -H "X-Algo-API-Token: 6a502bc719407612b85e41b4f12c0522941d17d5d9e1c556b1959c065430c1ac"

Step 4.2 - Connect to Algorand via WebSocket

wscat -H "X-Auth-Token: YOUR_AUTH_TOKEN" -c wss://YOUR_ENDPOINT_URL:8443/websocket
  • Replace YOUR_ENDPOINT_URL with the Endpoint URL found in the Blockdaemon app.
  • Replace YOUR_AUTH_TOKEN with the Auth Token found in the Blockdaemon app.

📘

Info:

wscat is a tool that can connect over WebSocket(s) and may need to be installed. You can use your preferred tool of choice.


Step 4.3 - Connect to Algorand via Python

import algosdk
# Node Access
client = algosdk.v2client.algod.AlgodClient('', '', {
'X-Auth-Token': ''
})
resp = client.status()
print(resp)

Step 4.4 - Connect to Algorand via Go

package main
import (
"fmt"
"github.com/algorand/go-algorand-sdk/client/algod"
)
const algodAddress = ""
const algodToken = "Your_algorand_api_token"
func main() {
// Create an algod client
algodClient, err := algod.MakeClientWithHeaders(algodAddress, algodToken, []*algod.Header{
{
Key: "X-Auth-Token",
Value: "",
},
})Go
if err != nil {
return
}
// Print algod status
nodeStatus, err := algodClient.Status()
if err != nil {
fmt.Printf("error getting algod status: %s\n", err)
return
}
fmt.Printf("algod last round: %d\n", nodeStatus.LastRound)
fmt.Printf("algod time since last round: %d\n", nodeStatus.TimeSinceLastRound)
fmt.Printf("algod catchup: %d\n", nodeStatus.CatchupTime)
fmt.Printf("algod latest version: %s\n", nodeStatus.LastVersion)

Step 4.5 - Connect to Algorand via JavaScript

import algosdk from 'algosdk'
const token = '';
const server = '';
const port = 443;
const client = new algosdk.Algod(token, server, port, {
'X-Auth-Token': ''
});
(async () => {
console.log(await client.status());
})().catch((e) => {
console.log(e);
});

👋 Need Help?

Contact us through email or our support page for any issues, bugs, or assistance you may need.