Last active
December 2, 2022 01:34
-
-
Save martinsam16/d7017aa07c6115dfda8150552e017870 to your computer and use it in GitHub Desktop.
reto seguridad smart contract
This file contains hidden or 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.0; | |
import "@openzeppelin/contracts/access/Ownable.sol"; | |
import "github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/math/SafeMath.sol"; | |
contract Desafio is Ownable { | |
using SafeMath for uint256; | |
mapping(address => uint) balances; | |
function min(uint amount) public isOwner { | |
balances[msg.sender] += amount; | |
} | |
function depositar() public payable{ | |
balances[msg.sender] += msg.value; | |
} | |
function retirar() public { | |
require(balances[msg.sender] > 0, "Insufficient balance"); | |
balances[msg.sender] = 0; | |
(bool success, ) = payable(msg.sender).call{value:balances[msg.sender], gas:1000000}(""); | |
require(success, "Error al enviar eth"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment