示例#1
0
        /// <summary>
        /// update the balance of an address
        /// </summary>
        /// <param name="address"></param>
        /// <param name="newBalance"></param>
        public static void SetBalanceOf(byte[] address, BigInteger newBalance)
        {
            if (address.Length != 20)
            {
                Runtime.Log("SetBalanceOf() address.length != 20");
                return;
            }

            StorageMap balances = Storage.CurrentContext.CreateMap(StorageKeys.BalancePrefix());

            if (newBalance <= 0)
            {
                balances.Delete(address);
            }
            else
            {
                Runtime.Notify("SetBalanceOf() setting balance", newBalance);
                balances.Put(address, newBalance);
            }
        }
示例#2
0
文件: NEP5.cs 项目: Eluvade/DIVE
        public static BigInteger BalanceOf(byte[] account)
        {
            if (account.Length != 20)
            {
                Runtime.Log("BalanceOf() invalid address supplied");
                return(0);
            }

            StorageMap balances = Storage.CurrentContext.CreateMap(StorageKeys.BalancePrefix());

            BigInteger amountSubjectToVesting = TokenSale.SubjectToVestingPeriod(account);
            BigInteger userBalance            = balances.Get(account).AsBigInteger() - amountSubjectToVesting;

            if (userBalance < 0)
            {
                userBalance = 0;
            }

            return(userBalance.AsByteArray().Concat(new byte[] { }).AsBigInteger());
        }