This project serves as a reference implementation of the Augur Bitcoin fee estimation library. It demonstrates how to:
- Connect to a Bitcoin Core instance and persist mempool snapshots
- Calculate fee estimates using Augur's prediction model
- Expose fee estimates via a REST API
This reference service is intended to showcase the features of the Augur library, and is meant as a tool for exploring the fee estimation data that Augur generates. It serves as example code on how to integrate the library into a Kotlin codebase; it is not intended to be used as a production-ready fee estimation service.
- Mempool Data Collection: Connects to Bitcoin Core via RPC and collects mempool data at regular intervals
- Persistence: Stores mempool snapshots for later analysis and fee estimation
- Fee Estimation: Uses the Augur library to calculate fee estimates based on historical mempool data
- REST API: Exposes fee estimates through a simple HTTP endpoint
- Java 17 or higher
- Access to a Bitcoin Node with RPC access (specifically, requires the
getrawmempoolandgetblockchaininfoRPC methods)
The application uses YAML for configuration with support for environment variable overrides.
- Environment Variables: Highest priority
- External Config File: Specified by
AUGUR_CONFIG_FILEenvironment variable - Default Config: From
config.yamlin resources
| Setting | Environment Variable | Default | Description |
|---|---|---|---|
server.host |
AUGUR_SERVER_HOST |
0.0.0.0 |
HTTP server host |
server.port |
AUGUR_SERVER_PORT |
8080 |
HTTP server port |
bitcoinRpc.url |
BITCOIN_RPC_URL |
http://localhost:8332 |
Bitcoin Core RPC URL |
bitcoinRpc.username |
BITCOIN_RPC_USERNAME |
(empty) | Bitcoin Core RPC username |
bitcoinRpc.password |
BITCOIN_RPC_PASSWORD |
(empty) | Bitcoin Core RPC password |
persistence.dataDirectory |
AUGUR_DATA_DIR |
mempool_data |
Directory for storing mempool snapshots |
server:
host: "0.0.0.0"
port: 8080
bitcoinRpc:
url: "http://localhost:8332"
username: "rpcuser"
password: "rpcpassword"
persistence:
dataDirectory: "mempool_data"This project uses CashApp's Hermit. Hermit ensures that your team, your contributors, and your CI have the same consistent tooling. Here are the installation instructions.
Activate Hermit either
by enabling the shell hooks (one-time only, recommended) or manually
sourcing the env with . ./bin/activate-hermit.
Use gradle to run all tests:
bin/gradle buildbin/gradle runBITCOIN_RPC_USERNAME=myuser BITCOIN_RPC_PASSWORD=mypassword bin/gradle runAUGUR_CONFIG_FILE=/path/to/my-config.yaml bin/gradle runAlternatively, you can use Docker by first defining the bitcoinRpc username and password in the config.yaml file,
and then using:
docker build -t bitcoin-augur-reference .
docker run -p 8080:8080 bitcoin-augur-referenceOnce running, the application exposes fee estimates at:
GET /fees
Example response:
{
"mempool_update_time": "2025-03-03T19:13:50.043Z",
"estimates": {
"3": {
"probabilities": {
"0.05": {
"fee_rate": 2.0916
},
"0.20": {
"fee_rate": 3.0931
},
"0.50": {
"fee_rate": 3.4846
},
"0.80": {
"fee_rate": 4.0535
},
"0.95": {
"fee_rate": 5.0531
}
}
},
"6": {
"probabilities": {
"0.05": {
"fee_rate": 1.9631
},
"0.20": {
"fee_rate": 2.9441
},
"0.50": {
"fee_rate": 3.1191
},
"0.80": {
"fee_rate": 3.4903
},
"0.95": {
"fee_rate": 4.8708
}
}
},
"9": {
"probabilities": {
"0.05": {
"fee_rate": 1.8778
},
"0.20": {
"fee_rate": 2.8979
},
"0.50": {
"fee_rate": 3.1154
},
"0.80": {
"fee_rate": 3.4903
},
"0.95": {
"fee_rate": 4.2041
}
}
}
}
}Historical fee estimates at:
GET /historical_fee?timestamp=<unix_timestamp>
Example response:
{
"mempool_update_time" : "2025-08-16T14:05:44.854Z",
"estimates" : {
"3" : {
"probabilities" : {
"0.05" : {
"fee_rate" : 1.0
},
"0.20" : {
"fee_rate" : 1.0
},
"0.50" : {
"fee_rate" : 1.0
},
"0.80" : {
"fee_rate" : 1.0
},
"0.95" : {
"fee_rate" : 1.0
}
}
},
"6" : {
"probabilities" : {
"0.05" : {
"fee_rate" : 1.0
},
"0.20" : {
"fee_rate" : 1.0
},
"0.50" : {
"fee_rate" : 1.0
},
"0.80" : {
"fee_rate" : 1.0
},
"0.95" : {
"fee_rate" : 1.0
}
}
},
"9" : {
"probabilities" : {
"0.05" : {
"fee_rate" : 1.0
},
"0.20" : {
"fee_rate" : 1.0
},
"0.50" : {
"fee_rate" : 1.0
},
"0.80" : {
"fee_rate" : 1.0
},
"0.95" : {
"fee_rate" : 1.0
}
}
}
}
}
If you'd like to use a local version of Augur within your reference implementation:
- Within Augur, run
bin/gradle shadowJarto build a fat jar of Augur. - Copy the file
lib/build/libs/augur.jarinto this reference implementationapp/libsdirectory. - Change
implementation(libs.augur)toimplementation(files("libs/augur.jar"))in theapp/build.gradle.ktsfile. - Within the reference implementation, run
bin/gradle buildto build the project with the local version of Augur.
config: Configuration classesbitcoin: Bitcoin Core RPC clientpersistence: Mempool snapshot persistenceservice: Core application servicesapi: API endpointsserver: HTTP server setup
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.