Contract Balance disappeared! #6152
Answered
by
Nlferu
EngAbdalrhman
asked this question in
Q&A
-
in Raffle i wrote the following code function fulfillRandomWords(
uint256 /*requestId*/, // could comment requestId and take only uint256 since no need to store it in a variable
uint256[] memory randomWords
) internal override {
uint256 WinnerIndex = randomWords[0] % s_participations.length;
address payable winnerAddress = s_participations[WinnerIndex];
s_recentWinner = winnerAddress;
s_state = State.Open;
s_participations = new address payable[](0); // reseting array to get new participations
s_prevBlockTimeStamp = block.timestamp; // reseting the timestamp - update s_prevBlockTimeStamp to current when finished
(bool success, ) = winnerAddress.call{value: address(this).balance}(""); // making transaction to winner , available to payable address
// (bool s, ) = i_owner.call{value: address(this).balance / 4}(""); // could use i_owner.transfer(address(this).balance / 4);
if (!success) {
revert Raffle__TransferFailed(); // instead of require
}
emit WinnerAnnounced(winnerAddress);
} the event emitted that I won and the balance transferred but I didn't get anything and the contract hasn't made a transaction appears in history |
Beta Was this translation helpful? Give feedback.
Answered by
Nlferu
Sep 22, 2023
Replies: 1 comment 4 replies
-
Transaction passed so there is no way you did not receive contract balance, you are just checking tx incorrectly. |
Beta Was this translation helpful? Give feedback.
4 replies
Answer selected by
EngAbdalrhman
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi @EngAbdalrhman
Transaction passed so there is no way you did not receive contract balance, you are just checking tx incorrectly.
Below is proof that you have received your eth