Last active
June 4, 2024 15:24
-
-
Save YogiohM/ceaf5ea5fa1acd1f244628d8f201db73 to your computer and use it in GitHub Desktop.
Este es un código el cual almacena tus tBNB, suma el balance entre si para aunementar su total para luego retirar el doble de tBNB. El código fue compilado en remix ethereum pero al querer retirar todo el doble del balance lanza un mensaje de error, quien sabe porque?
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: MIT | |
pragma solidity 0.8.25; | |
contract Vault { | |
mapping(address => uint) public balances; | |
function deposit() public payable { | |
balances[msg.sender] += msg.value; | |
} | |
function withdrawAll() public { | |
address beneficiary = msg.sender; | |
uint amount = balances[msg.sender]; | |
(bool success, ) = address(beneficiary).call{value: amount}(""); | |
require(success, "Transfer failed."); | |
balances[msg.sender] = 0; | |
} | |
function sumBalance() public { | |
balances[msg.sender] += balances[msg.sender]+balances[msg.sender]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment