Key considerations

Mainly introduce the parameter configuration in smart contract development.

User pay ratio

The user payment ratio is defined as the ratio of expenses that the smart contract user should pay. For example, if the user pay ratio is set to 60, the user pays 60% of the contract cost. This parameter will accept any integer between 0 and 100, including 0 and 100. However, it is strongly recommended to set a value between 1 and 99. The main purpose is to protect yourself and avoid contract developers from malicious infinite loop timeout attacks.

Set up when the contract is deployed:

In Vision-Box

When deploying the contract, use the visionbox.js file and modify the parameter of consume_user_resource_percent:, which refers to the user's payment ratio.

Text

module.exports = {
 networks: {
  development: {
    from: 'VR7P6zGiRDP4G1pkWGqe3Ys91CBchk82Nn',
    privateKey: 'c87bc65d9b47c8b93809ea948fe92dd55fbdeedf59bc47ce0830f39ae7176cc7',
    consume_user_resource_percent: 60, //user pay ratio
    fee_limit: 100000000,
    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
  }
 }
};

In VisionWeb

The visionWeb.contract.new API call accepts a parameter named userFeePercentage. This parameter refers to the user payment ratio.

Text

let abi = 'abi for contract';
let code = 'bytecodes';
async function deploy_contract(){
 let contract_instance = await visionWeb.contract().new({
 abi:JSON.parse(abi),
 bytecode:code,
 feeLimit = 1_000_000_000,
 callValue = 0,
 userFeePercentage = 1, // user pay ratio
 parameters:[para1,2,3,...]
 })
 console.log(contract_instance.address);
}

Last updated