1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- @page "/blockchains"
- <h1>Blockchain</h1>
- <p>
- @namespace HyperCube.Models
- @code
- {
- string hidecontr = "hidden";
- string hidereceipt = "hidden";
- string result = "";
- }
- @if (Blockchain.newData)
- {
- @foreach (var bc in Blockchain.loaded)
- {
- <p><b>@bc.url:@bc.port</b>, address: @bc.address</p>
- }
- @bytecode;
- }
- </p>
- <h4>Ethereum dev network</h4>
- <p>
- Add blockchain connection:
- <input name="bcurl" @bind="bcURL" type="text" placeholder="URL" @bind:event="oninput">
- <input name="bport" @bind="bcport" type="number" placeholder="port">
- <button @onclick="GetBlockChain">Connect</button>
- </p>
- <p style="visibility:@hidecontr">
- Add smart contract:
- <button @onclick="AddContract">Add</button>
- <input id="bytecode" size="100" @bind="bytecode" name="bytecode" type="text" placeholder="Smart contract bytecode" @bind:event="oninput">
- <br />
- </p>
- <p style="visibility:@hidereceipt">
- Get smart contract address:
- <button @onclick="AddContract">Add</button>
- <input id="bytecode" size="100" @bind="bytecode" name="bytecode" type="text" placeholder="Smart contract bytecode" @bind:event="oninput">
- <br />
- </p>
- <p>@result</p>
- @code
- {
- private Random r = new Random();
- private string bcURL = "127.0.0.1";
- private int bcport = 8545;
- private string bytecode = "";
- private string error = "";
- private async Task GetReceipt()
- {
- //TODO result as transaction addr
- result = await Blockchain.loaded[0].GetReceipt(result);
- }
- private async Task AddContract()
- {
- if (Blockchain.loaded.Count > 0)
- {
- result = await Blockchain.loaded[0].AddContract(bytecode);
- }
- //private Post post = new Post();
- }
- private async Task GetBlockChain()
- {
- 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();
- }
- }
|