|
@@ -1,4 +1,5 @@
|
|
|
using System;
|
|
|
+using System.Text;
|
|
|
using System.Collections.Generic;
|
|
|
using System.Linq;
|
|
|
using System.Threading.Tasks;
|
|
@@ -25,6 +26,15 @@ namespace HyperCube.Models
|
|
|
ListAccounts();
|
|
|
if (!loaded.Contains(this))
|
|
|
loaded.Add(this);
|
|
|
+ Console.WriteLine("loaded blockchains " + loaded.Count);
|
|
|
+ }
|
|
|
+
|
|
|
+ public async void AddContract(string bytecode)
|
|
|
+ {
|
|
|
+ var req = $"{{ \"jsonrpc\":\"2.0\",\"method\":\"eth_sendTransaction\",\"params\":[{{\"from\":\"0x4Ce13B6012ad8AB5Bf2E364679173D81C28Cd8d4\",\"gas\":\"0x31b2e\", \"data\":\"{bytecode}\"}}], \"id\":1}}";
|
|
|
+
|
|
|
+ var res = await Post.PostRequestAsync(req);
|
|
|
+ Console.WriteLine("result "+ res);
|
|
|
}
|
|
|
|
|
|
public async void ListAccounts()
|
|
@@ -33,8 +43,18 @@ namespace HyperCube.Models
|
|
|
//{ "jsonrpc":"2.0","method":"eth_getCode","params":["0x938cae6f6c21ed9d55196e96ef880f562e530553", "latest" ],"id":1}
|
|
|
//string req = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_getCode\",\"params\":[\"0x874c6a51e62680d4594cd2555ed8fa47b63ed253\",\"latest\"],\"id\":1}";
|
|
|
string req = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_accounts\", \"params\":[],\"id\":1}";
|
|
|
- await Post.PostRequestAsync(req, answer);
|
|
|
- address = answer;
|
|
|
+
|
|
|
+ answer = await Post.PostRequestAsync(req);
|
|
|
+
|
|
|
+
|
|
|
+ //string json = Encoding.UTF8.GetString(bytedata, 1, bytedata.Length - 1);
|
|
|
+ //try
|
|
|
+ //{
|
|
|
+ Console.WriteLine("Json string " + answer);
|
|
|
+ dynamic jsonDe = JsonConvert.DeserializeObject(answer);
|
|
|
+ address = jsonDe.result[0];
|
|
|
+ Console.WriteLine("Json addr " + jsonDe.result[0]);
|
|
|
+ var methodName = (string)jsonDe.name;
|
|
|
}
|
|
|
|
|
|
public async void ExecuteContract()
|
|
@@ -43,7 +63,7 @@ namespace HyperCube.Models
|
|
|
string req = "{\"jsonrpc\":\"2.0\",\"method\":\"eth_call\",\"params\":[{\"to\":\"0x874c6a51e62680d4594cd2555ed8fa47b63ed253\", \"data\":\"0xa87d942c\"},\"latest\"],\"id\":1}";
|
|
|
//string req = "{\"jsonrpc\":\"2.0\",\"id\":1,\"result\":\"0x0000000000000000000000000000000000000000000000000000000000000004\"}";
|
|
|
//Console.WriteLine($"req " + req);
|
|
|
- await Post.PostRequestAsync(req, answer);
|
|
|
+ await Post.PostRequestAsync(req);
|
|
|
//Console.WriteLine($"answer {answer} len {answer.Length}" );
|
|
|
address = answer;
|
|
|
}
|