Skip to content

Instantly share code, notes, and snippets.

@parnaa
Last active October 2, 2018 22:37
Show Gist options
  • Save parnaa/150266573dc362944d3a06a1e67482a2 to your computer and use it in GitHub Desktop.
Save parnaa/150266573dc362944d3a06a1e67482a2 to your computer and use it in GitHub Desktop.
Created using remix-ide: Realtime Ethereum Contract Compiler and Runtime. Load this file by pasting this gists URL or ID at https://remix.ethereum.org/#version=soljson-v0.4.25+commit.59dbf8f1.js&optimize=false&gist=
pragma solidity ^0.4.0;
contract Ballot {
struct Voter {
uint weight;
bool voted;
uint8 vote;
address delegate;
}
struct Proposal {
uint voteCount;
}
address chairperson;
mapping(address => Voter) voters;
Proposal[] proposals;
/// Create a new ballot with $(_numProposals) different proposals.
function Ballot(uint8 _numProposals) public {
chairperson = msg.sender;
voters[chairperson].weight = 1;
proposals.length = _numProposals;
}
/// Give $(toVoter) the right to vote on this ballot.
/// May only be called by $(chairperson).
function giveRightToVote(address toVoter) public {
if (msg.sender != chairperson || voters[toVoter].voted) return;
voters[toVoter].weight = 1;
}
/// Delegate your vote to the voter $(to).
function delegate(address to) public {
Voter storage sender = voters[msg.sender]; // assigns reference
if (sender.voted) return;
while (voters[to].delegate != address(0) && voters[to].delegate != msg.sender)
to = voters[to].delegate;
if (to == msg.sender) return;
sender.voted = true;
sender.delegate = to;
Voter storage delegateTo = voters[to];
if (delegateTo.voted)
proposals[delegateTo.vote].voteCount += sender.weight;
else
delegateTo.weight += sender.weight;
}
/// Give a single vote to proposal $(toProposal).
function vote(uint8 toProposal) public {
Voter storage sender = voters[msg.sender];
if (sender.voted || toProposal >= proposals.length) return;
sender.voted = true;
sender.vote = toProposal;
proposals[toProposal].voteCount += sender.weight;
}
function winningProposal() public constant returns (uint8 _winningProposal) {
uint256 winningVoteCount = 0;
for (uint8 prop = 0; prop < proposals.length; prop++)
if (proposals[prop].voteCount > winningVoteCount) {
winningVoteCount = proposals[prop].voteCount;
_winningProposal = prop;
}
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success); //erc20 compatible
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
event Transfer(address indexed _from, address indexed _to, uint256 _value); //erc20 compatible
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _CAP;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}
else
{
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external returns (bool success){
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
return transferToContract(_to, _value, empty);
}
else
{
return transferToAddress(_to, _value, empty);
}
//emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
else
return false;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue), "Callers balance not enough");
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue) , "The amount to be decreased is incorrect");
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value, "Sender doesn't have enough balance"); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_CAP = _CAP.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value , "target balance is not enough"); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_CAP = _CAP.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _totalMinedSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
uint256 availableMinedSupply;
availableMinedSupply = (_totalMinedSupply.sub(_totalBurnedTokens)).add(_amount);
require(_CAP >= availableMinedSupply , "All tokens minted, Cap reached");
_totalMinedSupply = _totalMinedSupply.add(_amount);
if(_CAP <= _totalMinedSupply.sub(_totalBurnedTokens))
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function maximumSupply() public view returns (uint256 supply){
return _CAP;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _totalMinedSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
function totalBurnedTokens() public view returns (uint256 supply){
return _totalBurnedTokens;
}
function totalSupply() public view returns (uint256 supply){
return _totalMinedSupply.sub(_totalBurnedTokens);
}
}
contract CyBit is mintableERC223{
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version; //An Arbitrary versioning scheme.
uint256 private initialsupply;
uint256 private totalsupply;
constructor() public
{
decimals = 8;
name = "CyBit"; // Set the name for display purposes
symbol = "eCBT"; // Set the symbol for display purposes
version = "V1.0"; //Version.
initialsupply = 7000000000; //PreMined Tokens
totalsupply = 10000000000; //Total Tokens
_CAP = totalsupply.mul(10 ** uint256(decimals));
_initialSupply = initialsupply.mul(10 ** uint256(decimals));
_totalMinedSupply = _initialSupply;
balances[msg.sender] = _totalMinedSupply;
}
function() public {
//not payable fallback function
revert();
}
/* Get the contract constant _name */
function version() public view returns (string _v) {
return version;
}
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
}
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
//name this contract whatever you'd like
contract CryptoyaT is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
function CryptoyaT(
) public{
fulltoken = 500000000;
decimals = 18; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "Cryptoya"; // Set the name for display purposes
symbol = "CRAT"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountineth) public onlyOwner{
uint _amountInwei = _amountineth.mul(10 ** 18);
require(balances[this] > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] > _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
spent[_from][msg.sender] = spent[_from][msg.sender].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
if(_value.sub(spent[msg.sender][_spender]) <= 0)
allowed[msg.sender][_spender] = 0;
else
allowed[msg.sender][_spender] = _value.sub(spent[msg.sender][_spender]);
Approval(msg.sender, _spender, _value);
return true;
}
// Already spent amount i.e. the total transferred amount a spender spent from owner's account
function spend(address _owner, address _spender) constant public returns (uint256 totalspent) {
return spent[_owner][_spender];
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
mapping (address => mapping (address => uint256)) spent;
uint256 public _totalSupply;
}
//name this contract whatever you'd like
contract CryptonaTest is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
function CryptonaTest(
) public{
fulltoken = 500000000;
decimals = 18; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "CryptonaTest"; // Set the name for display purposes
symbol = "CRAT"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
Burn(msg.sender, _value);
Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
Burn(_from, _value);
Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountineth) public onlyOwner{
uint _amountInwei = _amountineth.mul(10 ** 18);
require(this.balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] > _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success); //erc20 compatible
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
event Transfer(address indexed _from, address indexed _to, uint256 _value); //erc20 compatible
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _CAP;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}
else
{
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external returns (bool success){
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
return transferToContract(_to, _value, empty);
}
else
{
return transferToAddress(_to, _value, empty);
}
//emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
else
return false;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue), "Callers balance not enough");
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue) , "The amount to be decreased is incorrect");
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value, "Sender doesn't have enough balance"); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_CAP = _CAP.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value , "target balance is not enough"); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_CAP = _CAP.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _totalMinedSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
uint256 availableMinedSupply;
availableMinedSupply = (_totalMinedSupply.sub(_totalBurnedTokens)).add(_amount);
require(_CAP >= availableMinedSupply , "All tokens minted, Cap reached");
_totalMinedSupply = _totalMinedSupply.add(_amount);
if(_CAP <= _totalMinedSupply.sub(_totalBurnedTokens))
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function maximumSupply() public view returns (uint256 supply){
return _CAP;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _totalMinedSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
function totalBurnedTokens() public view returns (uint256 supply){
return _totalBurnedTokens;
}
function totalSupply() public view returns (uint256 supply){
return _totalMinedSupply.sub(_totalBurnedTokens);
}
}
contract CyBit is mintableERC223{
/* Public variables of the token */
/*
NOTE:
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //Name Of Token
uint256 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version; //An Arbitrary versioning scheme.
uint256 private initialsupply;
uint256 private totalsupply;
constructor() public
{
decimals = 8;
name = "CyBit"; // Set the name for display purposes
symbol = "eCBT"; // Set the symbol for display purposes
version = "V1.0"; //Version.
initialsupply = 7000000000; //PreMined Tokens
totalsupply = 10000000000; //Total Tokens
_CAP = totalsupply.mul(10 ** decimals);
_initialSupply = initialsupply.mul(10 ** decimals);
_totalMinedSupply = _initialSupply;
balances[msg.sender] = _initialSupply;
}
function() public {
//not payable fallback function
revert();
}
/* Get the contract constant _name */
function version() public view returns (string _v) {
return version;
}
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint256 _decimals) {
return decimals;
}
}
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external;
function transfer(address to, uint value, bytes data) external;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _totalSupply;
mapping(address => uint) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external{
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
transferToContract(_to, _value, _data);
}
else
{
transferToAddress(_to, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external{
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
transferToContract(_to, _value, empty);
}
else
{
transferToAddress(_to, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
return length > 0;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue));
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
}
contract mintableERC223 is ERC20BackedERC223{
uint256 public _currentSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
_currentSupply = _currentSupply.add(_amount);
if(_totalSupply < _currentSupply)
mintingFinished = true;
require(_totalSupply >= _currentSupply);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function totalSupply() public view returns (uint256 supply){
return _totalSupply;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _currentSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
}
contract cybit is ERC20BackedERC223{
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'Test-V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private initialsupply;
uint256 private totalsupply;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
function cybit() public
{
decimals = 8;
name = "Cybit"; // Set the name for display purposes
symbol = "CBT"; // Set the symbol for display purposes
initialsupply = 7000000000;
totalsupply = 10000000000;
_totalSupply = totalsupply.mul(10 ** uint256(decimals));
// _initialSupply = initialsupply.mul(10 ** uint256(decimals));
//_currentSupply = _initialSupply;
balances[msg.sender] = _totalSupply;
//emit Mint(msg.sender, _initialSupply);
//emit Transfer(address(0), msg.sender, _initialSupply, 0x5052454d494e454420746f204f776e6572);
}
function() public {
//not payable fallback function
revert();
}
function version() public view returns (string _v) {
require(bytes(_v).length > 0);
return version;
}
/* Get the contract constant _name */
function name() public view returns (string _name) {
require(bytes(_name).length > 0);
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
require(bytes(_symbol).length > 0);
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success);
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
struct TKN {
address sender;
uint value;
bytes data;
bytes4 sig;
}
function tokenFallback(address _from, uint _value, bytes _data) external;
}
contract ERC20BackedERC223 is ERC223Interface{
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function disApprove(address _spender) public returns (bool success);
function increaseApproval(address _spender, uint _addedValue) public returns (bool success);
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
function name() public view returns (string _name);
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol);
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
library SafeERC20BackedERC223 {
function safeTransfer(ERC20BackedERC223 token, address to, uint256 value, bytes data) internal {
assert(token.transfer(to, value, data));
}
function safeTransfer(ERC20BackedERC223 token, address to, uint256 value) internal {
assert(token.transfer(to, value));
}
function safeTransferFrom(ERC20BackedERC223 token, address from, address to, uint256 value) internal {
assert(token.transferFrom(from, to, value));
}
function safeApprove(ERC20BackedERC223 token, address spender, uint256 value) internal {
assert(token.approve(spender, value));
}
}
contract CybitICOTokenVault is ERC223ReceivingContract, owned{
using SafeERC20BackedERC223 for ERC20BackedERC223;
ERC20BackedERC223 CybitToken;
struct Investor {
string fName;
string lName;
}
mapping (address => Investor) public investors;
address[] public investorAccts;
uint256 public numberOFApprovedInvestorAccounts;
constructor() public
{
CybitToken = ERC20BackedERC223(0x2a08c4B5CB8eC0b84beEC790741Ae92Bd1f921E3);
}
function tokenFallback(address _from, uint _value, bytes _data) external{
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
}
function() public {
//not payable fallback function
revert();
}
function sendApprovedTokensToInvestor(address _benificiary,uint256 _approvedamount,string _fName, string _lName) public onlyOwner
{
require(CybitToken.balanceOf(address(this)) > _approvedamount);
investors[_benificiary] = Investor({
fName: _fName,
lName: _lName
});
investorAccts.push(_benificiary) -1;
numberOFApprovedInvestorAccounts = investorAccts.length;
CybitToken.safeTransfer(_benificiary , _approvedamount);
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokenFromcontract(ERC20BackedERC223 _token, uint256 _tamount) public onlyOwner{
require(_token.balanceOf(address(this)) > _tamount);
_token.safeTransfer(owner, _tamount);
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success);
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
struct TKN {
address sender;
uint value;
bytes data;
bytes4 sig;
}
function tokenFallback(address _from, uint _value, bytes _data) external;
}
contract ERC20BackedERC223 is ERC223Interface{
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function disApprove(address _spender) public returns (bool success);
function increaseApproval(address _spender, uint _addedValue) public returns (bool success);
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
function name() public view returns (string _name);
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol);
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
library SafeERC20BackedERC223 {
function safeTransfer(ERC20BackedERC223 token, address to, uint256 value, bytes data) internal {
assert(token.transfer(to, value, data));
}
function safeTransfer(ERC20BackedERC223 token, address to, uint256 value) internal {
assert(token.transfer(to, value));
}
function safeTransferFrom(ERC20BackedERC223 token, address from, address to, uint256 value) internal {
assert(token.transferFrom(from, to, value));
}
function safeApprove(ERC20BackedERC223 token, address spender, uint256 value) internal {
assert(token.approve(spender, value));
}
}
contract ICOTokenVault is ERC223ReceivingContract, owned{
using SafeERC20BackedERC223 for ERC20BackedERC223;
ERC20BackedERC223 CybitToken;
event TokenReceived(address indexed from, uint value, string token_name);
constructor() public
{
CybitToken = ERC20BackedERC223(0x2a08c4B5CB8eC0b84beEC790741Ae92Bd1f921E3);
}
function tokenFallback(address _from, uint _value, bytes _data) external{
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
//uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
//tkn.sig = bytes4(u);
//require( tkn.sender == owner , "Only Owner can send" );
emit TokenReceived(tkn.sender,tkn.value,CybitToken.name());
}
function() public {
//not payable fallback function
revert();
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokenFromcontract(ERC20BackedERC223 _token, uint256 _tamount) public onlyOwner{
require(_token.balanceOf(address(this)) > _tamount);
_token.safeTransfer(owner, _tamount);
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success);
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
struct TKN {
address sender;
uint value;
bytes data;
bytes4 sig;
}
function tokenFallback(address _from, uint _value, bytes _data) external;
}
contract ERC20BackedERC223 is ERC223Interface{
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function disApprove(address _spender) public returns (bool success);
function increaseApproval(address _spender, uint _addedValue) public returns (bool success);
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
function name() public view returns (string _name);
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol);
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
library SafeERC20BackedERC223 {
function safeTransfer(ERC20BackedERC223 token, address to, uint256 value, bytes data) internal {
assert(token.transfer(to, value, data));
}
function safeTransfer(ERC20BackedERC223 token, address to, uint256 value) internal {
assert(token.transfer(to, value));
}
function safeTransferFrom(ERC20BackedERC223 token, address from, address to, uint256 value) internal {
assert(token.transferFrom(from, to, value));
}
function safeApprove(ERC20BackedERC223 token, address spender, uint256 value) internal {
assert(token.approve(spender, value));
}
}
contract TokenVesting is ERC223ReceivingContract, owned {
using SafeMath for uint256;
using SafeERC20BackedERC223 for ERC20BackedERC223;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
string public benificiaryName;
bytes private paramData;
bool public revocable;
mapping (address => uint256) public released;
mapping (address => bool) public revoked;
/**
* @dev Creates a vesting contract that vests its balance of any ERC20 token to the
* _beneficiary, gradually in a linear fashion until _start + _duration. By then all
* of the balance will have vested.
* @param _beneficiary address of the beneficiary to whom vested tokens are transferred
* @param _cliff duration in seconds of the cliff in which tokens will begin to vest
* @param _duration duration in seconds of the period in which the tokens will vest
* @param _revocable whether the vesting is revocable or not
*/
constructor(
address _beneficiary,
uint256 _start,
uint256 _cliff,
uint256 _duration,
bool _revocable,
string _benficiaryName
)
public
{
require(_beneficiary != address(0));
require(_cliff <= _duration);
beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
benificiaryName = _benficiaryName;
paramData = bytes32ToBytes(stringToBytes32(_benficiaryName));
}
function tokenFallback(address _from, uint _value, bytes _data) external{
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
}
function stringToBytes32(string memory source) internal pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}
assembly {
result := mload(add(source, 32))
}
}
function bytes32ToBytes(bytes32 data) internal pure returns (bytes) {
uint i = 0;
while (i < 32 && uint(data[i]) != 0) {
++i;
}
bytes memory result = new bytes(i);
i = 0;
while (i < 32 && data[i] != 0) {
result[i] = data[i];
++i;
}
return result;
}
/**
* @notice Transfers vested tokens to beneficiary.
* @param token ERC223 token which is being vested
*/
function release(ERC20BackedERC223 token) public {
uint256 unreleased = releasableAmount(token);
require(unreleased > 0);
released[token] = released[token].add(unreleased);
token.safeTransfer(beneficiary, unreleased, paramData);
emit Released(unreleased);
}
/**
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param token ERC20 token which is being vested
*/
function revoke(ERC20BackedERC223 token) public onlyOwner {
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
token.safeTransfer(owner, refund, paramData);
emit Revoked();
}
/**
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param token ERC20 token which is being vested
*/
function releasableAmount(ERC20BackedERC223 token) public view returns (uint256) {
return vestedAmount(token).sub(released[token]);
}
/**
* @dev Calculates the amount that has already vested.
* @param token ERC20 token which is being vested
*/
function vestedAmount(ERC20BackedERC223 token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
}
}
}
contract CybitTokenVestingFactory is ERC223ReceivingContract, owned {
using SafeMath for uint256;
using SafeERC20BackedERC223 for ERC20BackedERC223;
ERC20BackedERC223 CybitToken = ERC20BackedERC223(0x2a08c4B5CB8eC0b84beEC790741Ae92Bd1f921E3); //the deployed token address
struct Trustee{
string trusteeName;
address benificiary;
TokenVesting vestingForThisTrustee;
uint256 totalGrantedAmount;
uint256 start;
uint256 cliff;
uint256 duration;
bool revokable;
}
// Grants holder.
mapping (address => Trustee) public TrusteeBoard;
address[] public trusteeAccts;
event Created(TokenVesting vesting);
function tokenFallback(address _from, uint _value, bytes _data) external{
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
}
function create(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, string _benficiaryName) internal returns (TokenVesting) {
TokenVesting vesting = new TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable, _benficiaryName );
emit Created(vesting);
return vesting;
}
function VestTokens(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, string _benficiaryName, uint256 _grantedAmount) onlyOwner public
{
require(CybitToken.balanceOf(address(this)) >= _grantedAmount);
uint256 tokendecimals = CybitToken.decimals();
uint256 fullgrantedAmount = _grantedAmount.mul(10 ** uint256(tokendecimals));
TokenVesting vest = create(_beneficiary, _start, _cliff, _duration, _revocable, _benficiaryName);
TrusteeBoard[_beneficiary] = Trustee({
trusteeName: _benficiaryName,
benificiary: _beneficiary,
vestingForThisTrustee: vest,
totalGrantedAmount: fullgrantedAmount,
start: _start,
cliff: _cliff,
duration: _duration,
revokable: _revocable
});
trusteeAccts.push(_beneficiary) -1;
CybitToken.safeTransfer(vest,fullgrantedAmount);
}
function callRealeseVestedAmount(address _beneficiary,TokenVesting _vested) public {
require((TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested),"Member Not Found");
_vested.release(CybitToken);
}
function optionalRevoke(address _beneficiary,TokenVesting _vested) public onlyOwner{
require((TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested),"Member Not Found");
require(TrusteeBoard[_beneficiary].revokable ,"Revoke not allowed");
_vested.revoke(CybitToken);
}
function readReleasableAmountOf(address _beneficiary,TokenVesting _vested) public view returns(uint256 _ramount)
{
assert(TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested);
return _vested.releasableAmount(CybitToken);
}
function readVestedAmountOf(address _beneficiary,TokenVesting _vested) public view returns(uint256 _ramount)
{
assert(TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested);
return _vested.vestedAmount(CybitToken);
}
//function for withdrawal of extra tokens
function withdrawTokenFromcontract(ERC20BackedERC223 _token, uint256 _tamount) public onlyOwner{
require(_token.balanceOf(address(this)) > _tamount);
_token.safeTransfer(owner, _tamount);
}
}
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract Solarex is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
function Solarex(
) public{
fulltoken = 2400000000;
decimals = 6; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "Solarex"; // Set the name for display purposes
symbol = "SRX"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] >= _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
require(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC223Interface {
function balanceOf(address _owner) constant external returns (uint256 balance);
function transfer(address to, uint value) external;
function transfer(address to, uint value, bytes data) external;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingInterface {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
interface ERC20Token {
function totalSupply() constant external returns (uint256 supply);
function initialSupply() constant external returns (uint256 supply);
function currentSupply() constant external returns (uint256 supply);
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
require(msg.data.length == size.add(4));
_;
}
uint256 public _totalSupply;
uint256 public _preminedSupply;
uint256 public _currentSupply;
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/// @return total amount of tokens
function totalSupply() constant external returns (uint256 supply){
return _totalSupply;
}
/// @return initial or premined amount of tokens
function preminedSupply() constant external returns (uint256 supply){
return _preminedSupply;
}
/// @return current supply of tokens
function currentSupply() constant external returns (uint256 supply){
return _currentSupply;
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract mintableERC223Token is ERC223Interface, StandardToken {
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external{
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingInterface receiver = ERC223ReceivingInterface(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external{
uint codeLength;
bytes memory empty;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingInterface receiver = ERC223ReceivingInterface(_to);
receiver.tokenFallback(msg.sender, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
_currentSupply = _currentSupply.add(_amount);
require(_totalSupply >= _currentSupply);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
//The Contract Name
contract CybitDev is mintableERC223Token{
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'Test-V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
uint256 private initial_supply;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC223Token
function CybitDev(
) public{
fulltoken = 10000000000;
initial_supply = 7000000000;
decimals = 8; // Amount of decimals for display purposes
_preminedSupply = initial_supply.mul(10 ** uint256(decimals));
_currentSupply = _preminedSupply;
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = initial_supply; // Give the creator all initial tokens (100000 for example)
name = "Cybit"; // Set the name for display purposes
symbol = "CBT"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountineth) public onlyOwner{
uint _amountInwei = _amountineth.mul(10 ** 18);
require(balances[this] > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] > _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success); //erc20 compatible
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
event Transfer(address indexed _from, address indexed _to, uint256 _value); //erc20 compatible
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _CAP;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}
else
{
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external returns (bool success){
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
return transferToContract(_to, _value, empty);
}
else
{
return transferToAddress(_to, _value, empty);
}
//emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
else
return false;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue), "Callers balance not enough");
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue) , "The amount to be decreased is incorrect");
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value, "Sender doesn't have enough balance"); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_CAP = _CAP.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value , "target balance is not enough"); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_CAP = _CAP.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _totalMinedSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
uint256 availableMinedSupply;
availableMinedSupply = (_totalMinedSupply.sub(_totalBurnedTokens)).add(_amount);
require(_CAP >= availableMinedSupply , "All tokens minted, Cap reached");
_totalMinedSupply = _totalMinedSupply.add(_amount);
if(_CAP <= _totalMinedSupply.sub(_totalBurnedTokens))
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function maximumSupply() public view returns (uint256 supply){
return _CAP;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _totalMinedSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
function totalBurnedTokens() public view returns (uint256 supply){
return _totalBurnedTokens;
}
function totalSupply() public view returns (uint256 supply){
return _totalMinedSupply.sub(_totalBurnedTokens);
}
}
contract FairDiamondMining is mintableERC223{
/* Public variables of the token */
string public name; //Name Of Token
uint256 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version; //An Arbitrary versioning scheme.
constructor() public
{
decimals = 3;
name = "Fair Diamond Mining"; // Set the name for display purposes
symbol = "FDM"; // Set the symbol for display purposes
version = "V1.0"; //Version.
_CAP = 48000000;
_initialSupply = 48000000;
_totalMinedSupply = 48000000;
balances[msg.sender] = 48000000;
}
function() public {
//not payable fallback function
revert();
}
/* Get the contract constant _name */
function version() public view returns (string _v) {
return version;
}
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint256 _decimals) {
return decimals;
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) external view returns (uint);
function transfer(address to, uint value) external returns (bool success); //erc20 compatible
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
event Transfer(address indexed _from, address indexed _to, uint256 _value); //erc20 compatible
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _CAP;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}
else
{
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external returns (bool success){
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
return transferToContract(_to, _value, empty);
}
else
{
return transferToAddress(_to, _value, empty);
}
//emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
else
return false;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) external view returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require(_spender != address(0));
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
require(_spender != address(0));
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(_spender != address(0));
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue), "Callers balance not enough");
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
require(_spender != address(0));
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue) , "The amount to be decreased is incorrect");
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value, "Sender doesn't have enough balance"); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_CAP = _CAP.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(_from!= address(0));
require(balances[_from] >= _value , "target balance is not enough"); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_CAP = _CAP.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _totalMinedSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
require(_to != address(0));
bytes memory empty;
uint256 availableMinedSupply;
availableMinedSupply = (_totalMinedSupply.sub(_totalBurnedTokens)).add(_amount);
require(_CAP >= availableMinedSupply , "All tokens minted, Cap reached");
_totalMinedSupply = _totalMinedSupply.add(_amount);
if(_CAP <= _totalMinedSupply.sub(_totalBurnedTokens))
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function maximumSupply() public view returns (uint256 supply){
return _CAP;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _totalMinedSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
function totalBurnedTokens() public view returns (uint256 supply){
return _totalBurnedTokens;
}
function totalSupply() public view returns (uint256 supply){
return _totalMinedSupply.sub(_totalBurnedTokens);
}
}
contract FairDiamondMining is mintableERC223{
/* Public variables of the token */
string public name; //Name Of Token
uint256 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version; //An Arbitrary versioning scheme.
constructor() public
{
decimals = 3;
name = "Fair Diamond Mining"; // Set the name for display purposes
symbol = "FDM"; // Set the symbol for display purposes
version = "V1.0"; //Version.
_CAP = 48000000;
_initialSupply = 48000000;
_totalMinedSupply = 48000000;
balances[msg.sender] = 48000000;
}
function() public {
//not payable fallback function
revert();
}
/* Get the contract constant _name */
function version() public view returns (string _v) {
return version;
}
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint256 _decimals) {
return decimals;
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) view external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
/**
Mitigation for short address attack
*/
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) view external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
require(_value <= balances[msg.sender]);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint256 _addedValue) whenNotPaused public returns (bool)
{
allowed[msg.sender][_spender] = (allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender,uint256 _subtractedValue) whenNotPaused public returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract GFT is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
constructor(
) public{
fulltoken = 1500000000;
decimals = 3; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "GFT"; // Set the name for display purposes
symbol = "GFT"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() public view returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] >= _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
/* Get the contract constant _name */
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) view external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
function approve(address _spender, uint256 _value) public returns (bool success);
function disApprove(address _spender) public returns (bool success);
function increaseApproval(address _spender, uint _addedValue) public returns (bool success);
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining);
function name() public view returns (string _name);
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol);
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
library SafeERC20{
function safeTransfer(ERC20Token token, address to, uint256 value) internal {
assert(token.transfer(to, value));
}
function safeTransferFrom(ERC20Token token, address from, address to, uint256 value) internal {
assert(token.transferFrom(from, to, value));
}
function safeApprove(ERC20Token token, address spender, uint256 value) internal {
assert(token.approve(spender, value));
}
}
contract TokenVesting is owned {
using SafeMath for uint256;
using SafeERC20 for ERC20Token;
event Released(uint256 amount);
event Revoked();
// beneficiary of tokens after they are released
address public beneficiary;
uint256 public cliff;
uint256 public start;
uint256 public duration;
string public benificiaryName;
bytes private paramData;
bool public revocable;
mapping (address => uint256) public released;
mapping (address => bool) public revoked;
/**
* @dev Creates a vesting contract that vests its balance of any ERC20 token to the
* _beneficiary, gradually in a linear fashion until _start + _duration. By then all
* of the balance will have vested.
* @param _beneficiary address of the beneficiary to whom vested tokens are transferred
* @param _cliff duration in seconds of the cliff in which tokens will begin to vest
* @param _duration duration in seconds of the period in which the tokens will vest
* @param _revocable whether the vesting is revocable or not
*/
constructor(
address _beneficiary,
uint256 _start,
uint256 _cliff,
uint256 _duration,
bool _revocable,
string _benficiaryName
)
public
{
require(_beneficiary != address(0));
require(_cliff <= _duration);
beneficiary = _beneficiary;
revocable = _revocable;
duration = _duration;
cliff = _start.add(_cliff);
start = _start;
benificiaryName = _benficiaryName;
}
function stringToBytes32(string memory source) internal pure returns (bytes32 result) {
bytes memory tempEmptyStringTest = bytes(source);
if (tempEmptyStringTest.length == 0) {
return 0x0;
}
assembly {
result := mload(add(source, 32))
}
}
function bytes32ToBytes(bytes32 data) internal pure returns (bytes) {
uint i = 0;
while (i < 32 && uint(data[i]) != 0) {
++i;
}
bytes memory result = new bytes(i);
i = 0;
while (i < 32 && data[i] != 0) {
result[i] = data[i];
++i;
}
return result;
}
/**
* @notice Transfers vested tokens to beneficiary.
* @param token ERC223 token which is being vested
*/
function release(ERC20Token token) public {
uint256 unreleased = releasableAmount(token);
require(unreleased > 0);
released[token] = released[token].add(unreleased);
token.safeTransfer(beneficiary, unreleased);
emit Released(unreleased);
}
/**
* @notice Allows the owner to revoke the vesting. Tokens already vested
* remain in the contract, the rest are returned to the owner.
* @param token ERC20 token which is being vested
*/
function revoke(ERC20Token token) public onlyOwner {
require(revocable);
require(!revoked[token]);
uint256 balance = token.balanceOf(this);
uint256 unreleased = releasableAmount(token);
uint256 refund = balance.sub(unreleased);
revoked[token] = true;
token.safeTransfer(owner, refund);
emit Revoked();
}
/**
* @dev Calculates the amount that has already vested but hasn't been released yet.
* @param token ERC20 token which is being vested
*/
function releasableAmount(ERC20Token token) public view returns (uint256) {
return vestedAmount(token).sub(released[token]);
}
/**
* @dev Calculates the amount that has already vested.
* @param token ERC20 token which is being vested
*/
function vestedAmount(ERC20Token token) public view returns (uint256) {
uint256 currentBalance = token.balanceOf(this);
uint256 totalBalance = currentBalance.add(released[token]);
if (block.timestamp < cliff) {
return 0;
} else if (block.timestamp >= start.add(duration) || revoked[token]) {
return totalBalance;
} else {
return totalBalance.mul(block.timestamp.sub(start)).div(duration);
}
}
}
contract GFTTokenVestingFactory is owned {
using SafeMath for uint256;
using SafeERC20 for ERC20Token;
ERC20Token GFTToken = ERC20Token(0x668C027f7dD117109CAf3D322765Bad9406e2020); //the deployed token address
struct Trustee{
string trusteeName;
address benificiary;
TokenVesting vestingForThisTrustee;
uint256 totalGrantedAmount;
uint256 start;
uint256 cliff;
uint256 duration;
bool revokable;
bool registered;
}
// Grants holder.
mapping (address => Trustee) public TrusteeBoard;
Trustee[] public trusteeAccts;
event Created(TokenVesting vesting);
function create(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, string _benficiaryName) internal returns (TokenVesting) {
TokenVesting vesting = new TokenVesting(_beneficiary, _start, _cliff, _duration, _revocable, _benficiaryName );
emit Created(vesting);
return vesting;
}
function VestTokens(address _beneficiary, uint256 _start, uint256 _cliff, uint256 _duration, bool _revocable, string _benficiaryName, uint256 _grantedAmount) onlyOwner public
{
require(GFTToken.balanceOf(address(this)) >= _grantedAmount,"Factory balance exhausted");
require(!TrusteeBoard[_beneficiary].registered,"The benificiary wallet Address already exists");
uint256 tokendecimals = GFTToken.decimals();
uint256 fullgrantedAmount = _grantedAmount.mul(10 ** uint256(tokendecimals));
TokenVesting vest = create(_beneficiary, _start, _cliff, _duration, _revocable, _benficiaryName);
TrusteeBoard[_beneficiary] = Trustee({
trusteeName: _benficiaryName,
benificiary: _beneficiary,
vestingForThisTrustee: vest,
totalGrantedAmount: fullgrantedAmount,
start: _start,
cliff: _cliff,
duration: _duration,
revokable: _revocable,
registered: true
});
trusteeAccts.push(TrusteeBoard[_beneficiary]) -1;
GFTToken.safeTransfer(vest,fullgrantedAmount);
}
function numberOfVestedContracts() public view returns(uint256 n)
{
return trusteeAccts.length;
}
function callRealeseVestedAmount(address _beneficiary,TokenVesting _vested) public {
require((TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested),"Member Not Found");
_vested.release(GFTToken);
}
function optionalRevoke(address _beneficiary,TokenVesting _vested) public onlyOwner{
require((TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested),"Member Not Found");
require(TrusteeBoard[_beneficiary].revokable ,"Revoke not allowed");
_vested.revoke(GFTToken);
}
function readReleasableAmountOf(address _beneficiary,TokenVesting _vested) public view returns(uint256 _ramount)
{
assert(TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested);
return _vested.releasableAmount(GFTToken);
}
function readVestedAmountOf(address _beneficiary,TokenVesting _vested) public view returns(uint256 _ramount)
{
assert(TrusteeBoard[_beneficiary].benificiary == _beneficiary && TrusteeBoard[_beneficiary].vestingForThisTrustee == _vested);
return _vested.vestedAmount(GFTToken);
}
//function for withdrawal of extra tokens
function withdrawTokenFromcontract(ERC20Token _token, uint256 _tamount) public onlyOwner{
require(_token.balanceOf(address(this)) > _tamount);
_token.safeTransfer(owner, _tamount);
}
}
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
require(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
require(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
// uint public totalSupply;
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external;
function transfer(address to, uint value, bytes data) external;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _totalSupply;
mapping(address => uint) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external{
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
uint codeLength;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external{
require(balances[msg.sender] >= _value && _value > 0);
uint codeLength;
bytes memory empty;
assembly {
// Retrieve the size of the code on target address, this needs assembly .
codeLength := extcodesize(_to)
}
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
if(codeLength>0) {
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
modifier onlyPayloadSize(uint size) {
require(msg.data.length == size.add(4));
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function increaseApproval(address _spender, uint _addedValue) public returns (bool) {
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) public returns (bool) {
uint oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
}
contract mintableERC223 is ERC20BackedERC223{
uint256 public _currentSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
_currentSupply = _currentSupply.add(_amount);
require(_totalSupply >= _currentSupply);
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
}
contract cybit is mintableERC223{
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'Test-V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 initialsupply;
uint256 totalsupply;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
function cybit() public
{
decimals = 8;
name = "Cybit"; // Set the name for display purposes
symbol = "CBT"; // Set the symbol for display purposes
initialsupply = 7000000000;
totalsupply = 10000000000;
_totalSupply = totalsupply.mul(10 ** uint256(decimals));
_initialSupply = initialsupply.mul(10 ** uint256(decimals));
_currentSupply = _initialSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
pragma solidity ^0.4.23;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external;
function transfer(address to, uint value, bytes data) external;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _totalSupply;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external{
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
transferToContract(_to, _value, _data);
}
else
{
transferToAddress(_to, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external{
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
transferToContract(_to, _value, empty);
}
else
{
transferToAddress(_to, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue));
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _currentSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
require(_totalSupply >= _currentSupply.add(_amount));
_currentSupply = _currentSupply.add(_amount);
if(_totalSupply < _currentSupply)
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function totalSupply() public view returns (uint256 supply){
return _totalSupply;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _currentSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
}
contract cybit is mintableERC223{
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'Test-V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private initialsupply;
uint256 private totalsupply;
constructor() public
{
decimals = 8;
name = "Cybit"; // Set the name for display purposes
symbol = "CBT"; // Set the symbol for display purposes
initialsupply = 7000000000;
totalsupply = 10000000000;
_totalSupply = totalsupply.mul(10 ** uint256(decimals));
_initialSupply = initialsupply.mul(10 ** uint256(decimals));
_currentSupply = _initialSupply;
balances[msg.sender] = _currentSupply;
//emit Mint(msg.sender, _initialSupply);
}
function() public {
//not payable fallback function
revert();
}
function version() public view returns (string _v) {
return version;
}
/* Get the contract constant _name */
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
}
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract Solarex is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
function Solarex(
) public{
fulltoken = 2400000000;
decimals = 6; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "Solarex"; // Set the name for display purposes
symbol = "SRX"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] >= _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity ^0.4.21;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
contract ERC223Interface {
uint public totalSupply;
function balanceOf(address who) public constant returns (uint);
function transfer(address to, uint value) external;
function transfer(address to, uint value, bytes data) external;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) public;
}
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract SreeERC is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
function SreeERC(
) public{
fulltoken = 100000000;
decimals = 8; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "SreeERC"; // Set the name for display purposes
symbol = "SERC"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountineth) public onlyOwner{
uint _amountInwei = _amountineth.mul(10 ** 18);
require(balances[this] > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] > _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
contract TokenVault is owned{
using SafeMath for uint256;
// The token being sold
StandardToken public token;
//Tokens available for Distribution
uint256 public totalDistributionAmount;
function TokenVault(StandardToken _tokenaddress) public{
token = _tokenaddress;
totalDistributionAmount = 0;
}
function set_Distribution_Amount(uint256 _amount) public onlyOwner
{
totalDistributionAmount = _amount;
}
}
pragma solidity 0.4.25;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) view external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
/**
Mitigation for short address attack
*/
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) view external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
require(_value <= balances[msg.sender]);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint256 _addedValue) whenNotPaused public returns (bool)
{
allowed[msg.sender][_spender] = (allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender,uint256 _subtractedValue) whenNotPaused public returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract TansalCoin is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
constructor(
) public{
fulltoken = 400000000;
decimals = 3; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "Tansal Coin"; // Set the name for display purposes
symbol = "TAN"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() public view returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] >= _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
/* Get the contract constant _name */
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
}
pragma solidity 0.4.25;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Interface {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) view external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
function approve(address _spender, uint256 _value) external returns (bool success);
function disApprove(address _spender) external returns (bool success);
function increaseApproval(address _spender, uint _addedValue) external returns (bool success);
function decreaseApproval(address _spender, uint _subtractedValue) external returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant external returns (uint256 remaining);
function name() external view returns (string _name);
/* Get the contract constant _symbol */
function symbol() external view returns (string _symbol);
/* Get the contract constant _decimals */
function decimals() external view returns (uint8 _decimals);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
library SafeERC20{
function safeTransfer(ERC20Interface token, address to, uint256 value) internal {
assert(token.transfer(to, value));
}
function safeTransferFrom(ERC20Interface token, address from, address to, uint256 value) internal {
assert(token.transferFrom(from, to, value));
}
function safeApprove(ERC20Interface token, address spender, uint256 value) internal {
assert(token.approve(spender, value));
}
}
contract TansalICOTokenVault is owned{
using SafeERC20 for ERC20Interface;
ERC20Interface TansalCoin;
struct Investor {
string fName;
string lName;
uint256 totalTokenWithdrawn;
bool exists;
}
mapping (address => Investor) public investors;
address[] public investorAccts;
uint256 public numberOFApprovedInvestorAccounts;
constructor() public
{
TansalCoin = ERC20Interface(0xe4a93eC88EaB28Fa25F03d066b6f94135722a120);
}
function() public {
//not payable fallback function
revert();
}
function sendApprovedTokensToInvestor(address _benificiary,uint256 _approvedamount,string _fName, string _lName) public onlyOwner
{
uint256 totalwithdrawnamount;
require(TansalCoin.balanceOf(address(this)) > _approvedamount);
if(investors[_benificiary].exists)
{
uint256 alreadywithdrawn = investors[_benificiary].totalTokenWithdrawn;
totalwithdrawnamount = alreadywithdrawn + _approvedamount;
}
else
totalwithdrawnamount = _approvedamount;
investors[_benificiary] = Investor({
fName: _fName,
lName: _lName,
totalTokenWithdrawn: totalwithdrawnamount,
exists: true
});
require(investors[_benificiary].exists,"benificiary not added");
investorAccts.push(_benificiary) -1;
numberOFApprovedInvestorAccounts = investorAccts.length;
TansalCoin.safeTransfer(_benificiary , _approvedamount);
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokenFromcontract(ERC20Interface _token, uint256 _tamount) public onlyOwner{
require(_token.balanceOf(address(this)) > _tamount);
_token.safeTransfer(owner, _tamount);
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) view external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
/**
Mitigation for short address attack
*/
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) view external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
require(_value <= balances[msg.sender]);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint256 _addedValue) whenNotPaused public returns (bool)
{
allowed[msg.sender][_spender] = (allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender,uint256 _subtractedValue) whenNotPaused public returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract GFT is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
constructor(
) public{
fulltoken = 1500000000;
decimals = 3; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "GFT"; // Set the name for display purposes
symbol = "GFT"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() public view returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] >= _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
/* Get the contract constant _name */
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
}
pragma solidity ^0.4.23;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
require(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
require(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
require(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external;
function transfer(address to, uint value, bytes data) external;
event Transfer(address indexed from, address indexed to, uint value, bytes data);
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _totalMaxSupply;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external{
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
transferToContract(_to, _value, _data);
}
else
{
transferToAddress(_to, _value, _data);
}
emit Transfer(msg.sender, _to, _value, _data);
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external{
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
transferToContract(_to, _value, empty);
}
else
{
transferToAddress(_to, _value, empty);
}
emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
event Transfer(address indexed _from, address indexed _to, uint256 _value);
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size + 4);
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue));
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue));
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalMaxSupply = _totalMaxSupply.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalMaxSupply = _totalMaxSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _totalMinedSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
uint256 availableMinedSupply;
availableMinedSupply = (_totalMinedSupply.sub(_totalBurnedTokens)).add(_amount);
require(_totalMaxSupply >= availableMinedSupply);
_totalMinedSupply = _totalMinedSupply.add(_amount);
if(_totalMaxSupply <= _totalMinedSupply.sub(_totalBurnedTokens))
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function maximumAvailableSupply() public view returns (uint256 supply){
return _totalMaxSupply;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _totalMinedSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
function totalBurnedTokens() public view returns (uint256 supply){
return _totalBurnedTokens;
}
function totalSupply() public view returns (uint256 supply){
return _totalMinedSupply.sub(_totalBurnedTokens);
}
}
contract cybit is mintableERC223{
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'Test-V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private initialsupply;
uint256 private totalsupply;
constructor() public
{
decimals = 8;
name = "Cybit"; // Set the name for display purposes
symbol = "CBT"; // Set the symbol for display purposes
initialsupply = 7000000000;
totalsupply = 10000000000;
_totalMaxSupply = totalsupply.mul(10 ** uint256(decimals));
_initialSupply = initialsupply.mul(10 ** uint256(decimals));
_totalMinedSupply = _initialSupply;
balances[msg.sender] = _totalMinedSupply;
//emit Mint(msg.sender, _initialSupply);
}
function() public {
//not payable fallback function
revert();
}
function version() public view returns (string _v) {
return version;
}
/* Get the contract constant _name */
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint8 _decimals) {
return decimals;
}
}
pragma solidity ^0.4.17;
/* ERC20 contract interface */
/* With ERC23/ERC223 Extensions */
/* Fully backward compatible with ERC20 */
/* Recommended implementation used at https://github.com/Dexaran/ERC223-token-standard/tree/Recommended */
contract ERC20 {
uint public totalSupply;
// ERC223 and ERC20 functions and events
function balanceOf(address who) public constant returns (uint);
function totalSupply() constant public returns (uint256 _supply);
function transfer(address to, uint value) public returns (bool ok);
function transfer(address to, uint value, bytes data) public returns (bool ok);
function transfer(address to, uint value, bytes data, string customFallback) public returns (bool ok);
event Transfer(address indexed from, address indexed to, uint value, bytes indexed data);
// ERC223 functions
function name() constant public returns (string _name);
function symbol() constant public returns (string _symbol);
function decimals() constant public returns (uint8 _decimals);
// ERC20 functions and events
function transferFrom(address _from, address _to, uint256 _value) returns (bool success);
function approve(address _spender, uint256 _value) returns (bool success);
function allowance(address _owner, address _spender) constant returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint _value);
}
/**
* Include SafeMath Lib
*/
contract SafeMath {
uint256 constant public MAX_UINT256 =
0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF;
function safeAdd(uint256 x, uint256 y) constant internal returns (uint256 z) {
if (x > MAX_UINT256 - y)
revert();
return x + y;
}
function safeSub(uint256 x, uint256 y) constant internal returns (uint256 z) {
if (x < y) {
revert();
}
return x - y;
}
function safeMul(uint256 x, uint256 y) constant internal returns (uint256 z) {
if (y == 0) {
return 0;
}
if (x > MAX_UINT256 / y) {
revert();
}
return x * y;
}
}
/*
* Contract that is working with ERC223 tokens
*/
contract ContractReceiver {
struct TKN {
address sender;
uint value;
bytes data;
bytes4 sig;
}
function tokenFallback(address _from, uint _value, bytes _data) public {
TKN memory tkn;
tkn.sender = _from;
tkn.value = _value;
tkn.data = _data;
uint32 u = uint32(_data[3]) + (uint32(_data[2]) << 8) + (uint32(_data[1]) << 16) + (uint32(_data[0]) << 24);
tkn.sig = bytes4(u);
/* tkn variable is analogue of msg variable of Ether transaction
* tkn.sender is person who initiated this token transaction (analogue of msg.sender)
* tkn.value the number of tokens that were sent (analogue of msg.value)
* tkn.data is data of token transaction (analogue of msg.data)
* tkn.sig is 4 bytes signature of function
* if data of token transaction is a function execution
*/
}
}
/*
* EDOGE is an ERC20 token with ERC223 Extensions
*/
contract EDOGE is ERC20, SafeMath {
string public name = "eDogecoin";
string public symbol = "EDOGE";
uint8 public decimals = 8;
uint256 public totalSupply = 100000000000 * 10**8;
address public owner;
bool public unlocked = false;
bool public tokenCreated = false;
mapping(address => uint256) balances;
mapping(address => mapping (address => uint256)) allowed;
// Initialize to have owner have 100,000,000,000 EDOGE on contract creation
// Constructor is called only once and can not be called again (Ethereum Solidity specification)
function EDOGE() public {
// Security check in case EVM has future flaw or exploit to call constructor multiple times
// Ensure token gets created once only
require(tokenCreated == false);
tokenCreated = true;
owner = msg.sender;
balances[owner] = totalSupply;
// Final sanity check to ensure owner balance is greater than zero
require(balances[owner] > 0);
}
modifier onlyOwner() {
require(msg.sender == owner);
_;
}
// Function to distribute tokens to list of addresses by the provided amount
// Verify and require that:
// - Balance of owner cannot be negative
// - All transfers can be fulfilled with remaining owner balance
// - No new tokens can ever be minted except originally created 100,000,000,000
function distributeAirdrop(address[] addresses, uint256 amount) onlyOwner public {
// Only allow undrop while token is locked
// After token is unlocked, this method becomes permanently disabled
require(!unlocked);
// Amount is in Wei, convert to EDOGE amount in 8 decimal places
uint256 normalizedAmount = amount * 10**8;
// Only proceed if there are enough tokens to be distributed to all addresses
// Never allow balance of owner to become negative
require(balances[owner] >= safeMul(addresses.length, normalizedAmount));
for (uint i = 0; i < addresses.length; i++) {
balances[owner] = safeSub(balanceOf(owner), normalizedAmount);
balances[addresses[i]] = safeAdd(balanceOf(addresses[i]), normalizedAmount);
Transfer(owner, addresses[i], normalizedAmount);
}
}
// Function to access name of token .sha
function name() constant public returns (string _name) {
return name;
}
// Function to access symbol of token .
function symbol() constant public returns (string _symbol) {
return symbol;
}
// Function to access decimals of token .
function decimals() constant public returns (uint8 _decimals) {
return decimals;
}
// Function to access total supply of tokens .
function totalSupply() constant public returns (uint256 _totalSupply) {
return totalSupply;
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data, string _custom_fallback) public returns (bool success) {
// Only allow transfer once unlocked
// Once it is unlocked, it is unlocked forever and no one can lock again
require(unlocked);
if (isContract(_to)) {
if (balanceOf(msg.sender) < _value) {
revert();
}
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
ContractReceiver receiver = ContractReceiver(_to);
receiver.call.value(0)(bytes4(sha3(_custom_fallback)), msg.sender, _value, _data);
Transfer(msg.sender, _to, _value, _data);
return true;
} else {
return transferToAddress(_to, _value, _data);
}
}
// Function that is called when a user or another contract wants to transfer funds .
function transfer(address _to, uint _value, bytes _data) public returns (bool success) {
// Only allow transfer once unlocked
// Once it is unlocked, it is unlocked forever and no one can lock again
require(unlocked);
if (isContract(_to)) {
return transferToContract(_to, _value, _data);
} else {
return transferToAddress(_to, _value, _data);
}
}
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
function transfer(address _to, uint _value) public returns (bool success) {
// Only allow transfer once unlocked
// Once it is unlocked, it is unlocked forever and no one can lock again
require(unlocked);
//standard function transfer similar to ERC20 transfer with no _data
//added due to backwards compatibility reasons
bytes memory empty;
if (isContract(_to)) {
return transferToContract(_to, _value, empty);
} else {
return transferToAddress(_to, _value, empty);
}
}
// assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) private returns (bool is_contract) {
uint length;
assembly {
//retrieve the size of the code on target address, this needs assembly
length := extcodesize(_addr)
}
return (length > 0);
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) {
revert();
}
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private returns (bool success) {
if (balanceOf(msg.sender) < _value) {
revert();
}
balances[msg.sender] = safeSub(balanceOf(msg.sender), _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
ContractReceiver receiver = ContractReceiver(_to);
receiver.tokenFallback(msg.sender, _value, _data);
Transfer(msg.sender, _to, _value, _data);
return true;
}
// Get balance of the address provided
function balanceOf(address _owner) constant public returns (uint256 balance) {
return balances[_owner];
}
// Creator/Owner can unlocked it once and it can never be locked again
// Use after airdrop is complete
function unlockForever() onlyOwner public {
unlocked = true;
}
// Allow transfers if the owner provided an allowance
// Prevent from any transfers if token is not yet unlocked
// Use SafeMath for the main logic
function transferFrom(address _from, address _to, uint256 _value) public returns (bool success) {
// Only allow transfer once unlocked
// Once it is unlocked, it is unlocked forever and no one can lock again
require(unlocked);
// Protect against wrapping uints.
require(balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]);
uint256 allowance = allowed[_from][msg.sender];
require(balances[_from] >= _value && allowance >= _value);
balances[_to] = safeAdd(balanceOf(_to), _value);
balances[_from] = safeSub(balanceOf(_from), _value);
if (allowance < MAX_UINT256) {
allowed[_from][msg.sender] = safeSub(allowed[_from][msg.sender], _value);
}
Transfer(_from, _to, _value);
return true;
}
function approve(address _spender, uint256 _value) public returns (bool success) {
// Only allow transfer once unlocked
// Once it is unlocked, it is unlocked forever and no one can lock again
require(unlocked);
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) view external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
/**
* @dev Transfer token for a specified address
* @param _to The address to transfer to.
* @param _value The amount to be transferred.
*/
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[msg.sender]);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}
/**
* @dev Transfer tokens from one address to another
* @param _from address The address which you want to send tokens from
* @param _to address The address which you want to transfer to
* @param _value uint256 the amount of tokens to be transferred
*/
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
function balanceOf(address _owner) view external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
require(_value <= balances[msg.sender]);
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
return allowed[_owner][_spender];
}
/**
* @dev Increase the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To increment
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _addedValue The amount of tokens to increase the allowance by.
*/
function increaseApproval(address _spender, uint256 _addedValue) whenNotPaused public returns (bool)
{
allowed[msg.sender][_spender] = (allowed[msg.sender][_spender].add(_addedValue));
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/**
* @dev Decrease the amount of tokens that an owner allowed to a spender.
* approve should be called when allowed[_spender] == 0. To decrement
* allowed value is better to use this function to avoid 2 calls (and wait until
* the first transaction is mined)
* From MonolithDAO Token.sol
* @param _spender The address which will spend the funds.
* @param _subtractedValue The amount of tokens to decrease the allowance by.
*/
function decreaseApproval(address _spender,uint256 _subtractedValue) whenNotPaused public returns (bool)
{
uint256 oldValue = allowed[msg.sender][_spender];
if (_subtractedValue > oldValue) {
allowed[msg.sender][_spender] = 0;
} else {
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
}
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) public balances;
mapping (address => mapping (address => uint256)) public allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract GFT is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
constructor(
) public{
fulltoken = 1500000000;
decimals = 3; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "GFT"; // Set the name for display purposes
symbol = "GFT"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() public view returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
require(address(this).balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] >= _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
+pragma solidity 0.4.24;
+/**
+ * @title SafeMath
+ * @dev Math operations with safety checks that throw on error
+ */
+library SafeMath {
+ function mul(uint256 a, uint256 b) internal pure returns (uint256) {
+ if (a == 0) {
+ return 0;
+ }
+ uint256 c = a * b;
+ assert(c / a == b);
+ return c;
+ }
+
+ function div(uint256 a, uint256 b) internal pure returns (uint256) {
+ assert(b > 0); // Solidity automatically throws when dividing by 0
+ uint256 c = a / b;
+ assert(a == b * c + a % b); // There is no case in which this doesn't hold
+ return c;
+ }
+
+ function sub(uint256 a, uint256 b) internal pure returns (uint256) {
+ assert(b <= a);
+ return a - b;
+ }
+
+ function add(uint256 a, uint256 b) internal pure returns (uint256) {
+ uint256 c = a + b;
+ assert(c >= a);
+ return c;
+ }
+}
+contract owned {
+ address public owner;
+ event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
+
+ constructor() public {
+ owner = msg.sender;
+ }
+
+ modifier onlyOwner {
+ require(msg.sender == owner);
+ _;
+ }
+
+ function transferOwnership(address newOwner) onlyOwner public {
+ require(newOwner != address(0));
+ emit OwnershipTransferred(owner, newOwner);
+ owner = newOwner;
+ }
+}
+
+contract Pausable is owned {
+ event Pause();
+ event Unpause();
+
+ bool public paused = false;
+
+ /**
+ * @dev Modifier to make a function callable only when the contract is not paused.
+ */
+ modifier whenNotPaused() {
+ require(!paused);
+ _;
+ }
+
+ /**
+ * @dev Modifier to make a function callable only when the contract is paused.
+ */
+ modifier whenPaused() {
+ require(paused);
+ _;
+ }
+
+ /**
+ * @dev called by the owner to pause, triggers stopped state
+ */
+ function pause() onlyOwner whenNotPaused public {
+ paused = true;
+ emit Pause();
+ }
+
+ /**
+ * @dev called by the owner to unpause, returns to normal state
+ */
+ function unpause() onlyOwner whenPaused public {
+ paused = false;
+ emit Unpause();
+ }
+}
+
+interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
+interface ERC20Token {
+
+
+
+ /// @param _owner The address from which the balance will be retrieved
+ /// @return The balance
+ function balanceOf(address _owner) view external returns (uint256 balance);
+
+ /// @notice send `_value` token to `_to` from `msg.sender`
+ /// @param _to The address of the recipient
+ /// @param _value The amount of token to be transferred
+ /// @return Whether the transfer was successful or not
+ function transfer(address _to, uint256 _value) external returns (bool success);
+
+ /// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
+ /// @param _from The address of the sender
+ /// @param _to The address of the recipient
+ /// @param _value The amount of token to be transferred
+ /// @return Whether the transfer was successful or not
+ function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
+
+
+
+ event Transfer(address indexed _from, address indexed _to, uint256 _value);
+
+}
+
+
+
+contract StandardToken is ERC20Token, Pausable {
+ using SafeMath for uint;
+
+ /**
+ Mitigation for short address attack
+ */
+ modifier onlyPayloadSize(uint size) {
+ assert(msg.data.length >= size.add(4));
+ _;
+ }
+
+/**
+ * @dev Transfer token for a specified address
+ * @param _to The address to transfer to.
+ * @param _value The amount to be transferred.
+ */
+
+ function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
+ require(_to != address(0));
+ require(_value <= balances[msg.sender]);
+
+ balances[msg.sender] = balances[msg.sender].sub(_value);
+ balances[_to] = balances[_to].add(_value);
+ emit Transfer(msg.sender, _to, _value);
+ return true;
+ }
+ /**
+ * @dev Transfer tokens from one address to another
+ * @param _from address The address which you want to send tokens from
+ * @param _to address The address which you want to transfer to
+ * @param _value uint256 the amount of tokens to be transferred
+ */
+ function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
+ require(_to != address(0));
+ require(_value <= balances[_from]);
+ require(_value <= allowed[_from][msg.sender]);
+
+ balances[_from] = balances[_from].sub(_value);
+ balances[_to] = balances[_to].add(_value);
+ allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
+ emit Transfer(_from, _to, _value);
+ return true;
+ }
+
+ function balanceOf(address _owner) view external returns (uint256 balance) {
+ return balances[_owner];
+ }
+
+ /// @notice `msg.sender` approves `_addr` to spend `_value` tokens
+ /// @param _spender The address of the account able to transfer the tokens
+ /// @param _value The amount of wei to be approved for transfer
+ /// @return Whether the approval was successful or not
+ function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
+ require((_value == 0) || (allowed[msg.sender][_spender] == 0));
+ require(_value <= balances[msg.sender]);
+ allowed[msg.sender][_spender] = _value;
+ emit Approval(msg.sender, _spender, _value);
+ return true;
+ }
+
+
+
+ /// @param _owner The address of the account owning tokens
+ /// @param _spender The address of the account able to transfer the tokens
+ /// @return Amount of remaining tokens allowed to spent
+ function allowance(address _owner, address _spender) public view returns (uint256 remaining) {
+ return allowed[_owner][_spender];
+ }
+
+ /**
+ * @dev Increase the amount of tokens that an owner allowed to a spender.
+ * approve should be called when allowed[_spender] == 0. To increment
+ * allowed value is better to use this function to avoid 2 calls (and wait until
+ * the first transaction is mined)
+ * From MonolithDAO Token.sol
+ * @param _spender The address which will spend the funds.
+ * @param _addedValue The amount of tokens to increase the allowance by.
+ */
+ function increaseApproval(address _spender, uint256 _addedValue) whenNotPaused public returns (bool)
+ {
+ allowed[msg.sender][_spender] = (allowed[msg.sender][_spender].add(_addedValue));
+ emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
+ return true;
+ }
+
+ /**
+ * @dev Decrease the amount of tokens that an owner allowed to a spender.
+ * approve should be called when allowed[_spender] == 0. To decrement
+ * allowed value is better to use this function to avoid 2 calls (and wait until
+ * the first transaction is mined)
+ * From MonolithDAO Token.sol
+ * @param _spender The address which will spend the funds.
+ * @param _subtractedValue The amount of tokens to decrease the allowance by.
+ */
+ function decreaseApproval(address _spender,uint256 _subtractedValue) whenNotPaused public returns (bool)
+ {
+ uint256 oldValue = allowed[msg.sender][_spender];
+ if (_subtractedValue > oldValue) {
+ allowed[msg.sender][_spender] = 0;
+ } else {
+ allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
+ }
+ emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
+ return true;
+ }
+
+ event Approval(address indexed _owner, address indexed _spender, uint256 _value);
+ mapping (address => uint256) public balances;
+ mapping (address => mapping (address => uint256)) public allowed;
+ uint256 public _totalSupply;
+}
+
+
+//The Contract Name
+contract GFT is StandardToken{
+ using SafeMath for uint;
+
+
+ /* Public variables of the token */
+
+ /*
+ NOTE:
+ The following variables are OPTIONAL vanities. One does not have to include them.
+ They allow one to customise the token contract & in no way influences the core functionality.
+ Some wallets/interfaces might not even bother to look at this information.
+ */
+ string public name; //fancy name: eg Simon Bucks
+ uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
+ string public symbol; //An identifier: eg SBX
+ string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
+ uint256 private fulltoken;
+ // This notifies clients about the amount burnt
+ event Burn(address indexed from, uint256 value);
+
+//
+// CHANGE THESE VALUES FOR YOUR TOKEN
+//
+
+//make sure this function name matches the contract name above. ERC20Token
+
+ constructor(
+ ) public{
+ fulltoken = 1500000000;
+ decimals = 3; // Amount of decimals for display purposes
+ _totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
+ balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
+ name = "GFT"; // Set the name for display purposes
+ symbol = "GFT"; // Set the symbol for display purposes
+ }
+ function() public {
+ //not payable fallback function
+ revert();
+ }
+ /**
+ * Set allowance for other address and notify
+ *
+ * Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
+ *
+ * @param _spender The address authorized to spend
+ * @param _value the max amount they can spend
+ * @param _extraData some extra information to send to the approved contract
+ */
+ function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
+ tokenRecipient spender = tokenRecipient(_spender);
+ if (approve(_spender, _value)) {
+ spender.receiveApproval(msg.sender, _value, this, _extraData);
+ return true;
+ }
+ }
+
+ /// @return total amount of tokens
+ function totalSupply() public view returns (uint256 supply){
+
+ return _totalSupply;
+ }
+
+ /**
+ * Destroy tokens
+ *
+ * Remove `_value` tokens from the system irreversibly
+ *
+ * @param _value the amount of money to burn
+ */
+ function burn(uint256 _value) onlyOwner public returns (bool success) {
+ require(balances[msg.sender] >= _value); // Check if the sender has enough
+ balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
+ _totalSupply = _totalSupply.sub(_value); // Updates totalSupply
+ emit Burn(msg.sender, _value);
+ emit Transfer(msg.sender, address(0), _value);
+ return true;
+ }
+
+ /**
+ * Destroy tokens from other account
+ *
+ * Remove `_value` tokens from the system irreversibly on behalf of `_from`.
+ *
+ * @param _from the address of the sender
+ * @param _value the amount of money to burn
+ */
+ function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
+ require(balances[_from] >= _value); // Check if the targeted balance is enough
+ require(_value <= allowed[_from][msg.sender]); // Check allowance
+ balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
+ allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
+ _totalSupply = _totalSupply.sub(_value); // Update totalSupply
+ emit Burn(_from, _value);
+ emit Transfer(_from, address(0), _value);
+ return true;
+ }
+ function onlyPayForFuel() public payable onlyOwner{
+ // Owner will pay in contract to bear the gas price if transactions made from contract
+
+ }
+ function withdrawEtherFromcontract(uint _amountInwei) public onlyOwner{
+ require(address(this).balance > _amountInwei);
+ require(msg.sender == owner);
+ owner.transfer(_amountInwei);
+
+ }
+ function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
+ require(balances[this] >= _amountOfTokens);
+ require(msg.sender == owner);
+ balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
+ balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
+ emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
+
+ }
+
+}
pragma solidity 0.4.24;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
constructor() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner , "Unauthorized Access");
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface ERC223Interface {
function balanceOf(address who) constant external returns (uint);
function transfer(address to, uint value) external returns (bool success); //erc20 compatible
function transfer(address to, uint value, bytes data) external returns (bool success);
event Transfer(address indexed from, address indexed to, uint value, bytes data);
event Transfer(address indexed _from, address indexed _to, uint256 _value); //erc20 compatible
}
/**
* @title Contract that will work with ERC223 tokens.
*/
contract ERC223ReceivingContract {
/**
* @dev Standard ERC223 function that will handle incoming token transfers.
*
* @param _from Token sender address.
* @param _value Amount of tokens.
* @param _data Transaction metadata.
*/
function tokenFallback(address _from, uint _value, bytes _data) external;
}
/**
* @title Reference implementation of the ERC223 standard token.
*/
contract ERC223Token is ERC223Interface, Pausable {
using SafeMath for uint;
uint256 public _CAP;
mapping(address => uint256) balances; // List of user balances.
/**
* @dev Transfer the specified amount of tokens to the specified address.
* Invokes the `tokenFallback` function if the recipient is a contract.
* The token transfer fails if the recipient is a contract
* but does not implement the `tokenFallback` function
* or the fallback function to receive funds.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
* @param _data Transaction metadata.
*/
function transfer(address _to, uint _value, bytes _data) whenNotPaused external returns (bool success){
// Standard function transfer similar to ERC20 transfer with no _data .
// Added due to backwards compatibility reasons .
require(balances[msg.sender] >= _value && _value > 0);
if(isContract(_to)){
return transferToContract(_to, _value, _data);
}
else
{
return transferToAddress(_to, _value, _data);
}
}
/**
* @dev Transfer the specified amount of tokens to the specified address.
* This function works the same with the previous one
* but doesn't contain `_data` param.
* Added due to backwards compatibility reasons.
*
* @param _to Receiver address.
* @param _value Amount of tokens that will be transferred.
*/
function transfer(address _to, uint _value) whenNotPaused external returns (bool success){
require(balances[msg.sender] >= _value && _value > 0);
bytes memory empty;
if(isContract(_to)){
return transferToContract(_to, _value, empty);
}
else
{
return transferToAddress(_to, _value, empty);
}
//emit Transfer(msg.sender, _to, _value, empty);
}
//assemble the given address bytecode. If bytecode exists then the _addr is a contract.
function isContract(address _addr) internal view returns (bool is_contract) {
// retrieve the size of the code on target address, this needs assembly
uint length;
assembly { length := extcodesize(_addr) }
if (length > 0)
return true;
else
return false;
}
// function that is called when transaction target is an address
function transferToAddress(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
// function that is called when transaction target is a contract
function transferToContract(address _to, uint _value, bytes _data) private whenNotPaused returns (bool success) {
require(_to != address(0));
require(balances[msg.sender] >= _value && _value > 0);
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
ERC223ReceivingContract receiver = ERC223ReceivingContract(_to);
receiver.tokenFallback(msg.sender, _value, _data);
emit Transfer(msg.sender, _to, _value);
emit Transfer(msg.sender, _to, _value, _data);
return true;
}
/**
* @dev Returns balance of the `_owner`.
*
* @param _owner The address whose balance will be returned.
* @return balance Balance of the `_owner`.
*/
function balanceOf(address _owner) constant external returns (uint balance) {
return balances[_owner];
}
}
contract ERC20BackedERC223 is ERC223Token{
modifier onlyPayloadSize(uint size) {
assert(msg.data.length >= size.add(4));
_;
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(3 * 32) whenNotPaused external returns (bool success) {
require(_to != address(0));
require(_value <= balances[_from]);
require(_value <= allowed[_from][msg.sender]);
balances[_from] = balances[_from].sub(_value);
balances[_to] = balances[_to].add(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((balances[msg.sender] >= _value) && ((_value == 0) || (allowed[msg.sender][_spender] == 0)));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
function disApprove(address _spender) whenNotPaused public returns (bool success)
{
allowed[msg.sender][_spender] = 0;
assert(allowed[msg.sender][_spender] == 0);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function increaseApproval(address _spender, uint _addedValue) whenNotPaused public returns (bool success) {
require(balances[msg.sender] >= allowed[msg.sender][_spender].add(_addedValue), "Callers balance not enough");
allowed[msg.sender][_spender] = allowed[msg.sender][_spender].add(_addedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
function decreaseApproval(address _spender, uint _subtractedValue) whenNotPaused public returns (bool success) {
uint oldValue = allowed[msg.sender][_spender];
require((_subtractedValue != 0) && (oldValue > _subtractedValue) , "The amount to be decreased is incorrect");
allowed[msg.sender][_spender] = oldValue.sub(_subtractedValue);
emit Approval(msg.sender, _spender, allowed[msg.sender][_spender]);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => mapping (address => uint256)) allowed;
}
contract burnableERC223 is ERC20BackedERC223{
// This notifies clients about the amount burnt
uint256 public _totalBurnedTokens = 0;
event Burn(address indexed from, uint256 value);
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value, "Sender doesn't have enough balance"); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_CAP = _CAP.sub(_value); // Updates totalSupply
_totalBurnedTokens = _totalBurnedTokens.add(_value);
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value , "target balance is not enough"); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_CAP = _CAP.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
}
contract mintableERC223 is burnableERC223{
uint256 public _totalMinedSupply;
uint256 public _initialSupply;
event Mint(address indexed to, uint256 amount);
event MintFinished();
bool public mintingFinished = false;
modifier canMint() {
require(!mintingFinished);
_;
}
/**
* @dev Function to mint tokens
* @param _to The address that will receive the minted tokens.
* @param _amount The amount of tokens to mint.
* @return A boolean that indicates if the operation was successful.
*/
function mint(address _to, uint256 _amount) onlyOwner canMint public returns (bool) {
bytes memory empty;
uint256 availableMinedSupply;
availableMinedSupply = (_totalMinedSupply.sub(_totalBurnedTokens)).add(_amount);
require(_CAP >= availableMinedSupply , "All tokens minted, Cap reached");
_totalMinedSupply = _totalMinedSupply.add(_amount);
if(_CAP <= _totalMinedSupply.sub(_totalBurnedTokens))
mintingFinished = true;
balances[_to] = balances[_to].add(_amount);
emit Mint(_to, _amount);
emit Transfer(address(0), _to, _amount);
emit Transfer(address(0), _to, _amount, empty);
return true;
}
/**
* @dev Function to stop minting new tokens.
* @return True if the operation was successful.
*/
function finishMinting() onlyOwner canMint public returns (bool) {
mintingFinished = true;
emit MintFinished();
return true;
}
/// @return total amount of tokens
function maximumSupply() public view returns (uint256 supply){
return _CAP;
}
/// @return total amount of tokens
function totalMinedSupply() public view returns (uint256 supply){
return _totalMinedSupply;
}
/// @return total amount of tokens
function preMinedSupply() public view returns (uint256 supply){
return _initialSupply;
}
function totalBurnedTokens() public view returns (uint256 supply){
return _totalBurnedTokens;
}
function totalSupply() public view returns (uint256 supply){
return _totalMinedSupply.sub(_totalBurnedTokens);
}
}
contract CyBitInternal is mintableERC223{
/* Public variables of the token */
/*
NOTE:
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //Name Of Token
uint256 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version; //An Arbitrary versioning scheme.
uint256 private totalsupply;
constructor() public
{
decimals = 8;
name = "CyBit-Internal-Token"; // Set the name for display purposes
symbol = "iCBT"; // Set the symbol for display purposes
version = "V1.0"; //Version.
totalsupply = 5000000000; //Total Tokens
_CAP = totalsupply.mul(10 ** decimals);
_initialSupply = totalsupply.mul(10 ** decimals);
_totalMinedSupply = _initialSupply;
balances[msg.sender] = _initialSupply;
}
function() public {
//not payable fallback function
revert();
}
/* Get the contract constant _name */
function version() public view returns (string _v) {
return version;
}
function name() public view returns (string _name) {
return name;
}
/* Get the contract constant _symbol */
function symbol() public view returns (string _symbol) {
return symbol;
}
/* Get the contract constant _decimals */
function decimals() public view returns (uint256 _decimals) {
return decimals;
}
}
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
emit OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
contract Pausable is owned {
event Pause();
event Unpause();
bool public paused = false;
/**
* @dev Modifier to make a function callable only when the contract is not paused.
*/
modifier whenNotPaused() {
require(!paused);
_;
}
/**
* @dev Modifier to make a function callable only when the contract is paused.
*/
modifier whenPaused() {
require(paused);
_;
}
/**
* @dev called by the owner to pause, triggers stopped state
*/
function pause() onlyOwner whenNotPaused public {
paused = true;
emit Pause();
}
/**
* @dev called by the owner to unpause, returns to normal state
*/
function unpause() onlyOwner whenPaused public {
paused = false;
emit Unpause();
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
}
contract StandardToken is ERC20Token, Pausable {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) whenNotPaused external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
emit Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) whenNotPaused public returns (bool success) {
require((_value == 0) || (allowed[msg.sender][_spender] == 0));
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant public returns (uint256 remaining) {
return allowed[_owner][_spender];
}
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
//The Contract Name
contract zelitex is StandardToken{
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //fancy name: eg Simon Bucks
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//
// CHANGE THESE VALUES FOR YOUR TOKEN
//
//make sure this function name matches the contract name above. ERC20Token
function zelitex(
) public{
fulltoken = 100000000;
decimals = 2; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "Zelitex"; // Set the name for display purposes
symbol = "ZLX"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
emit Burn(msg.sender, _value);
emit Transfer(msg.sender, address(0), _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
emit Burn(_from, _value);
emit Transfer(_from, address(0), _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountineth) public onlyOwner{
uint _amountInwei = _amountineth.mul(10 ** 18);
require(balances[this] > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] > _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
emit Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
pragma solidity ^0.4.18;
/**
* @title SafeMath
* @dev Math operations with safety checks that throw on error
*/
library SafeMath {
function mul(uint256 a, uint256 b) internal pure returns (uint256) {
if (a == 0) {
return 0;
}
uint256 c = a * b;
assert(c / a == b);
return c;
}
function div(uint256 a, uint256 b) internal pure returns (uint256) {
// assert(b > 0); // Solidity automatically throws when dividing by 0
uint256 c = a / b;
// assert(a == b * c + a % b); // There is no case in which this doesn't hold
return c;
}
function sub(uint256 a, uint256 b) internal pure returns (uint256) {
assert(b <= a);
return a - b;
}
function add(uint256 a, uint256 b) internal pure returns (uint256) {
uint256 c = a + b;
assert(c >= a);
return c;
}
}
contract owned {
address public owner;
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
function owned() public {
owner = msg.sender;
}
modifier onlyOwner {
require(msg.sender == owner);
_;
}
function transferOwnership(address newOwner) onlyOwner public {
require(newOwner != address(0));
OwnershipTransferred(owner, newOwner);
owner = newOwner;
}
}
interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) external; }
interface ERC20Token {
/// @param _owner The address from which the balance will be retrieved
/// @return The balance
function balanceOf(address _owner) constant external returns (uint256 balance);
/// @notice send `_value` token to `_to` from `msg.sender`
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transfer(address _to, uint256 _value) external returns (bool success);
/// @notice send `_value` token to `_to` from `_from` on the condition it is approved by `_from`
/// @param _from The address of the sender
/// @param _to The address of the recipient
/// @param _value The amount of token to be transferred
/// @return Whether the transfer was successful or not
function transferFrom(address _from, address _to, uint256 _value) external returns (bool success);
/// @param _owner The address of the account owning tokens
/// @param _spender The address of the account able to transfer the tokens
/// @return Amount of remaining tokens allowed to spent
function allowance(address _owner, address _spender) constant external returns (uint256 remaining);
event Transfer(address indexed _from, address indexed _to, uint256 _value);
event Approval(address indexed _owner, address indexed _spender, uint256 _value);
}
contract StandardToken is ERC20Token {
using SafeMath for uint;
modifier onlyPayloadSize(uint size) {
assert(msg.data.length == size.add(4));
_;
}
function transfer(address _to, uint256 _value) onlyPayloadSize(2 * 32) external returns (bool success) {
//Default assumes totalSupply can't be over max (2^256 - 1).
//If your token leaves out totalSupply and can issue more tokens as time goes on, you need to check if it doesn't wrap.
//Replace the if with this one instead.
//if (balances[msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[msg.sender] >= _value && _value > 0) {
balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
Transfer(msg.sender, _to, _value);
return true;
} else { return false; }
}
function transferFrom(address _from, address _to, uint256 _value) onlyPayloadSize(2 * 32) external returns (bool success) {
//same as above. Replace this line with the following if you want to protect against wrapping uints.
//if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && balances[_to] + _value > balances[_to]) {
if (balances[_from] >= _value && allowed[_from][msg.sender] >= _value && _value > 0) {
balances[_to] = balances[_to].add(_value);
balances[_from] = balances[_from].sub(_value);
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value);
Transfer(_from, _to, _value);
return true;
} else { return false; }
}
function balanceOf(address _owner) constant external returns (uint256 balance) {
return balances[_owner];
}
/// @notice `msg.sender` approves `_addr` to spend `_value` tokens
/// @param _spender The address of the account able to transfer the tokens
/// @param _value The amount of wei to be approved for transfer
/// @return Whether the approval was successful or not
function approve(address _spender, uint256 _value) public returns (bool success) {
allowed[msg.sender][_spender] = _value;
Approval(msg.sender, _spender, _value);
return true;
}
function allowance(address _owner, address _spender) constant external returns (uint256 remaining) {
return allowed[_owner][_spender];
}
mapping (address => uint256) balances;
mapping (address => mapping (address => uint256)) allowed;
uint256 public _totalSupply;
}
//Main Contract
contract Zelitex is StandardToken, owned {
using SafeMath for uint;
/* Public variables of the token */
/*
NOTE:
The following variables are OPTIONAL vanities. One does not have to include them.
They allow one to customise the token contract & in no way influences the core functionality.
Some wallets/interfaces might not even bother to look at this information.
*/
string public name; //NAME
uint8 public decimals; //How many decimals to show. ie. There could 1000 base units with 3 decimals. Meaning 0.980 SBX = 980 base units. It's like comparing 1 wei to 1 ether.
string public symbol; //An identifier: eg SBX
string public version = 'V1.0'; //Version 0.1 standard. Just an arbitrary versioning scheme.
uint256 private fulltoken;
// This notifies clients about the amount burnt
event Burn(address indexed from, uint256 value);
//constructor
function Zelitex(
) public{
fulltoken = 100000000 ;
decimals = 2; // Amount of decimals for display purposes
_totalSupply = fulltoken.mul(10 ** uint256(decimals)); // Update total supply (100000 for example)
balances[msg.sender] = _totalSupply; // Give the creator all initial tokens (100000 for example)
name = "Zelitex"; // Set the name for display purposes
symbol = "ZLX"; // Set the symbol for display purposes
}
function() public {
//not payable fallback function
revert();
}
/**
* Set allowance for other address and notify
*
* Allows `_spender` to spend no more than `_value` tokens in your behalf, and then ping the contract about it
*
* @param _spender The address authorized to spend
* @param _value the max amount they can spend
* @param _extraData some extra information to send to the approved contract
*/
function approveAndCall(address _spender, uint256 _value, bytes _extraData) public returns (bool success) {
tokenRecipient spender = tokenRecipient(_spender);
if (approve(_spender, _value)) {
spender.receiveApproval(msg.sender, _value, this, _extraData);
return true;
}
}
/// @return total amount of tokens
function totalSupply() constant public returns (uint256 supply){
return _totalSupply;
}
/**
* Destroy tokens
*
* Remove `_value` tokens from the system irreversibly
*
* @param _value the amount of money to burn
*/
function burn(uint256 _value) onlyOwner public returns (bool success) {
require(balances[msg.sender] >= _value); // Check if the sender has enough
balances[msg.sender] = balances[msg.sender].sub(_value); // Subtract from the sender
_totalSupply = _totalSupply.sub(_value); // Updates totalSupply
Burn(msg.sender, _value);
return true;
}
/**
* Destroy tokens from other account
*
* Remove `_value` tokens from the system irreversibly on behalf of `_from`.
*
* @param _from the address of the sender
* @param _value the amount of money to burn
*/
function burnFrom(address _from, uint256 _value) onlyOwner public returns (bool success) {
require(balances[_from] >= _value); // Check if the targeted balance is enough
require(_value <= allowed[_from][msg.sender]); // Check allowance
balances[_from] = balances[_from].sub(_value); // Subtract from the targeted balance
allowed[_from][msg.sender] = allowed[_from][msg.sender].sub(_value); // Subtract from the sender's allowance
_totalSupply = _totalSupply.sub(_value); // Update totalSupply
Burn(_from, _value);
return true;
}
function onlyPayForFuel() public payable onlyOwner{
// Owner will pay in contract to bear the gas price if transactions made from contract
}
function withdrawEtherFromcontract(uint _amountineth) public onlyOwner{
uint _amountInwei = _amountineth.mul(10 ** 18);
require(this.balance > _amountInwei);
require(msg.sender == owner);
owner.transfer(_amountInwei);
}
function withdrawTokensFromContract(uint _amountOfTokens) public onlyOwner{
require(balances[this] > _amountOfTokens);
require(msg.sender == owner);
balances[msg.sender] = balances[msg.sender].add(_amountOfTokens); // adds the amount to owner's balance
balances[this] = balances[this].sub(_amountOfTokens); // subtracts the amount from contract balance
Transfer(this, msg.sender, _amountOfTokens); // execute an event reflecting the change
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment