Advertisement
Guest User

Untitled

a guest
Jan 16th, 2019
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. const contractModule = function (exports, require, module, pfe) {
  2.   // SomeContract smart contract code
  3. }
  4.  
  5. const exports = {};
  6. const require = function (moduleName) {
  7.   // the packet search logic available for a smart contract
  8. }
  9. const module = {
  10.   name: "SomeContract"
  11. }
  12.  
  13. const fee = 0.004 /* a fee for the whole smart contract execution, taken from transaction */
  14. const feePrice = 0.00000001 /* one elementary execution unit cost, taken from transaction (a tool to raise the fee and the transaction priority to be included in the next block) */
  15.  
  16. const pfe = function(price) {
  17.   fee -= feePrice * price
  18.   if (fee <=0 ) {
  19.     throw new Exception('Funds insufficient to execute the new smart contract')
  20.   }
  21. }
  22.  
  23. // thus we get an exported smart contract class
  24. const contractClass = contractModule(exports, require, module, pfe).default;
  25. // smart contract object instantiation
  26. const contractObject = new contractClass();
  27. // serialization of a contract in the smart contract storage to find it there later with all the corresponding status data
  28. save(contractObject)
  29.  
  30. The method is called equivalently to the sample above but we should keep in mind that the object of a smart contract created above has been serialized somewhere and to call its method later - deserialized all its status data.
  31.  
  32. const contractObject = load('Smart contract address')
  33. contractObject.getRandom();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement