How to Connect to Solana
Learn how easy it is to connect to the Solana nodes with Blockdaemon.
It's easy to connect to your Solana nodes.
If you haven't already configured any Solana infrastructure, visit the Solana marketplace page to learn more about Blockdaemon's Solana options.
Once you have purchased your Blockdaemon Solana infrastructure, Your Blockdaemon Technical Account Manager (TAM) will send you the necessary access credentials.
There are multiple ways to use these to connect to your node/cluster. In this guide, we will cover the following simple methods of connection to your infrastructure:
Solana RPC Connection via cURL
Step 1 - Your TAM will send you the following access credentials:
-
Your Unique Endpoint URL
-
Your Unique Auth Token
-
Please Note: These are one-time view, so make sure to copy them. Step 2 - Add your access credentials to a cURL request.
-
Example 1
- curl -H 'Content-Type: application/json'
-X POST 'YOUR_ENDPOINT_URL'
-H 'Authorization: Bearer YOUR_AUTH_TOKEN'
--data-raw '{"method":"getEpochInfo","id":1,"jsonrpc":"2.0"}'
-
Replace
YOUR_ENDPOINT_URL
with the Endpoint URL sent by your Blockdaemon TAM -
Replace
YOUR_AUTH_TOKEN
with the Auth Token sent by your Blockdaemon -
Example 2
curl -H 'Content-Type: application/json'
-X POST 'YOUR_ENDPOINT_URL?auth=YOUR_AUTH_TOKEN'
--data-raw '{"method":"getEpochInfo","id":1,"jsonrpc":"2.0"}'
- Replace `YOUR_ENDPOINT_URL` with the Endpoint URL sent by your Blockdaemon TAM
- Replace `YOUR_AUTH_TOKEN` with the Auth Token sent by your Blockdaemon TAM
Step 3
- Execute your request and you will now be successfully connected to your Blockdaemon Solana Infrastructure
- The result should look like this:
{
"jsonrpc": "2.0",
"result": {
"absoluteSlot": 132743177,
"blockHeight": 120380369,
"epoch": 307,
"slotIndex": 119177,
"slotsInEpoch": 432000,
"transactionCount": 72714796098
},
"id": 1
}
Solana Connection via WebSocket
Step 1 - Your TAM will send you the following access credentials:
- Your Unique Endpoint URL
- Your Unique Auth Token
Please Note: These are one-time view, so make sure to copy them. Step 2 - Add your access credentials to a websockets connection request. Examples are shown below:
WebSocket Connection Example 1: How to connect using wscat
wscat -H "X-Auth-Token: \<YOUR_AUTH_TOKEN>" -c \<YOUR_ENDPOINT_URL>
- Replace
YOUR_ENDPOINT_URL
with the Endpoint URL sent by your Blockdaemon TAM - Replace
YOUR_AUTH_TOKEN
with the Auth Token sent by your Blockdaemon TAM
WebSocket Connection Example 2: How to connect using wsdump
wsdump --headers "X-Auth-Token: \<YOUR_AUTH_TOKEN>" \<YOUR_ENDPOINT_URL>
- Replace
YOUR_ENDPOINT_URL
with the Endpoint URL sent by your Blockdaemon TAM - Replace
YOUR_AUTH_TOKEN
with the Auth Token sent by your Blockdaemon TAM
Step 3 - Subscribe to one or more WebSocket Endpoints. Examples are shown below:
WebSocket Subscriptions Example 1: How to subscribe to slotSubscription
{"id":1,"jsonrpc":"2.0","method":"slotSubscribe","params":\[]}
WebSocket Subscriptions Example 2: How to subscribe to accountSubscribe
{"id":1,"jsonrpc":"2.0","method":"accountSubscribe","params":["<ADDRESS>",{"encoding: "jsonParsed"}]}
- Replace
ADDRESS
with the address you want to subscribe to, e.g.JTmFx5zX9mM94itfk2nQcJnQQDPjcv4UPD7SYj6xDCV
Updated 2 months ago