Using GetBlock configuration files
GetBlock’s configuration file provides a more organized and flexible way to interact with blockchain nodes and networks without exposing sensitive API keys or credentials in the code.
Last updated
GetBlock’s configuration file provides a more organized and flexible way to interact with blockchain nodes and networks without exposing sensitive API keys or credentials in the code.
Last updated
Using GetBlock’s JSON configuration file with curl is particularly helpful when you need to access various node endpoints without hardcoding API keys in the code:
Download the getblock.config.json
file from your GetBlock account;
Make sure you have installed. jq is a versatile command-line tool that enables extracting values from JSON files;
Navigate to your workspace or directory where you have imported the getblock.config.json
file and open a terminal;
Now, you can make a GET request to a selected node endpoint using the curl command:
Connect to Ethereum nodes and other EVM-compatible networks using web3.js and GetBlock’s JS configuration file.
Make sure the web3.js library is added to your project. In order to do that, use one of the following methods:
Npm: npm install web3
Yarn: yarn add web3
Pure js link: dist/web3.min.js
Download the getblock.config.js
file from your GetBlock account. Add this file to your project directory.
Import the getblock
module to a .js file that configures a new Web3 instance:
Connect to an Ethereum node and start sending API calls using web3.js over HTTP or WebSocket in the format below:
Use go()
method to access an entire endpoint or token()
to fetch the token.
Set up GetBlock’s JS config file in Hardhat following the steps below:
Ensure you have Hardhat installed as a dependency in your Node.js project or run the following command to do so:
Navigate to your GetBlock account and install the getblock.config.js
file. Copy and paste it into your working directory;
Open the hardhat.config.js
file from your project directory and import the getblock
module:
To set up GetBlock as a provider, modify the Hardhat configuration file with the credentials as shown below. Use go()
method to access an entire endpoint or token()
to fetch the token only.