'deploy solidity contract with c#
I am developing an application on Ethereum blockchain. I use Solidity for contract and Nethereum c# library to connect to the contract. I am somehow new in Ethereum and it is my first app in blockchain!! I want to deploy my app in one TESTChain first,
I found a private test chain from nethereum website Docs (https://nethereum.readthedocs.io/en/latest/nethereum-smartcontrats-gettingstarted/)
created my simple contract with Remix and got the ByteCode.
- Writing simple connection code to deploy and connect to the contract.
The problem is that The C# code does not reply anything after send request for deploying of contract. here is my code
the contract is created well on remix and in running tab it works
public class DeploymentTest : ContractDeploymentMessage
{
public static string BYTECODE = @"0x....";// removed it because of long string
public DeploymentTest() : base(BYTECODE) { }
}
public async Task ConnectToTest()
{
var url = "https://github.com/Nethereum/TestChains";
var pass = "0xb5b1870957d373ef0eeffecc6e4812c0fd08f554b37b233526acc331bf1544f7";
var acc = new Account(pass);
var chain = new Web3(acc, url);
var deploymentMessage = new DeploymentTest();
var deploymentHandler = chain.Eth.GetContractDeploymentHandler<DeploymentTest>();
// this point just waited and does not return anything
var transactionReceipt = await deploymentHandler.SendRequestAndWaitForReceiptAsync(deploymentMessage);
var contractAddress = transactionReceipt.ContractAddress;
}
Can any one help me, I don't insist in deploying with code, it can be happened by anyway but after deploying I need to connect it and call some functions. Thanks
EDITED
I downloaded the TESTChain network for windows and it works fine, it seems the default port is 8545 for http:localhost. but it still does not connect to chain
var web3test = new Web3(); // also tried new Web3(http://localhost:8545);
var isMining = await web3test.Eth.Mining.IsMining.SendRequestAsync();
var accounts = await web3test.Eth.Accounts.SendRequestAsync();
is that problem with my connection? I disabled my MacAfee firewall completely.
EDITED 2
I changed my machine and it works on my another laptop, I cannot find the problem. I do not know if I just Uninstall the mcaffe will it be ok or not? has anybody any idea about the firewall prolems or other issues?
Solution 1:[1]
I found the problem , it was in my c# code The function which calls the code was on the wait,
Main()
{
TestConnection().wait(); // this is not proper
}
so I changed it to TestConnection(); and it works
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Azzurro94 |