I am running a private Ethereum blockchain server on my local machine. I set up the genesis file, created some nodes, and created a contract in Solidity. The aim to get a running blockchain with smart contracts on a private network. Since we develop on the .NET framework, we want to use Nethereum to interact with the blockchain.
The blockchain sets up fine, the nodes set up fine on the blockchain, and I can use Nethereum to interact with the nodes and query them. However, whenever I try make any transaction, it fails with the error message "One or more errors occurred. (invalid sender: eth_sendRawTransaction)". Regardless if this is just sending Ether or deploying a contract.
My genesis file is as follows: { "config": { "chainId": 1515, "homesteadBlock": 0, "eip150Block": 0, "eip150Hash": "0x0000000000000000000000000000000000000000000000000000000000000000", "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0, "constantinopleBlock": 0, "petersburgBlock": 0, "istanbulBlock": 0, "clique": { "period": 0, "epoch": 30000 } }, "nonce": "0x0", "timestamp": "0x0", "extraData": "0x000000000000000000000000000000000000000000000000000000000000000039FBa5910Ecd5A3AbB81493F898bFecf7046a9E20000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000", "gasLimit": "0x47b760", "difficulty": "0x1", "mixHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "coinbase": "0x3333333333333333333333333333333333333333", "alloc": { "0x39FBa5910Ecd5A3AbB81493F898bFecf7046a9E2": { "balance": "0x999999999" }, "0x321A928649C3338d1F6804fEdFa57eB52BEDa077": { "balance": "0x999999999" }, "0x7f3FdA43e7b57628107C7c76A13141FA8684fAd3": { "balance": "0x999999999" } }, "number": "0x0", "gasUsed": "0x0", "parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000", "baseFeePerGas": null }
I start the nodes as follows: geth --nousb --datadir=node1/ --networkid 1515 --syncmode full --port 30310 --miner.gasprice 0 --miner.gastarget 470000000000 --http --http.addr localhost --http.port 8545 --http.api admin,eth,miner,net,txpool,personal,web3 --mine --allow-insecure-unlock --unlock "0x39FBa5910Ecd5A3AbB81493F898bFecf7046a9E2" --password node1/password.txt
Note that the network ID does match the chain ID and is specified in both places.
The C# code to use Nethereum to make a transaction looks like this:
var accountFilePath = @"<path-to-keystore>\keystore\UTC--2021-09-12T23-49-11.299662900Z--39fba5910ecd5a3abb81493f898bfecf7046a9e2";
var account = Account.LoadFromKeyStore(File.ReadAllText(accountFilePath), password, 1515);
var web3 = new Web3(account, "http://127.0.0.1:8545");
var unlock = web3.Personal.UnlockAccount.SendRequestAsync(account.Address, password, 120);
while (!unlock.IsCompleted) { }
var send = web3.TransactionManager.SendTransactionAsync(account.Address, "0x321A928649C3338d1F6804fEdFa57eB52BEDa077", new HexBigInteger(20));
while (!send.IsCompleted) { }
string senderAddress = account.Address;
var estimateGas = web3.Eth.DeployContract.EstimateGasAsync(abi, contractByteCode, senderAddress);
while (!estimateGas.IsCompleted) { }
var deployReceipt = web3.Eth.DeployContract.SendRequestAndWaitForReceiptAsync(abi, contractByteCode, senderAddress, estimateGas.Result, null);
while (!deployReceipt.IsCompleted) { }
To the best of my knowledge, this should send Ether from node 1 to node2 and then deploy a contract. However, neither transaction succeeds. I have ensured that my chain ID and network ID are the same, Nethereum unlocks the accounts and signs the transactions, so that should not be an issue. I did try manually unlocking the accounts just in case, but that made no difference. I've checked, and the transaction has the correct chain ID and sender address.
I've been working on this for a few days now, and I'm no closer to finding a solution. Any help is appreciated.