public static BigInteger balanceOf(byte[] account)
        {
            BigInteger balance = (BigInteger)0;

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

            NPCNEP5LedgerEntry accountLedgerEntry = NPCNEP5LedgerEntry.Get(account);

            if (NeoTrace.VERBOSE)
            {
                NPCNEP5LedgerEntry.Log("balanceOf().ledgerEntry", accountLedgerEntry);
            }
            if (!NPCNEP5LedgerEntry.IsMissing(accountLedgerEntry))
            {
                if (NeoTrace.VERBOSE)
                {
                    NeoTrace.Trace("accountLedgerEntry is not Missing");
                }
                balance = NPCNEP5LedgerEntry.GetBalance(accountLedgerEntry);
            }

            return(balance);
        }
        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 bool transfer(byte[] from, byte[] to, BigInteger amount)
        {
            bool result = false;

            if (NeoTrace.VERBOSE)
            {
                NeoTrace.Trace("transfer():entered", from, to, amount);
            }

            // https://github.com/neo-project/examples-csharp/blob/master/ICO_Template/ICO_Template.cs#L146

            if (amount > 0)
            {
                if (NeoTrace.VERBOSE)
                {
                    NeoTrace.Trace("transfer():amount > 0");
                }
                //if (Neo.SmartContract.Framework.Services.Neo.Runtime.CheckWitness(from))
                {
                    if (from == to)
                    {
                        if (NeoTrace.VERBOSE)
                        {
                            NeoTrace.Trace("transfer():from == to");
                        }
                        result = true;
                    }
                    else
                    {
                        if (NeoTrace.VERBOSE)
                        {
                            NeoTrace.Trace("transfer():from != to");
                        }
                        NPCNEP5LedgerEntry fromLedgerEntry = NPCNEP5LedgerEntry.Get(from);
                        if (NeoTrace.VERBOSE)
                        {
                            NPCNEP5LedgerEntry.Log("transfer().fromLedgerEntry", fromLedgerEntry);
                        }
                        BigInteger fromBalance = NPCNEP5LedgerEntry.GetBalance(fromLedgerEntry);
                        if (fromBalance >= amount)
                        {
                            if (NeoTrace.VERBOSE)
                            {
                                NeoTrace.Trace("transfer():fromBalance >= amount");
                            }
                            //NPCEnvironment env = NPCEnvironment.New();
                            //NPCEnvironment.Initialize(env);
                            //BigInteger timestamp = NPCEnvironment.GetBlockTimestamp(env);

                            //uint h = Blockchain.GetHeight();
                            //Header header = Blockchain.GetHeader(h);
                            //BigInteger timestamp = header.Timestamp;
                            //Block block = Blockchain.GetBlock(h); // NEO Debugger: not implemented
                            //BigInteger timestamp = block.Timestamp;

                            BigInteger timestamp = 0;

                            NPCNEP5LedgerEntry.Set(fromLedgerEntry, timestamp, 0 - amount, fromBalance - amount);
                            NPCNEP5LedgerEntry.Put(fromLedgerEntry, from);
                            if (NeoTrace.VERBOSE)
                            {
                                NPCNEP5LedgerEntry.Log("transfer().fromLedgerEntry", fromLedgerEntry);
                            }

                            NPCNEP5LedgerEntry toLedgerEntry = NPCNEP5LedgerEntry.Get(to);
                            if (NeoTrace.VERBOSE)
                            {
                                NPCNEP5LedgerEntry.Log("transfer().toLedgerEntry", toLedgerEntry);
                            }
                            BigInteger toBalance = NPCNEP5LedgerEntry.GetBalance(toLedgerEntry);

                            NPCNEP5LedgerEntry.Set(toLedgerEntry, timestamp, 0 + amount, toBalance + amount);
                            NPCNEP5LedgerEntry.Put(toLedgerEntry, to);
                            if (NeoTrace.VERBOSE)
                            {
                                NPCNEP5LedgerEntry.Log("transfer().toLedgerEntry", toLedgerEntry);
                            }

                            Transfer(from, to, amount);
                            result = true;
                        }
                    }
                }
            }

            return(result);
        }