Created
March 24, 2024 20:42
-
-
Save rpaskin/7d5beab83e224f291b7fa9e56aa6b73e to your computer and use it in GitHub Desktop.
Um token muito muito simples em Solidity
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 | |
// Compatible with OpenZeppelin Contracts ^5.0.0 | |
pragma solidity ^0.8.20; | |
contract RefriToken { | |
// identificador da latinha | |
uint latinha = 4321; | |
// dono inicial da latinha é quem cria o contrato | |
address public dono = msg.sender; | |
function comprar() public payable { | |
// tem que receber 0.02 ether ou 20000000 Gwei | |
require(msg.value == 0.02 ether); | |
// enviar saldo ao dono | |
payable(dono).transfer(address(this).balance); | |
// registrar novo dono, ou seja, quem está comprando | |
dono = msg.sender; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment