---
title: "eth_gasPrice"
description: "返回当前 Gas Price（单位 wei）（Arc）"
url: "https://blockreq.com/docs/zh-cn/build/api-reference/arc/eth_gasPrice/"
---

# eth_gasPrice

**网络：** Arc · 主网 · Chain ID `5042`（`0x13b2`）

**数据：** 全节点。Arc 不提供旧区块状态，请查询近期区块。

**计为 1 个 Request。** 计费规则见 [Request Counting](https://blockreq.com/docs/zh-cn/pricing/request-counting/index.md)。

返回当前每单位 Gas 的价格（wei）。

## 参数

无。

## 返回

`QUANTITY` — 当前 Gas Price（单位 wei）。

## 请求

```json
{
  "jsonrpc": "2.0",
  "method": "eth_gasPrice",
  "params": [],
  "id": 1
}
```

## 响应

```json
{
  "jsonrpc": "2.0",
  "id": 1,
  "result": "0x3b9aca00"
}
```

> `0x3b9aca00` = 1,000,000,000 wei = 1 Gwei

## 代码示例

**cURL**

```bash
curl -X POST https://arc-rpc.blockreq.com/v1/rpc/public \
  -H "Content-Type: application/json" \
  -d '{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}'
```

**TypeScript**

```typescript
const response = await fetch("https://arc-rpc.blockreq.com/v1/rpc/public", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({
  "jsonrpc": "2.0",
  "method": "eth_gasPrice",
  "params": [],
  "id": 1
}),
});
const data = await response.json();
console.log(data.result);
```

**Python**

```python
import requests

response = requests.post(
    "https://arc-rpc.blockreq.com/v1/rpc/public",
    json={
  "jsonrpc": "2.0",
  "method": "eth_gasPrice",
  "params": [],
  "id": 1
}
)
print(response.json()["result"])
```

**Go**

```go
package main

import (
	"bytes"
	"encoding/json"
	"fmt"
	"io"
	"net/http"
)

func main() {
	payload := []byte(`{"jsonrpc":"2.0","method":"eth_gasPrice","params":[],"id":1}`)
	resp, err := http.Post(
		"https://arc-rpc.blockreq.com/v1/rpc/public",
		"application/json",
		bytes.NewBuffer(payload),
	)
	if err != nil {
		panic(err)
	}
	defer resp.Body.Close()

	body, _ := io.ReadAll(resp.Body)
	var result map[string]interface{}
	json.Unmarshal(body, &result)
	fmt.Println(result["result"])
}
```

**viem**

```typescript
import { createPublicClient, http } from "viem";

const client = createPublicClient({
  transport: http("https://arc-rpc.blockreq.com/v1/rpc/public"),
});

const result = await client.request({
  method: "eth_gasPrice",
  params: [],
});
console.log(result);
```

**Foundry**

```bash
cast rpc --rpc-url https://arc-rpc.blockreq.com/v1/rpc/public eth_gasPrice
```

**Hardhat**

```javascript
const { ethers } = require("hardhat");

async function main() {
  const provider = new ethers.JsonRpcProvider("https://arc-rpc.blockreq.com/v1/rpc/public");
  const result = await provider.send("eth_gasPrice", []);
  console.log(result);
}

main();
```
