Quickstart
This quickstart guide will help you set up and make calls on the Blast network using the Infura endpoints.
Prerequisites
Ensure you have an API key with the Blast network enabled.
Make calls
cURL
Run the following command in your terminal, replacing <YOUR-API-KEY>
with your actual Infura API key:
curl https://blast-mainnet.infura.io/v3/<YOUR-API-KEY> \
-X POST \
-H "Content-Type: application/json" \
-d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}'
Node (JavaScript)
In these examples, you'll use NPM as your package manager.
Node Fetch
-
In your project folder, install the
node-fetch
package usingnpm
:npm i node-fetch
-
Create your JavaScript file and copy the following code:
Replace
<YOUR-API-KEY>
with your actual Infura API key.index.jsimport fetch from "node-fetch"
fetch("https://blast-mainnet.infura.io/v3/<YOUR-API-KEY>", {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
jsonrpc: "2.0",
method: "eth_blockNumber",
params: [],
id: 1,
}),
})
.then((response) => response.json())
.then((data) => {
console.log(data)
})
.catch((error) => {
console.error(error)
}) -
Run the code using the following command:
node index.js
Axios
-
In your project folder, install the Axios package using
npm
:npm i axios
-
Create your JavaScript file and copy the following code:
Replace
<YOUR-API-KEY>
with your actual Infura API key.index.jsconst axios = require("axios")
axios
.post("https://blast-mainnet.infura.io/v3/<YOUR-API-KEY>", {
jsonrpc: "2.0",
method: "eth_blockNumber",
params: [],
id: 1,
})
.then((response) => {
console.log(response.data)
})
.catch((error) => {
console.error(error)
}) -
Run the code using the following command:
node index.js
Ethers
-
In your project folder, install the ethers package using
npm
:npm install ethers
-
Create your JavaScript file and copy the following code:
Replace
<YOUR-API-KEY>
with your actual Infura API key.index.jsconst ethers = require("ethers")
const provider = new ethers.providers.JsonRpcProvider(
"https://blast-mainnet.infura.io/v3/<YOUR-API-KEY>"
)
provider
.getBlockNumber()
.then((blockNumber) => {
console.log(blockNumber)
})
.catch((error) => {
console.error(error)
}) -
Run the code using the following command:
node index.js
Python
-
In your project folder, install the
requests
library:pip install requests
-
Create your Python file and copy the following code:
Replace
<YOUR-API-KEY>
with your actual Infura API key.index.pyimport requests
import json
url = "https://blast-mainnet.infura.io/v3/<YOUR-API-KEY>"
payload = {
"jsonrpc": "2.0",
"method": "eth_blockNumber",
"params": [],
"id": 1
}
headers = {"content-type": "application/json"}
response = requests.post(url, data=json.dumps(payload), headers=headers).json()
print(response) -
Run the code using the following command:
python index.py
Next steps
Now that you have successfully made a call to the Blast network, you can explore more functionalities and APIs. Here are some suggestions:
-
Explore other Blast APIs: Infura supports a wide range of APIs. You can find more information in the JSON-RPC API method documentation.
-
Try out different networks: Infura supports multiple networks including Ethereum, Linea, Polygon, Optimism, and more.
-
Monitor your usage: Keep an eye on your usage on the Infura dashboard to ensure you're not hitting your rate limits.
Remember, the Infura community is here to help. If you have any questions or run into any issues, check out the Infura community for help and answers to common questions.