0

I am doing the static analysis of the following smart contract (SC) on Remix:

pragma solidity 0.5.1;
contract TxUserWallet {
    address owner;
    constructor() public {
        owner = msg.sender;
    }
    function transferTo(address payable dest, uint amount) public {
        require(tx.origin == owner);
        dest.transfer(amount);
    }
}

I am getting the message Gas Cost. Somebody please guide me, why I am getting the Gas Cost message? The message is shown below:

Gas costs: Gas requirement of function TxUserWallet.transferTo is infinite: If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid loops in your functions or actions that modify large areas of storage (this includes clearing or copying arrays in storage) Pos: 8:4:

1
  • 1
    It's probably a bug. The transfer forwards only 2300 gas, so there's an upper limit.
    – 0xSanson
    Oct 3, 2022 at 20:03

1 Answer 1

0

If you try:

    function transferTo(address payable dest) payable public {
        require(tx.origin == owner);
        dest.transfer(msg.value);
    }

And send the amount by value field? Im not sure what you want.. but I tried this here on my remix, and worked. Let me know. :D

1
  • Hi, this is not the answer. Kindly read my question and then provide the answer accordingly. What do you mean by worked? Why have you written just the function, not the whole SC? Zulfi.
    – zak100
    Oct 4, 2022 at 13:22

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.