Expense limit description
Fee limit
Before deploying a contract on the mainnet, it is best to set a reasonable fee limit. The cost limit refers to the upper limit of the smart contract deployment/execution cost in VS. For the entropy cost model, see Entropy. This limit is measured in vdt (1e-6 VS). The maximum limit is 1000 VS or 1e9 vdt. If it is set to a value greater than 1e9, an error will be generated.
When deploying large contracts or running complex functions, this limit may need to be increased to 1000 VS. However, checking for timeouts, infinite loops, illegal operations, and non-existent account transfers are the reasons why setting higher limits can sometimes be bad practice.
This value can be set in VisionBox and VisionWeb:
VisionBox
As far as VisionBox smart contract deployment is concerned, all global settings are in the visionbox.js file, and the feeLimit parameter refers to the fee limit.
module.exports = {
development: {
from: 'VR7P6zGiRDP4G1pkWGqe3Ys91CBchk82Nn',
privateKey: 'c87bc65d9b47c8b93809ea948fe92dd55fbdeedf59bc47ce0830f39ae7176cc7',
consume_user_resource_percent: 60,
fee_limit: 100000000, // fee limit
host: "https://vtest.infragrid.v.network/",
port: 8090,
fullNode: "https://vtest.infragrid.v.network/",
solidityNode: "https://vtest.infragrid.v.network/",
eventServer: "https://vtest.infragrid.v.network/",
network_id: "*" // Match any network id
}
};
VisionWeb
The API call of visionweb.contract.new passes in a parameter named feeLimit. This parameter refers to the fee limit.
let abi = 'abi';
let code = 'bytecode';
async function deploy_contract() {
let contract_instance = await visionweb.contract().new({
abi: JSON.parse(abi),
bytecode: code,
feeLimit: 1e9, // Set fee limit
callValue: 0,
userFeePercentage: 60,
originEntropyLimit: 1e7,
parameters: [param1, param2, param3, ...]
})
console.log(contract_instance.address);
}
deploy_contract();
Updated over 3 years ago