> For the complete documentation index, see [llms.txt](/llms.txt).

# Unichain quickstart

This quickstart guide will help you set up and make calls on the Unichain network using the Infura endpoints.

Don't have an Infura account? Sign up for a free plan and start using the Unichain network!

[Sign up](https://app.infura.io/register)

## Prerequisites[​](#prerequisites "Direct link to Prerequisites")

Ensure you have an [API key](/developer-tools/dashboard/get-started/create-api/) with the Unichain network enabled.

## Make calls[​](#make-calls "Direct link to Make calls")

### curl[​](#curl "Direct link to curl")

Run the following command in your terminal, replacing `<YOUR-API-KEY>` with your actual Infura API key:

```
curl https://unichain-mainnet.infura.io/v3/<YOUR-API-KEY> \
  -X POST \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc": "2.0", "method": "eth_blockNumber", "params": [], "id": 1}'

```

note

In Windows Powershell, quotations in `curl` commands can behave differently than expected. We recommend using Postman on Windows systems.

### Postman[​](#postman "Direct link to Postman")

Call the JSON-RPC methods using [Postman](https://learning.postman.com/docs/getting-started/introduction/).

Select **Run in Postman** to fork the collection and make requests.

[![Run in Postman](https://run.pstmn.io/button.svg)](https://god.gw.postman.com/run-collection/8171681-49bfbc10-85ae-466c-8cf0-91eba9298b12?action=collection%2Ffork&source=rip%5Fmarkdown&collection-url=entityId%3D8171681-49bfbc10-85ae-466c-8cf0-91eba9298b12%26entityType%3Dcollection%26workspaceId%3Db8156083-f4da-481f-84fa-72dcc26cb146)

info

Set the correct [variables](https://learning.postman.com/docs/sending-requests/variables/#understanding-variables) for your API key and network before running requests.

### Node (JavaScript)[​](#node-javascript "Direct link to Node (JavaScript)")

In these examples, you'll use [npm](https://docs.npmjs.com/downloading-and-installing-node-js-and-npm) as your package manager.

#### Node Fetch[​](#node-fetch "Direct link to Node Fetch")

1. In your project folder, install the `node-fetch` package using npm:  
```  
npm i node-fetch  
```
2. Create your JavaScript file and copy the following code:  
Replace `<YOUR-API-KEY>` with your actual Infura API key.  
index.js  
```  
import fetch from 'node-fetch'  
fetch('https://unichain-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)  
  })  
```
3. Run the code using the following command:  
```  
node index.js  
```

#### Axios[​](#axios "Direct link to Axios")

1. In your project folder, install the `axios` package using npm:  
```  
npm i axios  
```
2. Create your JavaScript file and copy the following code:  
Replace `<YOUR-API-KEY>` with your actual Infura API key.  
index.js  
```  
const axios = require('axios')  
axios  
  .post('https://unichain-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)  
  })  
```
3. Run the code using the following command:  
```  
node index.js  
```

#### Ethers[​](#ethers "Direct link to Ethers")

1. In your project folder, install the `ethers` package using npm:  
```  
npm install ethers  
```
2. Create your JavaScript file and copy the following code:  
Replace `<YOUR-API-KEY>` with your actual Infura API key.  
index.js  
```  
const ethers = require('ethers')  
const provider = new ethers.providers.JsonRpcProvider(  
  'https://unichain-mainnet.infura.io/v3/<YOUR-API-KEY>'  
)  
provider  
  .getBlockNumber()  
  .then(blockNumber => {  
    console.log(blockNumber)  
  })  
  .catch(error => {  
    console.error(error)  
  })  
```
3. Run the code using the following command:  
```  
node index.js  
```

#### Web3.js[​](#web3js "Direct link to Web3.js")

1. In your project folder, [install the latest version of the web3.js library](https://www.npmjs.com/package/web3?activeTab=versions)
2. Create your JavaScript file and copy the following code:  
Replace `<YOUR-API-KEY>` with your actual Infura API key.  
index.js  
```  
var { Web3 } = require('web3')  
var provider = 'https://unichain-mainnet.infura.io/v3/<YOUR-API-KEY>'  
var web3Provider = new Web3.providers.HttpProvider(provider)  
var web3 = new Web3(web3Provider)  
web3.eth.getBlockNumber().then(result => {  
  console.log('Latest Unichain Block is ', result)  
})  
```
3. Run the code using the following command:  
```  
node index.js  
```

### Python[​](#python "Direct link to Python")

1. In your project folder, install the `requests` library:  
```  
pip install requests  
```
2. Create your Python file and copy the following code:  
Replace `<YOUR-API-KEY>` with your actual Infura API key.  
index.py  
```  
import requests  
import json  
url = "https://unichain-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)  
```
3. Run the code using the following command:  
```  
python index.py  
```

## Next steps[​](#next-steps "Direct link to Next steps")

Now that you have successfully made a call to the Unichain network, you can explore more functionalities and APIs provided by Infura. Here are some suggestions:

- **Explore other Unichain APIs**: Infura supports a wide range of APIs. You can find more information in the [JSON-RPC API method documentation](/services/reference/unichain/json-rpc-methods/).
- **Try out different networks**: Infura supports multiple networks including Ethereum, Arbitrum, Linea, Polygon, Optimism, and more.
- **Monitor your usage**: Monitor your usage on the [Infura dashboard](/developer-tools/dashboard/how-to/dashboard-stats/) to ensure you're not hitting your rate limits.

Remember, the MetaMask community is here to help. If you have any questions or run into any issues, check out the [MetaMask community](https://community.metamask.io/) for help and answers to common questions.
