Пример #1
0
        /// <summary>
        /// retreive the balance of an address showing contribution during token sale
        /// </summary>
        /// <param name="account">address to check balance of</param>
        /// <returns>number of tokens</returns>
        public static BigInteger BalanceOfSaleContribution(byte[] account)
        {
            if (account.Length != 20)
            {
                Runtime.Log("BalanceOfSaleContribution() invalid address supplied");
                return(0);
            }

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

            return(balances.Get(account).AsBigInteger());
        }
Пример #2
0
        /// <summary>
        /// update the balance of an address - used to ensure maxContribution isn't exceeded
        /// </summary>
        /// <param name="address"></param>
        /// <param name="newBalance"></param>
        public static void SetBalanceOfSaleContribution(byte[] address, BigInteger newBalance)
        {
            if (address.Length != 20)
            {
                Runtime.Log("SetBalanceOfSaleContribution() address.length != 20");
                return;
            }

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

            if (newBalance <= 0)
            {
                balances.Delete(address);
            }
            else
            {
                Runtime.Notify("SetBalanceOfSaleContribution() setting balance", newBalance);
                balances.Put(address, newBalance);
            }
        }