MaticGasStation Network is a REST API service that provides current gas price recommendations for Polygon PoS and Zkevm transactions. This service offers developers a convenient way to retrieve real-time gas prices and make informed decisions about transaction fees on the Polygon PoS and Zkevm network.
$ git clone https://github.com/maticnetwork/
$ npm install
- Prepare
.env
file & paste following content in .env.sample file into it. You may want to check configuratoin.
touch .env
Example
POS_RPC=<pos rpc url>
ZKEVM_RPC=<zkevm rpc url>
PORT=7000
SAFE=5
STANDARD=15
FAST=30
HISTORY_BLOCKS=15
- Run service
npm start
- Run tests
npm tests
Assuming you've docker set up & running,
- Build docker image with tag mgs
# all commands executed at root of project
docker build . -t mgs
- Run docker image at port 7000 and name the container
docker run -p 7000 -d --name matic_gas_station mgs
- Check docker container running
docker ps
- Check log
docker logs -f matic_gas_station
- Stop container
docker stop matic_gas_station
- Restart container
docker restart matic_gas_station
- Remove container
docker rm matic_gas_station
- Remove image
docker rmi -f matic_gas_station
Request
curl -s localhost:7000/pos/v1
Response
{
"success": true,
"data": {
"safeLow": 129.47556613,
"standard": 129.47556613,
"fast": 129.47556613,
"blockTime": 2,
"blockNumber": 45068237
}
}
Request
curl -s localhost:7000/pos
(or)
curl -s localhost:7000/pos/v2
Response
{
"success": true,
"data": {
"safeLow": {
"maxPriorityFee": 30,
"maxFee": 189.831563019
},
"standard": {
"maxPriorityFee": 30,
"maxFee": 189.831563019
},
"fast": {
"maxPriorityFee": 31.931367927,
"maxFee": 191.762930946
},
"estimatedBaseFee": 159.831563019,
"blockTime": 2,
"blockNumber": 45068158
}
}
Request
curl -s localhost:7000/zkevm
Response
{
"success": true,
"data": {
"safeLow": 1.04,
"standard": 1.04,
"fast": 1.04,
"blockTime": 1.5,
"blockNumber": 2526102
}
}
Field | Interpretation |
---|---|
Safe | Minimum gas price at which X % of last N tx(s) got accepted |
Standard | Average gas price at which X % of last N tx(s) got accepted |
Fast | Highest gas price at which X % of last N tx(s) got accepted |
POS_RPC | PoS node's endpoint |
ZKEVM_PRC | Zkevm node's endpoint |
Port | Accept connections on port |
HistoryOfBlocks | The last N history of blocks |
Field | Interpretation |
---|---|
SafeLow | Lowest possible recommended gas price |
Standard | Average gas price seen ( Recommended ) |
Fast | Tx should be included in ~30 sec |
BlockTime | Observed delay between two recently mined consequtive blocks |
BlockNumber | Latest considered block in recommendation |
Note: All gas prices in
Gwei
Our Discord is the best way to reach us ✨.
You are very welcome to contribute, please see contributing guidelines - [Contribute].
Thank you to all the people who already contributed to maticgasstation!
Made with contributors-img.