Skip to main content
1 of 2
Victory
  • 1.2k
  • 1
  • 8
  • 21

Is there a way to write a function in solidity to transfer all ERC20 tokens and all ETH?

If someone sends tokens and eth to a contact, is there anyway to create a function that will transfer any and all tokens or eth to owner address?

function sendEverything()
public 
{
   owner.transfer(this.balance);
   owner.transfer(this.allthetokens);
}
Victory
  • 1.2k
  • 1
  • 8
  • 21