1

When you create a transaction calling a function in a smart contract the transaction status is true if it's executed correctly and false if it isn't

When testing in Hyperledger Besu, if a transaction calling a function in a smart contract which doesn't exists (IE: properly encoded tx to a wrong address), the transaction shows as successfully executed.

For example: I successfully deploy a smart contract, I create the smart contract instance with the ABI + address, and make a call to the smart contract like so:

myContract.methods.myMethod(123).call({from: '0xde0B295669a9FD93d5F28D9Ec85E40f4cb697BAe'}, function(error, result){
    ...
});

When I recover the transaction receipt I can verify that the transaction status is true.

But if I send the same transaction to an address where there is nothing deployed, I don't get any logs the function may have, which makes sense because there is nothing deployed there. but I also get transaction status true:

result:  {
  transactionReceipt: {
    blockHash: '0xea2a7a30fcba0359b76d93d1fe4bc9c97216a720d30022b53eb9111fada263ef',
    blockNumber: 22,
    contractAddress: null,
    cumulativeGasUsed: 30424,
    from: '0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1',
    gasUsed: 30424,
    logs: [],
    logsBloom: '0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

Any idea why that happens? Why wouldn't the transaction get rejected?

3
  • Can you reproduce the behaviour in a different client?
    – hrkrshnn
    Feb 13 at 14:21
  • Yes, it happens in all clients Feb 16 at 11:31
  • Seems like it's default protocol behavior and something we have to code around (IE you can't just call a function from another smart contract and assume true or 0 without checking that the contract you expect is deployed there) Feb 16 at 11:37
1

It is a perfectly valid use to use a transaction data field to store messages.

And it is cheaper than using a contract if your data is read only.

2
  • Ok that makes sense, would there be any difference if the transaction got rejected thou? IE: You sent a transaction the destination can't interpret because there is no code that there that can process it so it rejects it and still introduce it into the block Your message would still be stored Feb 16 at 11:36
  • @EnriqueAlcazar It might work but it doesn't make much sense to flag a transaction as failed when it didn't fail. Now, it is too late to change its behavior.
    – Ismael
    Feb 16 at 18:28

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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