-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathlab3_storage.cs
39 lines (33 loc) · 1.16 KB
/
lab3_storage.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
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services.Neo;
using System;
using System.Numerics;
namespace lab3_storage
{
public class lab3_storage : SmartContract
{
public static void Main()
{
// Get a copy of the NEO Storage context
StorageContext ctx = Storage.CurrentContext;
string item_key = "test-storage-key";
Runtime.Notify("item_key", item_key);
// Try to get a value for this key from storage
BigInteger item_value = Storage.Get(ctx, item_key).AsBigInteger();
Runtime.Notify("item_value", item_value);
if (item_value == 0)
{
Runtime.Notify("Storage key not set. Setting item_value to 1");
item_value = 1;
}
else
{
Runtime.Notify("Storage key already set. Incrementing item_value by 1");
item_value += 1;
}
// Put the updated value for this key into NEO Storage
Storage.Put(ctx, item_key, item_value);
Runtime.Notify("New item_value", item_value);
}
}
}