0
  var endval = this.balance / 2;
  counterparty1.send(endval);
  counterparty2.send(endval);
  selfdestruct(creator);

Is there anyway to selfdestruct to two parties? I have the code above, but now you have to do the whole jazz to make sure it doesn't run out of gas in the middle of a send. Can one end a contract and split the value a better way?

1

You can't send the result of selfdestruct to multiple parties.

What you could do is self-destruct to the address of another contract, and put the splitting logic in that contract.

However, unlike a normal payment to a contract, selfdestruct doesn't automatically invoke the fallback function, so you can't do any splitting in that call. You'd have to simply let the value accumulate in the receiver contract, then have the recipients make another call to the receiver contract to send the funds found in its balance on to wherever they're supposed to be split to. You may prefer to have each of the recipients each make their own call to withdraw funds, as this avoids problems with failed sends affecting other users.

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.