How to Connect to Algorand Mainnet

How to Access Algorand Credentials

📘

Info:

If you haven't configured a node, learn how to deploy one here.

  1. Log into the Blockdaemon app.
  2. Select Dedicated Nodes from the sidebar menu
  3. Go to the My Nodes tab and select the Algorand node you want to connect to.
  4. Navigate to the Connect tab, where you’ll find:
    1. Endpoint URL
    2. Auth String
    3. Auth Token

Please reach out to [email protected] or your Customer Success Manager for support.


1. How to Connect via the REST API

curl 'ENDPOINT_URL/v2/REST_METHOD' 
-H 'X-Algo-API-Token: <Insert Your API Token>' 
-H 'X-Auth-Token: AUTH_TOKEN'

2. How to Connect via Python

This Python example shows how to connect to an Algorand node using the Algorand SDK and retrieve the current node status.

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

3. How to Connect via Go

This Go example shows how to create a client that interacts with the Algorand node and retrieves its status.

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)

📘

Info:

You can access a sample Go SDK for Algorand here.


4. How to Connect via JavaScript

In this JavaScript example, you’ll connect to an Algorand node using the Algorand SDK and fetch the node status asynchronously.

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.