Fee Limit on Deploy/Execution
It is highly recommended to set an appropriate fee limit before deploying a contract to Mainnet. The fee limit refers to the upper limit of the smart contract deploy/execution cost, in TRX. See Energy for energy cost models. This limit is measured in SUN, which is 1e-6 TRX. The maximum limit is 1000 TRX, or 1e9 SUN. Setting it to a value larger than 1e9 will produce an error.
When deploying large contracts or running complex functions, this limit may need to be increased up to 1000 TRX. However, check out timeouts, infinite loops, illegal operations, and non-existent account transfer sections are why setting a higher limit may sometimes be bad practice.
This value can be set in both Tron-Box and Tron-Web:
For Tron-Box smart contract deployment, all global settings are in the tronbox.js file. Within this file, there is a parameter called feeLimit, which refers to the fee limit.
JavaScript
module.exports = < networks: < development: < from: 'TPL66VK2gCXNCD7EJg9pgJRfqcRazjhUZY', privateKey: 'da146374a75310b9666e834ee4ad0866d6f4035967bfc76217c5a495fff9f0d0', consume_user_resource_percent: 30, feeLimit: 1e9, // Set fee limit originEnergyLimit: 1e7, fullHost: 'https://api.shasta.trongrid.io', network_id: "*" // Match any network id >, > >;
The tronweb.contract.new API call takes in a parameter called feeLimit. This parameter refers to the fee limit.
JavaScript
let abi = 'abi'; let code = 'bytecode'; async function deploy_contract() < let contract_instance = await tronWeb.contract().new(< abi: JSON.parse(abi), bytecode: code, feeLimit: 1e9, // Set fee limit callValue: 0, userFeePercentage: 30, originEnergyLimit: 1e7, parameters: [param1, param2, param3, . ] >) console.log(contract_instance.address); > deploy_contract();
Updated about 5 years ago