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

# Get Provider

> Get an RPC provider for a specific blockchain network

## Method Signature

```typescript theme={null}
align.blockchain.providers.getProvider(
  network: Network
): JsonRpcProvider
```

## Parameters

<ParamField body="network" type="string" required>
  Network: `ethereum`, `polygon`, `base`, `arbitrum`, `optimism`
</ParamField>

## Returns

Returns an ethers.js `JsonRpcProvider` instance.

## Examples

<Tabs>
  <Tab title="TypeScript">
    ```typescript theme={null}
    import Align from "@tolbel/align";

    const align = new Align({
      apiKey: process.env.ALIGN_API_KEY!,
      environment: "sandbox",
    });

    const provider = align.blockchain.providers.getProvider("polygon");

    // Get current block number
    const blockNumber = await provider.getBlockNumber();
    console.log(`Current block: ${blockNumber}`);

    // Get gas price
    const feeData = await provider.getFeeData();
    console.log(`Gas price: ${feeData.gasPrice?.toString()}`);
    ```
  </Tab>

  <Tab title="JavaScript">
    ```javascript theme={null}
    const provider = align.blockchain.providers.getProvider("polygon");
    const block = await provider.getBlockNumber();
    console.log("Block:", block);
    ```
  </Tab>
</Tabs>

### Direct Contract Interaction

```typescript theme={null}
import { Contract } from "ethers";

const provider = align.blockchain.providers.getProvider("polygon");

const contract = new Contract(
  "0xContractAddress...",
  ["function totalSupply() view returns (uint256)"],
  provider
);

const supply = await contract.totalSupply();
console.log(`Total supply: ${supply}`);
```

<Info>
  Providers are cached internally. Multiple calls to `getProvider()` with the
  same network return the same instance.
</Info>

## Related Methods

<CardGroup cols={2}>
  <Card title="Set Custom RPC" icon="gear" href="/docs/api/blockchain/providers/set-custom-rpc">
    Use premium RPC
  </Card>

  <Card title="Get Network Info" icon="circle-info" href="/docs/api/blockchain/providers/get-network-info">
    Get network config
  </Card>
</CardGroup>
