Skip to content

Instantly share code, notes, and snippets.

@martinsam16
Last active December 2, 2022 01:34
Show Gist options
  • Save martinsam16/d7017aa07c6115dfda8150552e017870 to your computer and use it in GitHub Desktop.
Save martinsam16/d7017aa07c6115dfda8150552e017870 to your computer and use it in GitHub Desktop.
reto seguridad smart contract
//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