initial commit
This commit is contained in:
commit
bd6afce955
|
@ -0,0 +1 @@
|
||||||
|
build
|
|
@ -0,0 +1,99 @@
|
||||||
|
// SPDX-License-Identifier: Proprietary
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
import "./Owned.sol";
|
||||||
|
import "./IERC20.sol";
|
||||||
|
|
||||||
|
interface FoolsGransRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; }
|
||||||
|
|
||||||
|
contract FoolsGrans is IERC20, Owned {
|
||||||
|
|
||||||
|
string public name = "FoolsGrans";
|
||||||
|
string public symbol = "FOOL";
|
||||||
|
uint256 public override decimals = 18;
|
||||||
|
uint256 public override totalSupply = 15000000000000000015000;
|
||||||
|
|
||||||
|
/* This creates an array with all balances */
|
||||||
|
mapping (address => uint256) public override balanceOf;
|
||||||
|
mapping (address => mapping (address => uint256)) public override allowance;
|
||||||
|
mapping (address => bool) public frozenAccount;
|
||||||
|
|
||||||
|
/* This generates a public event on the blockchain that will notify clients */
|
||||||
|
event Transfer(address indexed from, address indexed to, uint256 value);
|
||||||
|
|
||||||
|
/* If an account is frozen or unfrozen */
|
||||||
|
event FrozenFunds(address target, bool frozen);
|
||||||
|
|
||||||
|
/* Initializes contract with initial supply tokens to the creator of the contract */
|
||||||
|
constructor() {
|
||||||
|
contractOwner = msg.sender;
|
||||||
|
balanceOf[msg.sender] = totalSupply; // Give the creator all initial tokens
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Send coins */
|
||||||
|
function transfer(address _to, uint256 _value) public override returns(bool success) {
|
||||||
|
require(balanceOf[msg.sender] >= _value, "not enough to transfer");
|
||||||
|
require(!frozenAccount[msg.sender], "sender account frozen");
|
||||||
|
|
||||||
|
balanceOf[msg.sender] = balanceOf[msg.sender] - _value;
|
||||||
|
balanceOf[_to] = balanceOf[_to] + _value;
|
||||||
|
|
||||||
|
emit Transfer(msg.sender, _to, _value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Allow another contract to spend some tokens in your behalf */
|
||||||
|
function approve(address _spender, uint256 _value) public override returns (bool success) {
|
||||||
|
allowance[msg.sender][_spender] = _value;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Approve and then communicate the approved contract in a single tx */
|
||||||
|
function approveAndCall(address _spender, uint256 _value, bytes calldata _extraData) public returns (bool success) {
|
||||||
|
FoolsGransRecipient spender = FoolsGransRecipient(_spender);
|
||||||
|
if (approve(_spender, _value)) {
|
||||||
|
spender.receiveApproval(msg.sender, _value, address(this), _extraData);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/* A contract attempts to get the coins */
|
||||||
|
function transferFrom(address _from, address _to, uint256 _value) public override returns (bool success) {
|
||||||
|
require(balanceOf[_from] >= _value, "not enough to transfer");
|
||||||
|
|
||||||
|
if (msg.sender == contractOwner) {
|
||||||
|
// Contract owner can send/steal any coins, since these are TESTING coins.
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
require(allowance[_from][msg.sender] >= _value, "not enough allowance to transfer");
|
||||||
|
require(!frozenAccount[_from], "from account frozen");
|
||||||
|
allowance[_from][msg.sender] = allowance[_from][msg.sender] - _value;
|
||||||
|
}
|
||||||
|
|
||||||
|
balanceOf[_from] = balanceOf[_from] - _value;
|
||||||
|
balanceOf[_to] = balanceOf[_to] + _value;
|
||||||
|
|
||||||
|
emit Transfer(_from, _to, _value);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
function mintToken(address target, uint256 mintedAmount) public onlyContractOwner {
|
||||||
|
totalSupply = totalSupply + mintedAmount;
|
||||||
|
balanceOf[target] = balanceOf[target] + mintedAmount;
|
||||||
|
|
||||||
|
emit Transfer(address(0), address(this), mintedAmount);
|
||||||
|
emit Transfer(address(this), target, mintedAmount);
|
||||||
|
}
|
||||||
|
|
||||||
|
function freezeAccount(address target, bool freeze) public onlyContractOwner {
|
||||||
|
frozenAccount[target] = freeze;
|
||||||
|
emit FrozenFunds(target, freeze);
|
||||||
|
}
|
||||||
|
|
||||||
|
/* This unnamed function is called whenever someone tries to send ether to it */
|
||||||
|
fallback () external {
|
||||||
|
revert(); // Prevents accidental sending of ether
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
// SPDX-License-Identifier: Proprietary
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
interface IERC20 {
|
||||||
|
function totalSupply() external view returns (uint supply);
|
||||||
|
function balanceOf(address _owner) external view returns (uint balance);
|
||||||
|
function transfer(address _to, uint _value) external returns (bool success);
|
||||||
|
function transferFrom(address _from, address _to, uint _value) external returns (bool success);
|
||||||
|
function approve(address _spender, uint _value) external returns (bool success);
|
||||||
|
function allowance(address _owner, address _spender) external view returns (uint remaining);
|
||||||
|
function decimals() external view returns(uint digits);
|
||||||
|
event Approval(address indexed owner, address indexed spender, uint value);
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,19 @@
|
||||||
|
// SPDX-License-Identifier: MIT
|
||||||
|
pragma solidity >=0.4.22 <0.9.0;
|
||||||
|
|
||||||
|
contract Migrations {
|
||||||
|
address public owner = msg.sender;
|
||||||
|
uint public last_completed_migration;
|
||||||
|
|
||||||
|
modifier restricted() {
|
||||||
|
require(
|
||||||
|
msg.sender == owner,
|
||||||
|
"This function is restricted to the contract's owner"
|
||||||
|
);
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setCompleted(uint completed) public restricted {
|
||||||
|
last_completed_migration = completed;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,24 @@
|
||||||
|
// SPDX-License-Identifier: Proprietary
|
||||||
|
|
||||||
|
pragma solidity ^0.8.0;
|
||||||
|
|
||||||
|
contract Owned {
|
||||||
|
address public contractOwner;
|
||||||
|
|
||||||
|
event OwnershipTransferred(
|
||||||
|
address indexed from,
|
||||||
|
address indexed to
|
||||||
|
);
|
||||||
|
|
||||||
|
modifier onlyContractOwner {
|
||||||
|
require(contractOwner == msg.sender, "Not owner");
|
||||||
|
_;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setContractOwner(address newContractOwner) public onlyContractOwner {
|
||||||
|
require(newContractOwner != address(0), "0 owner disallowed");
|
||||||
|
emit OwnershipTransferred(contractOwner, newContractOwner);
|
||||||
|
contractOwner = newContractOwner;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -0,0 +1,5 @@
|
||||||
|
const Migrations = artifacts.require("Migrations");
|
||||||
|
|
||||||
|
module.exports = function (deployer) {
|
||||||
|
deployer.deploy(Migrations);
|
||||||
|
};
|
Loading…
Reference in New Issue