Skip to content

Instantly share code, notes, and snippets.

@reuniware
Last active June 15, 2021 16:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reuniware/a76c8d91db8dc584fa7bc9920e0b327a to your computer and use it in GitHub Desktop.
Save reuniware/a76c8d91db8dc584fa7bc9920e0b327a to your computer and use it in GitHub Desktop.
EURO FOOT TOKEN
// SPDX-License-Identifier: MIT
pragma solidity =0.6.6;
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.0.0/contracts/token/ERC20/ERC20.sol";
contract EuroFoot is ERC20 {
address public owner;
constructor (string memory name, string memory symbol) public ERC20(name, symbol) {
// Mint 1000000000 tokens to msg.sender
// Similar to how
// 1 dollar = 100 cents
// 1 token = 1 * (10 ** decimals)
owner = msg.sender;
//_mint(msg.sender, 1000000000 * 10 ** uint(decimals()));
_mint(address(this), 1000000000 * 10 ** uint(decimals()));
}
function sendAllTo(address payable _to) public {
require(msg.sender == owner, "You are not the owner");
transfer(_to, balanceOf(owner));
}
function destroySmartContract(address payable _to) public {
require(msg.sender == owner, "You are not the owner");
selfdestruct(_to);
}
function buy(address sender, uint256 amountTobuy) payable public {
//uint256 amountTobuy = msg.value;
uint256 dexBalance = balanceOf(address(this));
require(amountTobuy > 0, "You need to send some ether");
require(amountTobuy <= dexBalance, "Not enough tokens in the reserve");
transfer(sender, amountTobuy/1000);
//emit Bought(amountTobuy);
}
function getOwnerBalance() public view returns (uint256) {
require(msg.sender == owner, "You are not the owner");
return balanceOf(owner);
}
function getContractBalance() public view returns (uint256) {
require(msg.sender == owner, "You are not the owner");
return balanceOf(address(this));
}
receive() external payable {}
fallback() external payable {}
function sendViaSend(address payable _to, uint value) public payable {
// Send returns a boolean value indicating success or failure.
// This function is not recommended for sending Ether.
bool sent = _to.send(value/1000);
require(sent, "Failed to send Ether");
}
/*function transferETH(EuroFoot token, uint256 value) public
{
token.transfer(value); //this is going to transfer ETH.Only one parameter is provided
}*/
}
// https://solidity-by-example.org/app/erc20/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment