[Ethereum] nethereum – transactions are ignored or disappearing

go-ethereumnethereumsolidity

I'm trying to create a transaction with Nethereum as below but I cant see the result anywhere. I've checked the wallet and queried from custom client.

var proposalsFunction = contract.GetFunction("newProposal");
var transactionOfProposal = await proposalsFunction.SendTransactionAsync( addressFrom,p.Recipient,p.Amount,p.Description,true);

This is the contract method I'm trying to execute. (For some reason it wants bool as the last parameter)

 function newProposal(
    address beneficiary,
    uint etherAmount,
    string JobDescription,
    bytes transactionBytecode
)
    onlyMembers
    returns (uint proposalID)
{
... 
}

This is how it looks in geth primary node. I can see the tx in sub nodes as well. So the tx is there somewhere but what happened?
enter image description here

Best Answer

Your main issue is that you have ran out of gas.

Execution of contracts requires "gas", in this scenario you have not provided enough gas, and all of it has been consumed. Contracts depending on their complexity use different amounts of gas, the gas is calculated per instruction.

A commmon way to validate this is to check if the gas is the same as the gas used

TransactionSource.Gas == TransactionReceipt.GasUsed

If using geth as a client you can examing the stacktrace and find the error, first you can get the debug information:

await Web3.DebugGeth.TraceTransaction.SendRequestAsync(transactionHash,
                    new TraceTransactionOptions {DisableMemory = true, DisableStorage = true, DisableStack = true});        

and then use the following functions to validate this:

    public bool HasError(JObject stack)
    {
        return !string.IsNullOrEmpty(GetError(stack));
    }

    public string GetError(JObject stack)
    {
        var structsLogs = (JArray)stack["structLogs"];
        if (structsLogs.Count > 0)
        {
            var lastCall = structsLogs[structsLogs.Count - 1];
            return lastCall["error"].Value<string>();
        }
        return null;
    }

This helper class is included from RC5. So you can do the following:

web3.DebugGeth.StackErrorChecker.HasError("stacktrace");

You can calculate the gas beforehand by doing something like:

var gas = await multiplyFunction.EstimateGasAsync(69);


Bytes issue, a bool convertor was configured instead of a bytes one, this is fixed from RC5.


Await and slow response, this has nothing to do with using the keyword await. Mainly the transaction is taking a long time, the cause for this might be due to not being fully synchronised. The right nonce needs to be used for the transaction and it might be awaiting (geth) to have this information.

You would not be able to get a receipt without the transactionId, if not await keyword is in place you will be assigning to a variable the Task object.

Related Topic