예제 #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");
        }
예제 #2
0
파일: NEP5.cs 프로젝트: uvmetal/neo-lux
 public NEP5(NeoAPI api, string contractHash)
 {
     this.api          = api;
     this.contractHash = contractHash;
 }