예제 #1
0
        /// <summary>
        /// Returns HRD balance of given account
        /// </summary>
        /// <param name="account">account to query</param>
        /// <returns></returns>
        public async Task <BigInteger> GetHRDBalance(HoardID account)
        {
            string hrdAddress = await GetHRDAddress();

            if (hrdAddress != null)
            {
                hrdAddress.RemoveHexPrefix();

                HoardTokenContract hrdContract = new HoardTokenContract(web, hrdAddress);
                return(await hrdContract.GetBalanceOf(account));
            }
            return(new BigInteger(0));
        }
예제 #2
0
        /// <summary>
        /// Transfer HRD amount to another account
        /// </summary>
        /// <param name="from">sender profile</param>
        /// <param name="to">receiver address</param>
        /// <param name="amount">amount to send</param>
        /// <returns>true if transfer was successful, false otherwise</returns>
        public async Task <bool> TransferHRD(Profile from, string to, BigInteger amount)
        {
            string hoardTokenAddress = await gameCenter.GetHoardTokenAddressAsync();

            if (hoardTokenAddress != null)
            {
                hoardTokenAddress.RemoveHexPrefix();

                BigInteger hoardTokenAddressInt = BigInteger.Parse(hoardTokenAddress, NumberStyles.AllowHexSpecifier);
                if (!hoardTokenAddressInt.Equals(0))
                {
                    HoardTokenContract hrdContract = new HoardTokenContract(web, hoardTokenAddress);
                    return(await hrdContract.Transfer(from, to, amount));
                }
            }
            throw new HoardException("Cannot get proper Hoard Token contract!");
        }