0

I call a function with the transaction like this https://ropsten.etherscan.io/tx/0x7d4dec3c0db2b700efae63ef3ffb5a33fc2335bd992fd37c48aa10560eb8156e this fuction is a call from other contract,I wrote it like:

function tokenDeposit(address borrower,uint amount)public BorrowerExist(borrower) payable returns(bool){
      address platform_token=0x98e2F1c551c05447BAe0a753f5b9fE243d8194b6;
      bytes memory deposit_token=abi.encodeWithSignature("transfer_with_approve(address,address,uint256)",borrower,platform,amount);
            platform_token.call(deposit_token);
            return true;
        }

and the platform is :address platform="one of my walletaddress"; the contract 0x98e2F1c551c05447BAe0a753f5b9fE243d8194b6 has been deployed and I have tested the "transfer_with_approve" function in it and it worked ,however when I tried to call that function,I got an internal transaction error :out of gas, but the transaction status returned success .Anyone know what happen to this and can help me solve with this problem, thanks!

0

The contract makes a low-level call to another contract

platform_token.call(deposit_token);
return true;

The call returns a boolean with the result of the operation, true if it succeeded and false otherwise. In this case it is discarded because it is never assigned, so the result of the operation is ignored.

As a security measure EVM reserves some gas before making a call, so if the callee fails the caller has a chance to do something. In this case since it returns immediately and the transaction succeed.

It is recommended to verify the call result. In solc v0.5 it should be something like this.

(bool result, ) = platform_token.call(deposit_token);
require(result, "Call has failed.");
return true;
| improve this answer | |
  • I 've try this but it failed when i try to call this function. it returns out a gas estimation that i can't even send transaction... – Timmy Chien Jul 8 at 4:35
  • @TimmyChien The "out of gas" is a generic message when an error caused the EVM to stop. Any error will cause it to fail, for example a failed revert or assert, access array out of bounds, calling to a non-contract address, etc. – Ismael Jul 8 at 6:16

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.