> ## Documentation Index
> Fetch the complete documentation index at: https://docs.solanamobile.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Making RPC requests

> To interface with the Solana network, a client needs to construct and send [_JSON RPC requests_](https://docs.solana.com/api/http) to an [_RPC endpoint_](https://docs.solana.com/cluster/rpc-endpoints).

export const FooterDisclaimer = () => {
  return <p className="not-prose mt-16 text-center text-xs text-gray-500 dark:text-gray-400">
      Code samples on this page are subject to the{" "}
      <a className="underline underline-offset-2" href="https://www.apache.org/licenses/LICENSE-2.0">
        Apache 2.0 license
      </a>
      .
    </p>;
};

## Add dependencies

The [@solana/web3.js](https://github.com/solana-labs/solana-web3.js) library provides a convenient RPC client [`Connection`](https://solana-labs.github.io/solana-web3.js/classes/Connection.html) class that has an API for submitting RPC requests to a JSON RPC endpoint.

<CodeGroup>
  ```bash yarn theme={null}
  yarn install @solana/web3.js@1 \
               react-native-get-random-values \
               buffer
  ```

  ```bash npm theme={null}
  npm install @solana/web3.js@1 \
               react-native-get-random-values \
               buffer
  ```
</CodeGroup>

### Add polyfills

After installing, ensure you have also added these [polyfills](/react-native/polyfill-guides/web3-js) to the `index.js` of your React native app. These are needed in some parts of `@solana/web3.js` because it is originally written as a web/node library and, as a result, certain expected APIs are missing in a React Native environment.

## Creating a `Connection` client

The `Connection` class represents a connection to a Solana RPC endpoint and provides convenient functions to make RPC requests.

Construct a `Connection` client by passing in an RPC endpoint and an optional [commitment](https://docs.solana.com/cluster/commitments) config:

```typescript theme={null}
const connection = new Connection("https://api.devnet.solana.com", "confirmed");
```

The `Connection` class created can be reused throughout your application.

### Usage

After creation, call various asynchronous RPC functions and receive responses from the RPC endpoint.

```typescript theme={null}
// `getLatestBlockhash` RPC request
const blockhash = await connection.getLatestBlockhash();

// `getBalance` RPC request
const balanceInLamports = await connection.getBalance();

// Sending a Transaction
const txSignature = await sendTransaction(tx);
```

View the [official documentation](https://solana-labs.github.io/solana-web3.js/classes/Connection.html) to see the full list of available RPC functions, parameter types, and response types.

## Next steps

* Read the following *Building transactions* guide to learn how to create transactions that interact with on-chain Solana Programs.
* Browse the [full list](https://docs.solana.com/api/http) of Solana RPC HTTP Methods

<FooterDisclaimer />
