Search…
πŸ› 
3. How to Connect to Solana Web3JS
​
  1. 1.
    ) Add @solana/web3.js to your project:
  2. 2.
    yarn add @solana/web3.js OR npm install --save @solana/web3js
  3. 3.
    Include library in your files: const solanaWeb3 = require('@solana/web3.js');
  4. 4.
    ) Add RunNode connection string
1
var connection = new solanaWeb3.Connection(
2
'https://connect.runnode.com/?apikey=<API KEY GOES HERE>',
3
'confirmed',
4
);
5
if (connection) {
6
console.log('connected to RunNode successfully')
7
}
Copied!
3. ) Make calls like you normally would:
1
let block = await connection.getBlock(slot);
2
console.log(block);
Copied!
Last modified 1mo ago
Copy link