Created
November 11, 2019 21:42
-
-
Save anegg0/e450ffea73ba615185d4e286c1b112d9 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uusing Nethereum.Web3; | |
using System; | |
using Nethereum; | |
using Nethereum.Web3; | |
using System.Threading; | |
using System.Threading.Tasks; | |
using Nethereum.Web3.Accounts; | |
using Nethereum.Web3.Accounts.Managed; | |
public class LogProcessing_WithInDepthConfiguration | |
{ | |
public static async Task Main(string[] args) | |
{ | |
var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c"; | |
var password = "password"; | |
var account = new ManagedAccount(senderAddress, password); | |
var web3 = new Web3(account, "http://testchain.nethereum.com:8545"); | |
var abi = @"[{""constant"":false,""inputs"":[{""name"":""val"",""type"":""int256""}],""name"":""multiply"",""outputs"":[{""name"":""d"",""type"":""int256""}],""type"":""function""},{""inputs"":[{""name"":""multiplier"",""type"":""int256""}],""type"":""constructor""}]"; | |
var byteCode = | |
"0x60606040526040516020806052833950608060405251600081905550602b8060276000396000f3606060405260e060020a60003504631df4f1448114601a575b005b600054600435026060908152602090f3"; | |
var multiplier = 7; | |
var transactionHash = | |
await web3.Eth.DeployContract.SendRequestAsync(abi, byteCode, senderAddress, multiplier); | |
var receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash); | |
while (receipt == null) | |
{ | |
Thread.Sleep(5000); | |
receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash); | |
} | |
var contractAddress = receipt.ContractAddress; | |
var contract = web3.Eth.GetContract(abi, contractAddress); | |
var multiplyFunction = contract.GetFunction("multiply"); | |
var result = await multiplyFunction.CallAsync<int>(7); | |
// Assert.Equal(49, result); | |
var receipt2 = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash); | |
while (receipt == null) | |
{ | |
Thread.Sleep(5000); | |
receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash); | |
} | |
var contractAddress2 = receipt.ContractAddress; | |
var contract2 = web3.Eth.GetContract(abi, contractAddress); | |
var result2 = await multiplyFunction.CallAsync<int>(7); | |
//Assert.Equal(49, result); | |
}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment