Skip to content

Instantly share code, notes, and snippets.

@rpaskin
Created March 24, 2024 20:42
Show Gist options
  • Save rpaskin/7d5beab83e224f291b7fa9e56aa6b73e to your computer and use it in GitHub Desktop.
Save rpaskin/7d5beab83e224f291b7fa9e56aa6b73e to your computer and use it in GitHub Desktop.
Um token muito muito simples em Solidity
// 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