Skip to main content
expand the question
Source Link
Victory
  • 1.2k
  • 1
  • 8
  • 21

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);
}

In other words is there a generalized way to send any and all erc20 tokens, for instance even if the erc20 contract was created after my contract?

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);
}

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);
}

In other words is there a generalized way to send any and all erc20 tokens, for instance even if the erc20 contract was created after my contract?

Source Link
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);
}