# JSON-RPC 方法

### &#x20;示例 RPC

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

```
curl https://api.chainup.net/ethereum/mainnet/<YOUR_API_KEY> \
-X POST \
-H 'content-type: application/json' \
-H "CONSISTENT-HASH: true" \
--data '{"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}' 
```

{% endtab %}

{% tab title="Javascript" %}

```
const axios = require('axios'); 
//npm install axios if you don have the module installed

let options = {
    url: "https://api.chainup.net/ethereum/mainnet/<YOUR_API_KEY>",
    method: "post",
    headers: {
        "content-type": "application/json",
        "CONSISTENT-HASH": "true"  // Add your custom header here
    },
    data: {"jsonrpc":"2.0","method":"net_peerCount","params":[],"id":1}
};

axios(options)
    .then(response => {
        console.log('Post successful: response:', response.data);
    })
    .catch(error => {
        console.error('An error has occurred:', error);
    });
```

{% endtab %}

{% tab title="Python" %}

```python
import requests
import json

headers = {
    "content-type": "application/json",
    "CONSISTENT-HASH": "true"  # Add your custom header here
}

payload = json.dumps({
    "id": 1,
    "jsonrpc": "2.0",
    "method": "net_peerCount",
    "params": []
})

url = "https://api.chainup.net/ethereum/mainnet/00164210c0334c76a235aca8b1dcf655"
r = requests.post(url=url, headers=headers, data=payload)

if r.status_code == 200:
    print("Post successful: response: ", r.content)
else:
    print("An error has occurred: ", r.status_code)

```

{% endtab %}
{% endtabs %}

### Ethereum RPC 以太坊 RPC

&#x20;您可以查看以太坊 RPC 官方[**文档此处**](https://ethereum.org/en/developers/docs/apis/json-rpc/)

&#x20;可用的以太坊 API 请求方法

```solidity
          "eth_accounts"
          "eth_blockNumber"
          "eth_call"
          "eth_chainId"
          "eth_freeHistory"
          "eth_getBalance"
          "eth_getBlockByHash"
          "eth_getBlockByNumber"
          "eth_getBlockTransactionCountByHash"
          "eth_getBlocTransactionCountByNumber"
          "eth_getCode"
          "eth_getFilterChanges"
          "eth_getFilterLogs"
          "eth_getLogs"
          "eth_getStorageAt"
          "eth_getTransactionByHash"
          "eth_getTransactionByCount"
          "eth_getTransactionHashByCid"
          "eth_getTransactionReceipt"
          "eth_maxPriorityFeePerGas"
          "eth_newBlockFilter"
          "eth_newPendingTransactionFilter"
          "eth_sendRawTransaction"
          "eth_uninstallFilter"
          "eth_requestAccounts"
          "eth_sendTransaction"
          "eth_sign"
          "eth_gasPrice"
          "eth_estimateGas"
          "net_version"
```

{% hint style="info" %}
&#x20;由于某些 RPC 消耗计算资源，免费公共 RPC 仅支持上述 RPC。其余 JSON-RPC 将被拦截并返回 403 状态代码。
{% endhint %}

{% hint style="info" %}
&#x20;我们仅收集用户 IP 地址以用于速率限制。有关更多信息，请访问：  <https://www.chainup.com/privacyPolicy>
{% endhint %}


---

# 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.chainupcloud.com/zhong-wen/qu-kuai-lian-api/ethereum/json-rpc-methods.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.
