|
@@ -26,6 +26,27 @@ namespace HyperCube.Models
|
|
|
this.port = port;
|
|
|
}
|
|
|
|
|
|
+ public static string bin2hex(string code)
|
|
|
+ {
|
|
|
+ //code = "0x".bin2hex('getCount()');
|
|
|
+ var bytes = Encoding.UTF8.GetBytes(code);
|
|
|
+ var hex = BitConverter.ToString(bytes).Replace("-", "");
|
|
|
+ Console.WriteLine("hex " + hex);
|
|
|
+ return "0x"+hex;
|
|
|
+ }
|
|
|
+
|
|
|
+ public async Task<string> GetSHA3(string code)
|
|
|
+ {
|
|
|
+ var hex = bin2hex(code);
|
|
|
+ var req = $"{{ \"jsonrpc\":\"2.0\",\"method\":\"web3_sha3\",\"params\":[\"{hex}\"], \"id\":1}}";
|
|
|
+
|
|
|
+ var answer = await Post.PostRequestAsync(req);
|
|
|
+ //dynamic jsonDe = JsonConvert.DeserializeObject(answer);
|
|
|
+
|
|
|
+ Console.WriteLine("result " + answer);
|
|
|
+ return answer;
|
|
|
+ }
|
|
|
+
|
|
|
public async Task<string> RunContract(string contractAddress, string data)
|
|
|
{
|
|
|
Console.WriteLine("RunContract contractAddress " + contractAddress);
|