Esempio n. 1
0
        // FIXME - I'm almost sure that this code won't return non-integer balances correctly...
        public static decimal GetTokenBalance(string address, string symbol)
        {
            var info = GetTokenInfo();

            if (info.ContainsKey(symbol))
            {
                var token    = info[symbol];
                var response = NeoAPI.TestInvokeScript(NeoAPI.Net.Main, token.scriptHash, "balanceOf", new object[] { address.GetScriptHashFromAddress() });
                var balance  = new BigInteger((byte[])response.result);
                var decimals = token.decimals;
                while (decimals > 0)
                {
                    balance /= 10;
                    decimals--;
                }
                return((decimal)balance);
            }

            throw new NeoException("Invalid token symbol");
        }
Esempio n. 2
0
 public NEP5(NeoAPI api, string contractHash)
 {
     this.api          = api;
     this.contractHash = contractHash;
 }