MINER methods
The MINER API methods allow you to control settings related to block creation.
The MINER API is not enabled by default for JSON-RPC.
Enable it using the --rpc-http-api or --rpc-ws-api option.
miner_changeTargetGasLimit
Updates the target gas limit set using the --target-gas-limit command line option.
Parameters
gasPrice: number - Target gas price in wei.
Returns
Successorerror.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_changeTargetGasLimit",
"params": [
800000
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_changeTargetGasLimit",
"params": [
800000
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "Success"
}
miner_getExtraData
Retrieves the current extra data field that is used when producing blocks.
Parameters
- None
Returns
- Hexadecimal string representation of the extra data bytes.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_getExtraData",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_getExtraData",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x68656c6c6f20776f726c64"
}
miner_getMinGasPrice
Gets the minimum gas price (in wei) offered by a transaction to be included in a block.
The initial value is set using the --min-gas-price command line
option, or is set to 1000 if the command line option is not specified.
Use miner_setMinGasPrice to change the current value of the gas price.
Parameters
- None
Returns
- Minimum gas price (in wei) as a hexadecimal string.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_getMinGasPrice",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_getMinGasPrice",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x3e8"
}
miner_getMinPriorityFee
Gets the minimum priority fee per gas (in wei) offered by a transaction to be included in a block. The initial value is set using the --min-priority-fee command line option, or is set to 0 if the command line option is not specified.
Use miner_setMinPriorityFee to change the current value of the fee.
Parameters
- None
Returns
- Minimum priority fee per gas (in wei) as a hexadecimal string.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_getMinPriorityFee",
"params": [],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_getMinPriorityFee",
"params": [],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x1"
}
miner_setExtraData
Sets a new value for the extra data field that is used when producing blocks.
Parameters
extraData: string - Hexadecimal representation of the extra data field, with a maximum of 32 bytes.
Returns
trueorfalse.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_setExtraData",
"params": [
"0x0010203"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_setExtraData",
"params": [
"0x0010203"
],
"id": 1
}
{
"jsonrpc": "2.0",
"params": ["0x0010203"],
"id": 1,
"result": "true"
}
miner_setMinGasPrice
Sets the minimum gas price (in wei) offered by a transaction to be included in a block.
The initial value is set using the --min-gas-price command line
option, or is set to 1000 if the command line option is not specified.
Use miner_getMinGasPrice to get the current value of the gas price.
Parameters
minGasPrice: string - Minimum gas price in hexadecimal.
Returns
truewhen the gas price is set.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_setMinGasPrice",
"params": [
"0x5dc"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_setMinGasPrice",
"params": [
"0x5dc"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}
miner_setMinPriorityFee
Sets the minimum priority fee per gas (in wei) offered by a transaction to be included in a block.
The initial value is set using the --min-priority-fee command line option, or is set to 0 if the command line option is not specified.
Use miner_getMinPriorityFee to get the current value of the fee.
Parameters
minPriorityFeePerGas: string - Minimum priority fee per gas in hexadecimal.
Returns
truewhen the fee is set.
Example
- curl HTTP request
- wscat WS request
- JSON result
curl -X POST http://127.0.0.1:8545/ \
-H "Content-Type: application/json" \
--data '{
"jsonrpc": "2.0",
"method": "miner_setMinPriorityFee",
"params": [
"0x0a"
],
"id": 1
}'
{
"jsonrpc": "2.0",
"method": "miner_setMinPriorityFee",
"params": [
"0x0a"
],
"id": 1
}
{
"jsonrpc": "2.0",
"id": 1,
"result": true
}