private static bool Deploy(NEP5Base tokenBase) { bool result = false; if (true) // Runtime.CheckWitness(_OwnerAccountScriptHash)) { StorageContext ctx = Storage.CurrentContext; // Create on-chain ledger entry for the owner of this token. Check to see if the ledger already exists byte[] currentBalance = Storage.Get(ctx, tokenBase.OwnerAccountScriptHash); if (currentBalance.Length == 0) { Storage.Put(ctx, _OwnerAccountScriptHash, tokenBase.TotalSupply); result = true; } } return(result); }
public static object Main(string operation, params object[] args) { object result = false; // = 0 (zero) NEP5Base TOKENBASE = new NEP5Base { TotalSupply = _TotalSupply, Name = _Name, Symbol = _Symbol, Decimals = _Decimals, OwnerAccountScriptHash = _OwnerAccountScriptHash }; if (operation == "totalSupply") { Runtime.Notify("totalSupply"); result = TotalSupply(); } else if (operation == "name") { Runtime.Notify("name"); result = Name(); } else if (operation == "symbol") { Runtime.Notify("symbol"); result = Symbol(); } else if (operation == "decimals") { Runtime.Notify("decimals"); result = Decimals(); } else if (operation == "balanceOf") { if (args.Length < 1) { result = false; } else { byte[] account = (byte[])args[0]; Runtime.Notify("balanceOf"); result = BalanceOf(account); } } else if (operation == "transfer") { if (args.Length < 3) { result = false; } else { byte[] from = (byte[])args[0]; byte[] to = (byte[])args[1]; BigInteger amount = (BigInteger)args[2]; Runtime.Notify("transfer", args[0], args[1], args[2]); result = Transfer(from, to, amount); } } else if (operation == "deploy") { Runtime.Notify("deploy"); result = Deploy(TOKENBASE); } else { result = false; } return(result); }