EIP1559 call for early users
The develpment of EIP1559 is completed by https://github.com/XinFinOrg/XDPoSChain/pull/527 now.
Our parameters:
- InitialBaseFee: 12.5 GWei
- BaseFee: fixed value 12.5 GWei
- GasLimit of block: not changed
1. Get source code
git clone https://github.com/XinFinOrg/XDPoSChain.git
2. Test private network
2.1 Create genesis
If genesis file is not exist, it can be created according to the below guides:
- https://medium.com/xinfin/how-to-set-up-a-private-blockchain-network-with-xdc-network-codebase-b2ee82368e83
- https://github.com/gzliudan/Local_DPoS_Setup/blob/private-network/setup-guide.md
Then add parameter eip1559Block
to your genesis file, such as:
{
"config": {
"eip1559Block": 0,
}
}
Here I use block number 0 as the EIP1559 block because I will start a new private network. You can use any block number you like. If an existing private network is used, then it must be greater than the current block number.
Notice: we can also set the variable Eip1559Block
in the file common/constants.go
.
2.2 Start private network
Then you can build and start your private network according to guides.
3. How to use
3.1 foundry
- legacy transaction:
--legacy
or--legacy --gas-price <price>
- EIP1559 transaction with max fee per gas :
--with-gas-price <price>
- EIP1559 transaction with priority fee per gas:
--priority-gas-price <PriorityFee>
3.2 MetaMask
You can edit Max base fee
and Priority Fee
manually before confirm transaction.
3.3 HardHat
It seems that hardhat.config.js
has no parameters for EIP1559. But we can define parameters in the individual transaction code. Please refer to https://medium.com/klaytn/using-ethereum-tools-in-klaytn-dc068d48de04.
3.4 Truffle
3.5 viem
4. Releated API
RPC="http://localhost:8545/"
4.1 eth_getBlockByNumber
Request:
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1001,
"method": "eth_getBlockByNumber",
"params": [
"latest",
false
]
}' | jq
Response:
{
"result": {
"baseFeePerGas": "0x2e90edd00",
}
}
Verify: baseFeePerGas = 12500000000.
4.2 eth_maxPriorityFeePerGas
Request:
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1002,
"method": "eth_maxPriorityFeePerGas",
"params": []
}' | jq
Response:
{
"result": "0x1"
}
Verify: result is reasonable.
4.3 eth_gasPrice
Request:
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1003,
"method": "eth_gasPrice",
"params": []
}' | jq
Response:
{
"result": "0x2e90edd01"
}
Verify: result = baseFeePerGas + eth_maxPriorityFeePerGas.
4.4 eth_feeHistory
Usage: https://docs.infura.io/api/networks/ethereum/json-rpc-methods/eth_feehistory#parameters
Request:
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1004,
"method": "eth_feeHistory",
"params": [
"0x3",
"latest",
[20,50]
]
}' | jq
4.5 eth_getTransactionByHash
Send 3 transactions to the private network, such as:
- legacy tx:
forge script -vv --broadcast --legacy scripts/deploy/deploy-fiat-token.s.sol --rpc-url ${RPC}
- EIP1559 tx with parameter maxFeePerGas:
forge script -vv --broadcast scripts/deploy/deploy-fiat-token.s.sol --rpc-url ${RPC} --with-gas-price 12501000000
- EIP1559 tx with maxPriorityFeePerGas:
forge script -vv --broadcast scripts/deploy/deploy-fiat-token.s.sol --rpc-url ${RPC} --priority-gas-price 1000
and record their transaction id.
Request:
# eg: HASH="0xc64985e6faccc11c96a8baef1d989888022b75c958095e69d5e30938142a0375"
HASH=<HASH>
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1005,
"method": "eth_getTransactionByHash",
"params": [
"'"${HASH}"'"
]
}' | jq
Then verify tx's type, gasPrice, maxFeePerGas, maxPriorityFeePerGas in the response.
4.6 eth_getBlockReceipts
# eg: NUMBER="0x8"
NUMBER=<NUMBER>
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 1006,
"method": "eth_getBlockReceipts",
"params": [
"'"${NUMBER}"'"
]
}' | jq
Verify tx's type and effectiveGasPrice in the response.
4.7 eth_getTransactionReceipt
Request:
curl -s -X POST -H "Content-Type: application/json" ${RPC} -d '{
"jsonrpc": "2.0",
"id": 5002,
"method": "eth_getTransactionReceipt",
"params": [
"'"${HASH}"'"
]
}' | jq
Verify tx's type and effectiveGasPrice in the response.
5. Test synchronization
Although out network does not support EIP1559 now, the new codes can synchronize with any network normally and act as RPC without EIP1559 functions. You can use below scripts to sync:
- devnet: sync_devnet.sh
- testnet: sync-apothem.sh
- mainnet: sync-xinfin.sh
Discussion (0)