3

I have my base currency as 18 decimals like 1_000_000_000_000_000_000. I want to set my base fee to charge using 1_000_000_000_000_000_000 for each evm transaction. How can i do? currently i have done this but not working properly.

pub struct FixedGasPrice;

impl FeeCalculator for FixedGasPrice {
    fn min_gas_price() -> U256 {
        (1 * 1_000_000_000).into()
    }
}

if i try to change this formula into (1 * 1_000_000_000_000_000_000).into() i am getting error whenever i try to deploy the contract from remix. I am getting below error:

creation of MyToken20 errored: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"code":-32603,"message":"submit transaction to pool failed: Pool(InvalidTransaction(InvalidTransaction::Custom(1)))"}}} 
4
  • Consider specifying: what error are you getting?
    – pepyakin
    Commented Apr 27, 2022 at 9:54
  • creation of MyToken20 errored: [ethjs-query] while formatting outputs from RPC '{"value":{"code":-32603,"data":{"code":-32603,"message":"submit transaction to pool failed: Pool(InvalidTransaction(InvalidTransaction::Custom(1)))"}}}' Commented Apr 27, 2022 at 9:56
  • hey @FarazAhmad, were you able to change the runtime params as I said in my reply? Please consider accepting it as the correct answer if it worked for you.
    – afm
    Commented Jul 23, 2022 at 16:51
  • hey @afm i tried using your solution but in my case the transction fee keeps on decreasing ... supoose for 1st traction its 100 milli then for 2 second traction it becomes 100 micro them pico nano and them famto..it keeps on decreasing how can i fix this??? Commented Jan 5, 2023 at 11:33

2 Answers 2

3

To activate and set the BaseFee in your Frontier-based chain, you can simply change these runtime parameters:

frame_support::parameter_types! {
    pub IsActive: bool = true;
    pub DefaultBaseFeePerGas: U256 = U256::from(1_000_000_000);
}
1

Its likely web3.js has a great difference on gas_price with your own, you should add gasPrice to your transaction's option:

   gasPrice: await web3.eth.getGasPrice()
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.