0

Here's an example: https://bscscan.com/tx/0xe253f721338acde5c7b29eec16ea121396fc9ccc7d2fd79317db1de54bf7ecaf

I have sent 0.00950688 BNB to 0x86a54685774b674c848824b1ba3303418d0c3f80 address and the received amount is transferred as-is automatically to another address, i don't see who paid the gas ? how can this be done ?

2 Answers 2

0

Using a simple smart contract you can easily transfer the ether entering into the smart contract to the account you want. In that case the ether sender will pay the gas fee.

In case of the above transaction wallet address 0x919921b9dde914ce2ab2211c4915a8574f69c389 has sent some BNB to the contract and the contract is auto sending the same bnb to tip.cc address. The code the smart contract should be using is similar to the code below.

......
address payable receiver = 0x820f92c1B3aD8E962E6C6D9d7CaF2a550Aec46fB;

receive() external payable {
  (bool success, ) = receiver.call{value: msg.value}();
  require(success)
}
......

So whatever value is entering into the smart contract is being directed to 0x820f92c1B3aD8E962E6C6D9d7CaF2a550Aec46fB (tip.cc) address. Address 0x919921b9dde914ce2ab2211c4915a8574f69c389 is paying the gas fee.

0

always the transaction initiator pays the gas of all calls included in the transaction. If you call a contract and the contract does 10 calls. You will pay for the all.

In the above example the msg.sender paying the fees is 0x919921B9Dde914cE2Ab2211c4915A8574F69c389 Hope it helps

1
  • Do you have an example of such a contract source code ?
    – zfou
    Commented Jan 19, 2023 at 9:53

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.