-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathHelloWorld2.cs
70 lines (62 loc) · 1.36 KB
/
HelloWorld2.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
using Stratis.SmartContracts;
/// <summary>
/// An extension to the "Hello World" smart contract
/// </summary>
[Deploy]
public class HelloWorld2 : SmartContract
{
private int Index
{
get
{
return this.State.GetInt32("Index");
}
set
{
this.State.SetInt32("Index", value);
}
}
private int Bounds
{
get
{
return this.State.GetInt32("Bounds");
}
set
{
this.State.SetInt32("Bounds", value);
}
}
private string Greeting
{
get
{
this.Index++;
if (this.Index >= this.Bounds)
{
this.Index = 0;
}
return this.State.GetString("Greeting" + this.Index);
}
set
{
this.State.SetString("Greeting" + this.Bounds, value);
this.Bounds++;
}
}
public HelloWorld2(ISmartContractState smartContractState) : base(smartContractState)
{
this.Bounds = 0;
this.Index = -1;
this.Greeting = "Hello World!";
}
public string SayHello()
{
return this.Greeting;
}
public string AddGreeting(string helloMessage)
{
this.Greeting = helloMessage;
return "Added '" + helloMessage + "' as a greeting.";
}
}