👋
Vision Network
  • Vision Basics
    • Vision Network
    • VS and VRC
    • The GitBook editor
    • Token Issuance
    • Minting Mechanism
  • Protocol
    • Account
    • Resource Model
    • Economic model
    • Multi-Signature
    • Transaction
    • Validator
      • First Validator & Reward Mechanism
      • To be Validated Candidate
      • Proposal and Committee
  • SMART CONTRACTS
    • Introduction
    • Deployment Cost
    • DevOps Flow
    • Key considerations
    • Security considerations
    • Features
      • Protobuf
      • Function Usage
      • Contract Address
      • Different Form Ethereum
  • VIRTUAL MACHINE
    • Introduction
    • Event
    • Entropy Costs Calculation
    • VM Exception Handling
    • Features between Ethereum
  • HTTP API
  • Signature and Broadcast Steps
  • Infragrid guide
  • Vtimes chrome integration
  • Introduction
  • Getting Started
  • Group 1
    • Introduction
    • GUI and Usage
  • VISION-WEB
    • Introduction
  • VISION WALLET
    • Vtimes Chrome Plugin
    • Visionscan
    • Metamask
  • DECENTRALIZED EXCHANGES
    • Operating principle
    • Trading pairs
    • Liquidity pool
  • Others
    • Term
Powered by GitBook
On this page
  • User pay ratio
  • In Vision-Box
  • In VisionWeb
  1. SMART CONTRACTS

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);
}
PreviousDevOps FlowNextSecurity considerations

Last updated 3 years ago