public async Task ProdContract() { var account = "0x12890d2cce102216644c59daE5baed380d84830c"; var pass = "******"; var byteCode = "606060405260405161069d38038061069d833981016040528080518201919060200150505b33600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055508060036000509080519060200190828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f1061009e57805160ff19168380011785556100cf565b828001600101855582156100cf579182015b828111156100ce5782518260005055916020019190600101906100b0565b5b5090506100fa91906100dc565b808211156100f657600081815060009055506001016100dc565b5090565b50505b506105918061010c6000396000f360606040526000357c0100000000000000000000000000000000000000000000000000000000900480632d202d24146100685780634ba200501461009b578063893d20e81461011b578063a0e67e2b14610159578063d5d1e770146101b557610063565b610002565b346100025761008360048080359060200190919050506101df565b60405180821515815260200191505060405180910390f35b34610002576100ad600480505061027a565b60405180806020018281038252838181518152602001915080519060200190808383829060006004602084601f0104600302600f01f150905090810190601f16801561010d5780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b346100025761012d6004805050610336565b604051808273ffffffffffffffffffffffffffffffffffffffff16815260200191505060405180910390f35b346100025761016b6004805050610365565b60405180806020018281038252838181518152602001915080519060200190602002808383829060006004602084601f0104600302600f01f1509050019250505060405180910390f35b34610002576101c760048050506103f7565b60405180821515815260200191505060405180910390f35b60003373ffffffffffffffffffffffffffffffffffffffff16600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff161415156102415760009050610275565b81600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff0219169083021790555060019050610275565b919050565b602060405190810160405280600081526020015060036000508054600181600116156101000203166002900480601f0160208091040260200160405190810160405280929190818152602001828054600181600116156101000203166002900480156103275780601f106102fc57610100808354040283529160200191610327565b820191906000526020600020905b81548152906001019060200180831161030a57829003601f168201915b50505050509050610333565b90565b6000600160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff169050610362565b90565b602060405190810160405280600081526020015060006000508054806020026020016040519081016040528092919081815260200182805480156103e857602002820191906000526020600020905b8160009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16815260200190600101908083116103b4575b505050505090506103f4565b90565b60003373ffffffffffffffffffffffffffffffffffffffff16600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff16141515610459576000905061058e565b600060005080548060010182818154818355818115116104ab578183600052602060002091820191016104aa919061048c565b808211156104a6576000818150600090555060010161048c565b5090565b5b5050509190906000526020600020900160005b600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16909190916101000a81548173ffffffffffffffffffffffffffffffffffffffff0219169083021790555050600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff16600160006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055506000600260006101000a81548173ffffffffffffffffffffffffffffffffffffffff021916908302179055506001905061058e565b9056"; var abi = @"[{""constant"":false,""inputs"":[{""name"":""nextOwner"",""type"":""address""}],""name"":""setNextOwner"",""outputs"":[{""name"":""set"",""type"":""bool""}],""payable"":false,""type"":""function""},{""constant"":true,""inputs"":[],""name"":""getProduct"",""outputs"":[{""name"":""product"",""type"":""string""}],""payable"":false,""type"":""function""},{""constant"":true,""inputs"":[],""name"":""getOwner"",""outputs"":[{""name"":""owner"",""type"":""address""}],""payable"":false,""type"":""function""},{""constant"":true,""inputs"":[],""name"":""getOwners"",""outputs"":[{""name"":""owners"",""type"":""address[]""}],""payable"":false,""type"":""function""},{""constant"":false,""inputs"":[],""name"":""confirmOwnership"",""outputs"":[{""name"":""confirmed"",""type"":""bool""}],""payable"":false,""type"":""function""},{""inputs"":[{""name"":""productDigest"",""type"":""string""}],""type"":""constructor""}]"; var w3 = new Web3(); // var accUnlocked = await w3.Personal.UnlockAccount.SendRequestAsync(account, pass, new HexBigInteger(1000)); //issue ran out of gas (putting 900 * 1000 instead of 200 * 1000 fixes this) var contractHash = await w3.Eth.DeployContract.SignAndSendRequestAsync(pass, abi, byteCode, account, new HexBigInteger(900 * 1000), "My product"); var minerResult = await w3.Miner.Start.SendRequestAsync(); var receipt = await w3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(contractHash); while (receipt == null) { await Task.Delay(1000); receipt = await w3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(contractHash); } await w3.Miner.Stop.SendRequestAsync(); var contract = w3.Eth.GetContract(abi, receipt.ContractAddress); var code = await w3.Eth.GetCode.SendRequestAsync(receipt.ContractAddress); Assert.True(!string.IsNullOrEmpty(code) && code.Length > 3); var function = contract.GetFunction("getProduct"); var result = await function.CallAsync<string>(); Assert.Equal("My product", result); }
public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, BaseUpgradeabilityProxyDeployment baseUpgradeabilityProxyDeployment, CancellationTokenSource cancellationTokenSource = null) { return(web3.Eth.GetContractDeploymentHandler <BaseUpgradeabilityProxyDeployment>().SendRequestAndWaitForReceiptAsync(baseUpgradeabilityProxyDeployment, cancellationTokenSource)); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, WalletSellerDeployment walletSellerDeployment) { return(web3.Eth.GetContractDeploymentHandler <WalletSellerDeployment>().SendRequestAsync(walletSellerDeployment)); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, MockDaiDeployment mockDaiDeployment) { return(web3.Eth.GetContractDeploymentHandler <MockDaiDeployment>().SendRequestAsync(mockDaiDeployment)); }
public ReverseRegistrarService(Nethereum.Web3.Web3 web3, string contractAddress) { Web3 = web3; ContractHandler = web3.Eth.GetContractHandler(contractAddress); }
public BlockRewardHbbftCoinsService(Nethereum.Web3.Web3 web3, string contractAddress) { Web3 = web3; ContractHandler = web3.Eth.GetContractHandler(contractAddress); }
public PublicResolverService(Web3.Web3 web3, string address) { this.web3 = web3; this.contract = web3.Eth.GetContract(ABI, address); }
public BaseUpgradeabilityProxyService(Nethereum.Web3.Web3 web3, string contractAddress) { Web3 = web3; ContractHandler = web3.Eth.GetContractHandler(contractAddress); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, IStakingHbbftDeployment iStakingHbbftDeployment) { return(web3.Eth.GetContractDeploymentHandler <IStakingHbbftDeployment>().SendRequestAsync(iStakingHbbftDeployment)); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, FactoryDeployment factoryDeployment) { return(web3.Eth.GetContractDeploymentHandler <FactoryDeployment>().SendRequestAsync(factoryDeployment)); }
public L2CrossDomainMessengerService(Nethereum.Web3.Web3 web3, string contractAddress) { Web3 = web3; ContractHandler = web3.Eth.GetContractHandler(contractAddress); }
public static async Task <L2CrossDomainMessengerService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, L2CrossDomainMessengerDeployment l2CrossDomainMessengerDeployment, CancellationTokenSource cancellationTokenSource = null) { var receipt = await DeployContractAndWaitForReceiptAsync(web3, l2CrossDomainMessengerDeployment, cancellationTokenSource); return(new L2CrossDomainMessengerService(web3, receipt.ContractAddress)); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, L2CrossDomainMessengerDeployment l2CrossDomainMessengerDeployment) { return(web3.Eth.GetContractDeploymentHandler <L2CrossDomainMessengerDeployment>().SendRequestAsync(l2CrossDomainMessengerDeployment)); }
public static Task <TransactionReceipt> DeployContractAndWaitForReceiptAsync(Nethereum.Web3.Web3 web3, L2CrossDomainMessengerDeployment l2CrossDomainMessengerDeployment, CancellationTokenSource cancellationTokenSource = null) { return(web3.Eth.GetContractDeploymentHandler <L2CrossDomainMessengerDeployment>().SendRequestAndWaitForReceiptAsync(l2CrossDomainMessengerDeployment, cancellationTokenSource)); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, BaseUpgradeabilityProxyDeployment baseUpgradeabilityProxyDeployment) { return(web3.Eth.GetContractDeploymentHandler <BaseUpgradeabilityProxyDeployment>().SendRequestAsync(baseUpgradeabilityProxyDeployment)); }
public static async Task <BaseUpgradeabilityProxyService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, BaseUpgradeabilityProxyDeployment baseUpgradeabilityProxyDeployment, CancellationTokenSource cancellationTokenSource = null) { var receipt = await DeployContractAndWaitForReceiptAsync(web3, baseUpgradeabilityProxyDeployment, cancellationTokenSource); return(new BaseUpgradeabilityProxyService(web3, receipt.ContractAddress)); }
public async Task <IHttpActionResult> withdraw(txencrypted txdetails) { if (StkHelper.checkTxHash(txdetails)) { thashdetails thashresp = new thashdetails(); var txHash = ""; var context = new stakingapiEntities(); var keys = context.stk_admin.FirstOrDefault(); AdminKeys keystosend = new AdminKeys { }; var metamaskdetails = context.stk_users.Where(x => x.metamask == txdetails.metamask).FirstOrDefault(); if (metamaskdetails == null) { return(BadRequest("Invalid Wallet address")); } var account = new Account(keys.private_key); var web3 = new Nethereum.Web3.Web3(account, "https://mainnet.infura.io/v3/14063be7fce843b18bfbd7beae73caca"); try { string apiUrl = "https://api.etherscan.io/api?module=account&action=txlist&address=0xfE276a83012Ff9C199109137BBCe864a225cefE9&startblock=" + txdetails.blockNumber.BN + "&endblock=" + txdetails.blockNumber.BN + "&sort=asc&apikey=98RSH7SEW3Z77D683QTJCU5M447IRD7S6I"; using (HttpClient client = new HttpClient()) { client.BaseAddress = new Uri(apiUrl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); HttpResponseMessage response = await client.GetAsync(apiUrl); if (response.IsSuccessStatusCode) { var data = await response.Content.ReadAsStringAsync(); thashresp = Newtonsoft.Json.JsonConvert.DeserializeObject <thashdetails>(data); } } if (thashresp != null) { //System.DateTime txTimestamp = new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc); //txTimestamp = txTimestamp.AddSeconds(Convert.ToDouble(thashresp.result[0].timeStamp)).ToUniversalTime(); //if (thashresp.result[0].from == txdetails.metamask.ToLower() && thashresp.result[0].to == keys.stkcontractAddress && thashresp.result[0].value == txdetails.transactionFee.Transactionfee /*&& txTimestamp.AddMinutes(30) >= DateTime.UtcNow*/) //{ var receiverAddress = txdetails.metamask; var transferHandler = web3.Eth.GetContractTransactionHandler <TransferFunction>(); var transfer = new TransferFunction() { To = receiverAddress, TokenAmount = Web3.Convert.ToWei((BigDecimal)metamaskdetails.total_reward), GasPrice = Nethereum.Web3.Web3.Convert.ToWei(txdetails.gasPrice.GasPrice, UnitConversion.EthUnit.Gwei), Gas = txdetails.gasLimit.GasLimit }; var transactionReceipt = await transferHandler.SendRequestAndWaitForReceiptAsync(keys.zinTokenAddress, transfer); txHash = transactionReceipt.TransactionHash; using (DbContextTransaction dbTran = context.Database.BeginTransaction()) { try { keystosend.rewards = metamaskdetails.total_reward; metamaskdetails.zin_in_wallet = metamaskdetails.zin_in_wallet + metamaskdetails.total_reward; metamaskdetails.total_reward = 0; context.SaveChanges(); dbTran.Commit(); } catch (Exception ex) { dbTran.Rollback(); return(BadRequest(ex.Message)); } } //} } return(Json(new { status = 200, message = "success", result = txHash })); } catch (Exception Ex) { var message = Ex.Message; return(BadRequest(Ex.InnerException.Message)); } //return Json(new { status = 200, message = "success", result = "Ok" }); } else { return(BadRequest("Transaction details does not match with the blockchain provider")); } }
public static Task<string> DeployContractAsync(Web3.Web3 web3, string addressFrom, string ensAddr, HexBigInteger gas = null, HexBigInteger valueAmount = null) { return web3.Eth.DeployContract.SendRequestAsync(ABI, BYTE_CODE, addressFrom, gas, valueAmount , ensAddr); }
public static Task <string> DeployContractAsync(Nethereum.Web3.Web3 web3, ReverseRegistrarDeployment reverseRegistrarDeployment) { return(web3.Eth.GetContractDeploymentHandler <ReverseRegistrarDeployment>().SendRequestAsync(reverseRegistrarDeployment)); }
public static async Task <ReverseRegistrarService> DeployContractAndGetServiceAsync(Nethereum.Web3.Web3 web3, ReverseRegistrarDeployment reverseRegistrarDeployment, CancellationTokenSource cancellationTokenSource = null) { var receipt = await DeployContractAndWaitForReceiptAsync(web3, reverseRegistrarDeployment, cancellationTokenSource); return(new ReverseRegistrarService(web3, receipt.ContractAddress)); }
public DaoService(Web3.Web3 web3, string address) { this.web3 = web3; this.contract = web3.Eth.GetContract(abi, address); }