public async Task <MusResult> GetBalance(string address) { var req = new MusRequest("GetBalance", address); var result = await CallMethod(req); return(ResponseHandler.GetResult(ref result)); }
public async Task <MusResult> GetContractBalance(string address) { var req = new MusRequest("GetSmartContractState", address.TrimStart('0').TrimStart('x')); var result = await CallMethod(req); return(ResponseHandler.GetContractBalance(ref result)); }
/// <summary> /// Calls a API method of the Zilliqa API /// </summary> /// <param name="req">MusRequest object to pass request</param> /// <returns></returns> private async Task <APIResponse> CallMethod(MusRequest req) { string result = ""; var json = req.ToJson(); var data = new StringContent(json, Encoding.UTF8, "application/json"); using (var httpClient = GetClient()) { var response = await httpClient.PostAsync(Url, data); result = response.Content.ReadAsStringAsync().Result; } var musres = JsonConvert.DeserializeObject <APIResponse>(result); return(musres); }