// Factory methods // Template: NPCLevel1Part2_cs.txt
 private static NPCNEP5Base _Initialize(NPCNEP5Base e)
 {
     e._name = ""; e._symbol = ""; e._decimals = 0; e._totalSupply = 0; 
     e._state = NeoEntityModel.EntityState.NULL;
     if (NeoTrace.RUNTIME) LogExt("_Initialize(e).NPCNEP5Base", e);
     return e;
 }
 public static NPCNEP5Base Null()
 {
     NPCNEP5Base e = new NPCNEP5Base();
     _Initialize(e);
     if (NeoTrace.RUNTIME) LogExt("Null().NPCNEP5Base", e);
     return e;
 }
 public static NPCNEP5Base New(string Name, string Symbol, Int32 Decimals, BigInteger TotalSupply)
 {
     NPCNEP5Base e = new NPCNEP5Base();
     e._name = Name; e._symbol = Symbol; e._decimals = Decimals; e._totalSupply = TotalSupply; 
     e._state = NeoEntityModel.EntityState.INIT;
     if (NeoTrace.RUNTIME) LogExt("New(.,.).NPCNEP5Base", e);
     return e;
 }
        public static byte decimals(NPCNEP5Base tokenBase)
        {
            byte decimals = (byte)NPCNEP5Base.GetDecimals(tokenBase);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("decimals():entered", decimals);
            }

            return(decimals);
        }
        public static string symbol(NPCNEP5Base tokenBase)
        {
            string symbol = NPCNEP5Base.GetSymbol(tokenBase);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("symbol():entered", symbol);
            }

            return(symbol);
        }
        public static string name(NPCNEP5Base tokenBase)
        {
            string name = NPCNEP5Base.GetName(tokenBase);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("name():entered", name);
            }

            return(name);
        }
        public static BigInteger totalSupply(NPCNEP5Base tokenBase)
        {
            BigInteger totalSupply = NPCNEP5Base.GetTotalSupply(tokenBase);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("totalSupply():entered$INT", totalSupply);
            }

            return(totalSupply);
        }
        public static NPCNEP5LedgerEntry UpdateLedger(NPCNEP5Base tokenBase, NPCNEP5FundingRound[] fundingRounds)
        {
            NPCNEP5LedgerEntry e = new NPCNEP5LedgerEntry();

            if (NeoTrace.RUNTIME)
            {
                LogExt("UpdateLedger().NPCNEP5LedgerEntry", e);
            }

            return(e);
        }
        public static object Main(string operation, params object[] args)
        {
            object result = false;

            NPCNEP5Base tokenBase = NPCNEP5Base.New("My Meetup Token", "MMT", 8, 1000000);

            if (NeoTrace.VERBOSE)
            {
                NPCNEP5Base.Log("tokenBase", tokenBase);
            }

            result = ProcessOperation(tokenBase, operation, args);

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("result", result);
            }

            return(result);
        }
        public static bool deploy(NPCNEP5Base tokenbase)
        {
            bool result = false;

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("deploy():entered");
            }

            NPCEnvironment env = NPCEnvironment.New();

            NPCEnvironment.Initialize(env);

            NPCNEP5LedgerEntry ownerLedgerEntry = NPCNEP5LedgerEntry.Get(OwnerAccountScriptHash);

            if (NeoTrace.VERBOSE)
            {
                NPCNEP5LedgerEntry.Log("deploy().ownerLedgerEntry", ownerLedgerEntry);
            }
            if (NPCNEP5LedgerEntry.IsMissing(ownerLedgerEntry))
            {
                if (NeoTrace.VERBOSE)
                {
                    NeoTrace.Trace("ownerLedgerEntry is Missing");
                }
                NPCNEP5LedgerEntry.Set(ownerLedgerEntry,
                                       NPCEnvironment.GetBlockTimestamp(env), 0, NPCNEP5Base.GetTotalSupply(tokenbase));
                NPCNEP5LedgerEntry.Put(ownerLedgerEntry, OwnerAccountScriptHash);
                if (NeoTrace.VERBOSE)
                {
                    NPCNEP5LedgerEntry.Log("deploy().ownerLedgerEntry", ownerLedgerEntry);
                }
                result = true;
            }

            return(result);
        }
 public static void SetDecimals(NPCNEP5Base e, Int32 value) // Template: NPCLevel1SetXGetX_cs.txt
                        { e._decimals = value; e._state = NeoEntityModel.EntityState.SET; }
 public static void LogExt(string label, NPCNEP5Base e)
 {
     TraceRuntime(label, e._name, e._symbol, e._decimals, e._totalSupply, e._state);
 }
 // EntityState wrapper methods
 public static bool IsNull(NPCNEP5Base e)
 {
     return (e._state == NeoEntityModel.EntityState.NULL);
 }
        public static object ProcessOperation(NPCNEP5Base tokenBase, string operation, object[] args)
        {
            object result = false;

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("operation", operation);
            }

            if (operation == "deploy")
            {
                result = deploy(tokenBase);
            }
            else if (operation == "ping")
            {
                result = ping();
            }

            else if (operation == "name")
            {
                result = name(tokenBase);
            }
            else if (operation == "symbol")
            {
                result = symbol(tokenBase);
            }
            else if (operation == "decimals")
            {
                result = decimals(tokenBase);
            }
            else if (operation == "totalSupply")
            {
                result = totalSupply(tokenBase);
            }
            else if (operation == "balanceOf")
            {
                byte[] account = (byte[])args[0];
                if (NeoTrace.TESTING && account[0] == 0x0) // DEBUGGING
                {
                    account = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:from", account);
                    }
                }
                result = balanceOf(account);
            }
            else if (operation == "transfer")
            {
                if (args.Length == 3)
                {
                    // https://github.com/neo-project/examples-csharp/blob/master/ICO_Template/ICO_Template.cs#L59
                    byte[]     from   = (byte[])args[0];
                    byte[]     to     = (byte[])args[1];
                    BigInteger amount = (BigInteger)args[2];
                    if (NeoTrace.TESTING && from[0] == 0x0) // DEBUGGING
                    {
                        from = OwnerAccountScriptHash;
                        if (NeoTrace.VERBOSE)
                        {
                            NeoTrace.Trace("DEBUGGING:from", from);
                        }
                    }
                    result = transfer(from, to, amount);
                }
            }
            else if (operation == "allowance")
            {
                byte[] from = (byte[])args[0];
                byte[] to   = (byte[])args[1];
                if (NeoTrace.TESTING && from[0] == 0x0) // DEBUGGING
                {
                    from = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:from", from);
                    }
                }
                result = allowance(from, to); // optional
            }
            else if (operation == "transferFrom")
            {
                byte[]     originator = OwnerAccountScriptHash;
                byte[]     from       = (byte[])args[0];
                byte[]     to         = (byte[])args[1];
                BigInteger amount     = (BigInteger)args[2];
                if (NeoTrace.TESTING && originator[0] == 0x0) // DEBUGGING
                {
                    originator = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:originator", originator);
                    }
                }
                result = transferFrom(originator, from, to, amount); // optional
            }
            else if (operation == "approve")
            {
                byte[]     originator = OwnerAccountScriptHash;
                byte[]     to         = (byte[])args[0];
                BigInteger amount     = (BigInteger)args[1];
                if (NeoTrace.TESTING && originator[0] == 0x0) // DEBUGGING
                {
                    originator = OwnerAccountScriptHash;
                    if (NeoTrace.VERBOSE)
                    {
                        NeoTrace.Trace("DEBUGGING:originator", originator);
                    }
                }
                result = approve(originator, to, amount); // optional
            }

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("result", result);
            }

            return(result);
        }
 public static void Set(NPCNEP5Base e, string Name, string Symbol, Int32 Decimals, BigInteger TotalSupply) // Template: NPCLevel1Set_cs.txt
                         { e._name = Name; e._symbol = Symbol; e._decimals = Decimals; e._totalSupply = TotalSupply;  e._state = NeoEntityModel.EntityState.SET; }        
 public static string GetName(NPCNEP5Base e) { return e._name; }
 public static BigInteger GetTotalSupply(NPCNEP5Base e) { return e._totalSupply; }
 public static void SetTotalSupply(NPCNEP5Base e, BigInteger value) // Template: NPCLevel1SetXGetX_cs.txt
                        { e._totalSupply = value; e._state = NeoEntityModel.EntityState.SET; }
 public static Int32 GetDecimals(NPCNEP5Base e) { return e._decimals; }
 public static void SetSymbol(NPCNEP5Base e, string value) // Template: NPCLevel1SetXGetX_cs.txt
                        { e._symbol = value; e._state = NeoEntityModel.EntityState.SET; }
 public static string GetSymbol(NPCNEP5Base e) { return e._symbol; }