Example #1
0
        /// <summary>
        /// get node time
        /// method: web4b_getTime
        /// params: none
        /// result: node unix time in milliseconds ( UTC )
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public async Task <(long unixtime, string error)> GetTimeAsync(int id = 0)
        {
            (JsonRpc response, string error) = await PostAsync(new JsonRpc.Request(web4b_getTime, id));

            if (ReferenceEquals(response, null))
            {
                return(0, error);
            }

            try
            {
                return(response.HasError ? (0, response.ErrorMessage) : (Hex.ToNumber <long>(response.Result <string>(0)), string.Empty));
            }
            catch (Exception ex)
            {
                return(0, ex.Message);
            }
        }