-
Notifications
You must be signed in to change notification settings - Fork 102
/
NEP5.Owner.cs
40 lines (34 loc) · 1.21 KB
/
NEP5.Owner.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
using Neo.SmartContract.Framework;
using Neo.SmartContract.Framework.Services.Neo;
using Neo.SmartContract.Framework.Services.System;
using System;
namespace Template.NEP5.CSharp
{
public partial class NEP5 : SmartContract
{
public static bool Deploy()
{
if (!IsOwner()) throw new Exception("No authorization.");
if (TotalSupplyStorage.Get() > 0) throw new Exception("Contract has been deployed.");
TotalSupplyStorage.Increase(InitialSupply);
AssetStorage.Increase(Owner, InitialSupply);
OnTransfer(null, Owner, InitialSupply);
return true;
}
public static bool Update(byte[] script, string manifest)
{
if (!IsOwner()) throw new Exception("No authorization.");
// Check empty
if (script.Length == 0 && manifest.Length == 0) return false;
Contract.Update(script, manifest);
return true;
}
public static bool Destroy()
{
if (!IsOwner()) throw new Exception("No authorization.");
Contract.Destroy();
return true;
}
private static bool IsOwner() => Runtime.CheckWitness(Owner);
}
}