Been testing Nethereum and attempting to get a basic test class running as per the Nethereum documentation, but having trouble when running the mining command.


  1. Miner.Start was always bringing back "false" to begin with. Then I stumbled on to this question Nethereum 2.0.0-rc5 Miner which mentions that I should try using the pre-release where Web3Geth is the new way to call mining, trying both ways, I am still unable to get a true value to then continue with my test.

    var mineResult = await web3Geth.Miner.Start.SendRequestAsync(6);
    //var mineResult = await web3.Miner.Start.SendRequestAsync(6);

This is my XUnit test class where the issue is happening.

    using System.Threading;
    using System.Threading.Tasks;
    using Nethereum.Geth;
    using Nethereum.Hex.HexTypes;
    using Nethereum.Web3;
    using Xunit;

namespace BasicTurorial
    public class TestClass
        public async Task ShouldBeAbleToDeployAContract()
            var senderAddress = "0x12890d2cce102216644c59daE5baed380d84830c";
            var password = "password";

            var abi = @"[{""constant"":false,""inputs"":[{""name"":""val"",""type"":""int256""}],""name"":""multiply"",""outputs"":[{""name"":""d"",""type"":""int256""}],""payable"":false,""type"":""function""},{""inputs"":[{""name"":""multiplier"",""type"":""int256""}],""payable"":false,""type"":""constructor""}]";
            var byteCode =
            var multiplier = 7;

            var web3 = new Web3();
            var web3Geth = new Web3Geth();

            var unlockAccountResult =
                await web3.Personal.UnlockAccount.SendRequestAsync(senderAddress, password, 120);


            var transactionHash =
                await web3.Eth.DeployContract.SendRequestAsync(abi, byteCode, senderAddress, multiplier);

            var mineResult = await web3Geth.Miner.Start.SendRequestAsync(6);
            //var mineResult = await web3.Miner.Start.SendRequestAsync(6);


            var receipt = await web3.Eth.Transactions.GetTransactionReceipt.SendRequestAsync(transactionHash);

            while (receipt == null)
                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);

Full sourcecode can be found here https://github.com/stradled/NethereumTest

  • I would like to know too, did you find the answer?
    – Richard Fu
    Aug 28, 2018 at 10:00
  • Was a while ago. But don't think I did, just moved on. Sorry
    – stradled
    Aug 29, 2018 at 12:37

1 Answer 1


I happened to stumble upon the same problem and after weeks of trial and error this worked for me:

var web3 = new Nethereum.Geth.Web3Geth("");
var mine = await web3.Miner.Start.SendRequestAsync(6);

NB:// please use the local address and port that applies to you, mine in this case is

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.