Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const contractModule = function (exports, require, module, pfe) {
- // SomeContract smart contract code
- }
- const exports = {};
- const require = function (moduleName) {
- // the packet search logic available for a smart contract
- }
- const module = {
- name: "SomeContract"
- }
- const fee = 0.004 /* a fee for the whole smart contract execution, taken from transaction */
- 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) */
- const pfe = function(price) {
- fee -= feePrice * price
- if (fee <=0 ) {
- throw new Exception('Funds insufficient to execute the new smart contract')
- }
- }
- // thus we get an exported smart contract class
- const contractClass = contractModule(exports, require, module, pfe).default;
- // smart contract object instantiation
- const contractObject = new contractClass();
- // serialization of a contract in the smart contract storage to find it there later with all the corresponding status data
- save(contractObject)
- 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.
- const contractObject = load('Smart contract address')
- contractObject.getRandom();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement