Optimize Your Transaction Fees
This section will help you to reduce the transaction fees on Mantle v2 Tectonic. Mantle v2 Tectonic introduces a new fee collection mechanism, including EIP-1559 and some native token optimizations, if you want to know more details about our fee collection mechanism, please refer to this document.
In Mantle v2 Tectonic, with the introduction of the EIP-1559 mechanism, users need to configure the network's basefee
(the minimum basefee currently set 0.02 gwei
) and priorityfee
(recommend to set it to 0) configurations in order to optimize the transaction fees. We explain the different development components to optimize the user experience.
MetaMask
If you are a user of MetaMask for trading or contract deployment and interaction (e.g. using Remix), you can set up basefee
and priorityfee
in MetaMask to be able to send transactions at a lowest fee. Details can be found here.
Hardhat
If you are using Hardhat for contract deployment and interaction, you can use the default configuration in hardhat.config.ts
or specify gasPrice
as the network minimum basefee:
const config: HardhatUserConfig = {
solidity: '0.8.19', // solidity version
defaultNetwork: 'mantleSepolia', // chosen by default when network isn't specified while running Hardhat
networks: {
mantle: {
url: 'https://rpc.mantle.xyz', //mainnet
accounts: [process.env.ACCOUNT_PRIVATE_KEY ?? ''],
// Use the default configuration
},
mantleSepolia: {
url: 'https://rpc.sepolia.mantle.xyz', // Sepolia Testnet
accounts: [process.env.ACCOUNT_PRIVATE_KEY ?? ''],
gasPrice: 20000000, // specify the network's minimum basefee as the gas price
},
},
};
Foundry
If you are using Foundry for contract deployment and interaction, you need to set it up on the corresponding command line:
Contracts Deployment
Currently, for users deploying contracts using forge create
, we strongly recommend using the legacy transaction type.
Make sure you are using the latest version of Foundry, if you are using a version lower than 2024-07-31
, please add -skip-simulation
to your command line to ensure successful execution!
- Use forge script
- Use forge create
When you use the forge script
for contract deployment, there are different settings for different transaction types:
-
legacy transactions
If you are using legacy type transactions, you can use the following command for contract deployment, e.g.
forge script --legacy script/Deploy.s.sol:DeploySiege --sig "run()" --rpc-url <mantle_rpc_url> --broadcast
-
EIP-1559 transactions
If you are using EIP-1559 type transactions, you need to set the
--with-gas-price
parameter to the network minimum basefee, using the following command to deploy the contract, e.g.forge script script/Deploy.s.sol:DeploySiege --sig "run()" --with-gas-price 20000000 --rpc-url <mantle_rpc_url> --broadcast
When you use forge create
for contract deployment, there are different settings for different transaction types:
-
legacy transactions (recommended)
If you are using legacy type transactions, you don't need to do any additional setup, use the following commands for contract deployment, e.g.
forge create --legacy --rpc-url <mantle_rpc_url> ./script/StorageTest.sol:Storage --private-key <private_key>
-
EIP-1559 transactions
If using EIP-1559 type transactions, you need to set
--priority-gas-price
to0
,--gas-price
to20000000
(current network minimum basefee)--gas-limit
is40000000000
and the contract is deployed using the following command, e.g.forge create --rpc-url <mantle_rpc_url> ./script/StorageTest.sol:Storage --private-key <private_key> --priority-gas-price 0 --gas-price 20000000 --gas-limit 40000000000