# Alchemy RPC

## Overview

Alchemy provides scalable RPC infrastructure and developer tooling for interacting with blockchain networks.

On Pharos, Alchemy can be used to access reliable RPC endpoints for both Pacific Mainnet and Atlantic Testnet, making it suitable for application development and production use.

## Getting Started with Alchemy

To use Alchemy with Pharos, you’ll need to [create an Alchemy account](https://dashboard.alchemy.com/signup?utm_source=docs\&utm_medium=referral\&utm_content=reference_pharos-api-quickstart) and generate an API key.

Here are some prerequisites before you start interacting:

1. Sign up or log in to Alchemy
2. Create a new app
3. Select the Pharos network
4. Generate your API key

Once done, the API key will let you interact with the Pharos network through a set of JSON-RPC methods. Follow the guide below to start interacting with Pharos.

### Step 1. Choose a package manager (npm or yarn)

Choose between `npm` and `yarn` based on your preference or project requirements.

{% tabs %}
{% tab title="npm" %}

```
# Begin with npm by following the npm documentation
# https://docs.npmjs.com/downloading-and-installing-node-js-and-npm
```

{% endtab %}

{% tab title="yarn" %}

```
# For yarn, refer to yarn's installation guide
# https://classic.yarnpkg.com/lang/en/docs/install
```

{% endtab %}
{% endtabs %}

### Step 2. Set up your project

Run the following commands to create and initialize your project:

{% tabs %}
{% tab title="npm" %}

```
$ mkdir pharos-api-quickstart
$ cd pharos-api-quickstart
$ npm init --yes
```

{% endtab %}

{% tab title="yarn" %}

```
$ mkdir pharos-api-quickstart
$ cd pharos-api-quickstart
$ yarn init --yes
```

{% endtab %}
{% endtabs %}

This creates a new directory named `pharos-api-quickstart` and initializes a Node.js project within it.

### Step 3. Make your first request

Install Axios, a popular HTTP client, to make API requests:

{% tabs %}
{% tab title="npm" %}

```
$ npm install axios
```

{% endtab %}

{% tab title="yarn" %}

```
$ yarn add axios
```

{% endtab %}
{% endtabs %}

Create an `index.js` file in your project directory and paste the following code:

```javascript
const axios = require('axios');
 
const url = 'https://pharos-mainnet.g.alchemy.com/v2/your-api-key';
 
const payload = {
  jsonrpc: '2.0',
  id: 1,
  method: 'eth_blockNumber',
  params: []
```

Replace `your-api-key` with your actual Alchemy API key from the [Alchemy Dashboard](https://dashboard.alchemy.com/signup?utm_source=docs\&utm_medium=referral\&utm_content=reference_pharos-api-quickstart)

### Step 4. Run your script

Run your script to make a request to the network:

```shell
$ node index.js
```

You should see the latest block information from Pharos's network outputted to your console:

```shell
$ Latest Block: 0x...
```

## Next Steps

You've made your first request to the Pharos using Alchemy API. You can now explore the various [JSON-RPC methods](/api-and-sdk/json-rpc-methods.md) available on Pharos and start building your dApps.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.pharos.xyz/tooling-and-infrastructure/rpc/alchemy.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
