@page "/blockchains"
@namespace HyperCube.Models @code { string hidecontr = "hidden"; string hidereceipt = "hidden"; string result = ""; } @if (Blockchain.newData) { @foreach (var bc in Blockchain.loaded) {
@bc.url:@bc.port , address: @bc.address
} @bytecode; }Add blockchain connection:
@*Add smart contract:
0x60806040526000805534801561001457600080fd5b50610101806100246000396000f3006080604052600436106053576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680635b34b966146058578063a87d942c14606c578063f5c5ad83146094575b600080fd5b348015606357600080fd5b50606a60a8565b005b348015607757600080fd5b50607e60ba565b6040518082815260200191505060405180910390f35b348015609f57600080fd5b5060a660c3565b005b60016000808282540192505081905550565b60008054905090565b600160008082825403925050819055505600a165627a7a723058207815571f5c1d82bff3c0512a4cbc7a1f1c2063fa9a0de61913b76925f041e9ed0029
Get smart contract address:
@Blockchain.newData
@result
@code { private Random r = new Random(); private string bcURL = "127.0.0.1"; private int bcport = 8545; private string bytecode = ""; private string error = ""; string lastTransAddr = ""; string contractAddress = ""; private async Task RunContract() { //TODO result as transaction addr //result = await Blockchain.loaded[0].GetReceipt(result); } private async Task AddContract() { if (Blockchain.loaded.Count > 0) { var taddr = await Blockchain.loaded[0].AddContract(bytecode); if (taddr != "") { result = taddr; //hidereceipt = "visible"; var caddr = await Blockchain.loaded[0].GetReceipt(result); if (caddr != "") { result = "contractAddress: "+caddr; contractAddress = caddr; var run = await Blockchain.loaded[0].RunContractWrite(contractAddress, "0x11111111"); result = "run: " + run; } } } //private Post post = new Post(); } private async Task GetBlockChain() { var b2h = Blockchain.bin2hex("getCount()"); Console.WriteLine("bin2hex "+b2h); //if (Blockchain.loaded.Count == 0) //{ Blockchain bc = new HyperCube.Models.Blockchain(bcURL, bcport); result = await bc.Initialize(); if (result != "") hidecontr = "visible"; //bcURL = bc.GetAddress(); //bc.ExecuteContract(); //bcURL = bc.address; //hidecontr = "hidden"; //} //private Post post = new Post(); } }