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

# Alchemy RPC 配置

> 通过 Alchemy JSON-RPC 端点连接到 Injective EVM 主网和测试网。

[Alchemy](https://www.alchemy.com/) 为 Injective EVM 提供可靠的 JSON-RPC 端点。使用本指南创建一个 Alchemy 应用并开始发起请求。

<iframe className="w-1\/2 aspect-video rounded-xl" src="https://youtube.com/embed/Ma3CIvDRSjk?rel=0&autoplay=1&cc_load_policy=0" title="Injective + Alchemy quick start (1 min) - YouTube" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowFullScreen frameborder="0" />

[*Injective + Alchemy quick start (1 min) - YouTube*](https://youtube.com/watch?v=Ma3CIvDRSjk)

## 前置条件

* 一个 Alchemy 账号（[免费注册](https://www.alchemy.com/)）
* 对 EVM RPC 端点有基本了解

## 步骤

<Steps>
  <Step title="创建应用">
    在 [Alchemy 仪表盘](https://dashboard.alchemy.com/) 中创建一个新应用，并选择 **Injective** 作为链。然后选择网络：

    * **Injective EVM Mainnet**：Chain ID `1776`
    * **Injective EVM Testnet**：Chain ID `1439`
  </Step>

  <Step title="复制你的 RPC 端点">
    打开你的应用，复制 HTTPS 和 WebSocket 端点：

    <CodeGroup>
      ```bash Mainnet theme={null}
      https://inj-mainnet.g.alchemy.com/v2/<YOUR_API_KEY>
      wss://inj-mainnet.g.alchemy.com/v2/<YOUR_API_KEY>
      ```

      ```bash Testnet theme={null}
      https://inj-testnet.g.alchemy.com/v2/<YOUR_API_KEY>
      wss://inj-testnet.g.alchemy.com/v2/<YOUR_API_KEY>
      ```
    </CodeGroup>

    <Warning>
      请妥善保管你的 API key，将其视作密码。
    </Warning>
  </Step>

  <Step title="开始构建">
    使用你偏好的库调用该端点：

    <CodeGroup>
      ```ts ethers.js (v6) theme={null}
      import { JsonRpcProvider } from "ethers";

      const provider = new JsonRpcProvider(
        "https://inj-mainnet.g.alchemy.com/v2/<YOUR_API_KEY>"
      );

      const blockNumber = await provider.getBlockNumber();
      console.log("Latest block:", blockNumber);
      ```

      ```ts viem theme={null}
      import { createPublicClient, http } from "viem";
      import { defineChain } from "viem";

      const injectiveEVM = defineChain({
        id: 1776,
        name: "Injective EVM",
        nativeCurrency: { name: "Injective", symbol: "INJ", decimals: 18 },
        rpcUrls: {
          default: { http: ["https://inj-mainnet.g.alchemy.com/v2/<YOUR_API_KEY>"] },
        },
      });

      const client = createPublicClient({
        chain: injectiveEVM,
        transport: http(),
      });

      const blockNumber = await client.getBlockNumber();
      console.log("Latest block:", blockNumber);
      ```

      ```bash curl theme={null}
      curl https://inj-mainnet.g.alchemy.com/v2/<YOUR_API_KEY> \
        -X POST \
        -H "Content-Type: application/json" \
        -d '{"jsonrpc":"2.0","method":"eth_blockNumber","params":[],"id":1}'
      ```
    </CodeGroup>
  </Step>
</Steps>

## 后续步骤

* [EVM 网络信息](/developers-evm/network-information) - chain ID、区块浏览器和公共 RPC 端点
* [部署你的第一个 EVM 智能合约](/developers-evm/smart-contracts)
* [将你的 dApp 连接到 Injective](/developers-evm/add-injective-to-your-dapp)
