-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCSharpStorage.cs
50 lines (38 loc) · 1.23 KB
/
CSharpStorage.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
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services.Neo;
using Neo.SmartContract.Framework.Services.System;
using System;
using System.Numerics;
namespace CSharpStorage
{
public class TestContract : Neo.SmartContract.Framework.SmartContract
{
public static int Main(string operation, string key, int x)
{
if (operation == "print")
{
Runtime.Log("Hello nickazg");
return 1;
}
if (operation == "write")
{
Storage.Put(Storage.CurrentContext, key, x);
Runtime.Notify("The number was stored", key, x);
return 2;
}
if (operation == "read")
{
byte[] bytes = Storage.Get(Storage.CurrentContext, key);
BigInteger y = bytes.AsBigInteger();
Runtime.Notify("y", y);
for (int i = 0; i < 5; i++)
{
y = 2 * y;
Runtime.Notify("multiply by two", y);
}
return 3;
}
return 404;
}
}
}