Skip to content

Commit

Permalink
Merge pull request #62 from mariobyn/ns/replaced-transfer-with-call
Browse files Browse the repository at this point in the history
Replaced transfer with call
  • Loading branch information
norswap authored Mar 10, 2022
2 parents 50997dd + c1268e2 commit 24c78db
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions contracts/Challenge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,9 @@ contract Challenge {
fallback() external payable {}
receive() external payable {}
function withdraw() external {
require(msg.sender == owner);
owner.transfer(address(this).balance);
require(msg.sender == owner, "not owner");
(bool sent, ) = owner.call{value: address(this).balance}("");
require(sent, "Failed to send Ether");
}

// create challenge
Expand Down Expand Up @@ -211,8 +212,9 @@ contract Challenge {
require(stepState == c.assertedState[c.R], "wrong asserted state for challenger");

// pay out bounty!!
c.challenger.transfer(address(this).balance);

(bool sent, ) = c.challenger.call{value: address(this).balance}("");
require(sent, "Failed to send Ether");

emit ChallengerWins(challengeId);
}

Expand Down

0 comments on commit 24c78db

Please sign in to comment.