Research Article

To Delay Instantiation of a Smart Contract to Save Calculation Resources in IoT

Algorithm 3. Different instantiation combinations.

1: Define smart contract SCXI
2: …
3: End Define
4:
5: Define smart contract SCX-Post
6: …
7: End Define
8:
9: Define smart contract SCY-A
10: do other action
11: Variable scx = new Variable(”SCXI”);
12: invoking method1 of scx
13: do other action
14: invoke method2 of scx;
15: do other action
16: End Define
17:
18: Define smart contract SCY-B
19: do other action
20: Variable scx = new Variable(”SCX-Post”);
21: invoking method1 of scx; // Method1 is cached
22: do other action
23: invoke method2 of scx; // Method2 requires to have a real SCX smart contract instance
24: do other action
25: End Define
26:
27: Define smart contract SCY-C
28: do other action
29: //scope begin {
30: Variable scx = new Variable(”SCXI”);
31: invoking method of scx
32: do other action
33: invoke method of scx;
34: //scope end }
35: do other action
36: End Define
37:
38: Define smart contract SCY-D
39: do other action
40: //scope begin {
41: Variable scx = new Variable(”SCX-Post”);
42: invoking method1 of scx; // Method1 is cached
43: do other action
44: invoke method2 of scx; // Method2 requires to have a real SCA smart contract instance
45: //scope end }
46: do other action
47: End Define
Algorithm 3. Different instantiation combinations.