Skip to content
Permalink
Browse files

Merge branch 'develop'

  • Loading branch information...
piavgh committed Mar 5, 2019
2 parents 7af14cc + 72c254f commit 4af7050aaf1eedccf02fee69305e0ef1e89df041
Showing with 367 additions and 89 deletions.
  1. +0 −3 .env.sample
  2. +7 −59 config/index.js
  3. +0 −9 config/secret.js
  4. +180 −0 contracts/tokens/BTC.sol
  5. +180 −0 contracts/tokens/USDT.sol
  6. +0 −18 truffle.js
@@ -1,5 +1,2 @@
ETHEREUM_MNEMONIC=Your Ethereum mnemonic here
ROPSTEN_MNEMONIC=Your Ropsten mnemonic here
RINKEBY_MNEMONIC=Your Rinkeby mnemonic here
TOMOCHAIN_MNEMONIC=Your Tomochain mainnet mnemonic here
TOMOCHAIN_TESTNET_MNEMONIC=Your Tomochain testnet mnemonic here
@@ -1,37 +1,11 @@
require('dotenv').config()

const NETWORK_ID = {
ETHEREUM: '1',
ROPSTEN: '3',
RINKEBY: '4',
TOMOCHAIN: '88',
TOMOCHAIN_TESTNET: '89',
DEVELOPMENT: '8888',
}

const baseTokens = [
'ETH',
// 'AE',
// 'BAT',
// 'BNB',
// 'GNT',
// 'KNC',
// 'LOOM',
// 'LRC',
// 'MITH',
// 'MKR',
// 'NPXS',
// 'OMG',
// 'PRFT',
// 'REP',
// 'SNT',
// 'WTC',
// 'ZRX',
]

// const quoteTokens = ['WETH', 'DAI', 'TUSD', 'USDC'];
const quoteTokens = []

const rewardAddresses = {
'1': '',
'8888': '0xD3050147F1AC4c552941930C7b27386dE8A710b8',
@@ -41,30 +15,9 @@ let tokenContracts = null
const getTokenContracts = (artifacts, filters) => {
if (tokenContracts === null) {
tokenContracts = [
artifacts.require('../contracts/tokens/BTC.sol'),
artifacts.require('../contracts/tokens/ETH.sol'),
artifacts.require('../contracts/tokens/OMG.sol'),
artifacts.require('../contracts/tokens/BNB.sol'),
artifacts.require('../contracts/tokens/ZRX.sol'),
artifacts.require('../contracts/tokens/AE.sol'),
artifacts.require('../contracts/tokens/TRX.sol'),
artifacts.require('../contracts/tokens/MKR.sol'),
artifacts.require('../contracts/tokens/BAT.sol'),
artifacts.require('../contracts/tokens/REP.sol'),
artifacts.require('../contracts/tokens/BTM.sol'),
artifacts.require('../contracts/tokens/NPXS.sol'),
artifacts.require('../contracts/tokens/WTC.sol'),
artifacts.require('../contracts/tokens/KCS.sol'),
artifacts.require('../contracts/tokens/GNT.sol'),
artifacts.require('../contracts/tokens/PPT.sol'),
artifacts.require('../contracts/tokens/SNT.sol'),
artifacts.require('../contracts/tokens/DGX.sol'),
artifacts.require('../contracts/tokens/MITH.sol'),
artifacts.require('../contracts/tokens/AION.sol'),
artifacts.require('../contracts/tokens/LRC.sol'),
artifacts.require('../contracts/tokens/FUN.sol'),
artifacts.require('../contracts/tokens/KNC.sol'),
artifacts.require('../contracts/tokens/LOOM.sol'),
artifacts.require('../contracts/tokens/DAI.sol'),
artifacts.require('../contracts/tokens/USDT.sol'),
]
}
if (!filters) return tokenContracts
@@ -75,16 +28,14 @@ const getTokenContracts = (artifacts, filters) => {

module.exports = {
NETWORK_ID,
quoteTokens,
baseTokens,
tokens: [...baseTokens, ...quoteTokens],
tokens: [
// 'BTC',
'ETH',
// 'USDT',
],
rewardAddresses,
// truffle config
rpcEndpoints: {
ethereum: 'https://mainnet.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
ropsten: 'https://ropsten.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
kovan: 'https://ropsten.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
rinkeby: 'https://rinkeby.infura.io/v3/ebaf1785cc1b4f319e0ff07f26cadae8',
tomochain: 'https://rpc.tomochain.com',
tomochainTestnet: 'https://testnet.tomochain.com',
},
@@ -119,9 +70,6 @@ module.exports = {
'0xF069080F7acB9a6705b4a51F84d9aDc67b921bDF',
'0x657B4CbA193CCac878a3561F36329Facd6D19825',
],
ethereum: [],
ropsten: [],
rinkeby: [],
},
getTokenContracts,
}
@@ -1,13 +1,4 @@
const config = {
ethereum: {
mnemonic: process.env.ETHEREUM_MNEMONIC,
},
ropsten: {
mnemonic: process.env.ROPSTEN_MNEMONIC,
},
rinkeby: {
mnemonic: process.env.RINKEBY_MNEMONIC,
},
tomochain: {
mnemonic: process.env.TOMOCHAIN_MNEMONIC,
},
@@ -0,0 +1,180 @@
pragma solidity ^0.4.18;

import "../utils/SafeMath.sol";
import "../utils/Owned.sol";

/**
* @title Standard ERC20 token
*
* @dev Implementation of the basic standard token.
* @dev https://github.com/ethereum/EIPs/issues/20
* @dev Based on code by FirstBlood: https://github.com/Firstbloodio/token/blob/master/smart_contract/FirstBloodToken.sol
*/
contract BTC is Owned {

using SafeMath for uint256;

event Transfer(address indexed from, address indexed to, uint256 value);
event Approval(address indexed owner, address indexed spender, uint256 value);
event Mint(address indexed to, uint256 amount);
event MintFinished();

mapping (address => mapping (address => uint256)) internal allowed;
mapping(address => uint256) balances;

uint256 totalSupply_;
bool public mintingFinished = false;
string public constant symbol = "BTC";
uint8 public decimals = 8;

constructor(address _to, uint256 _amount) public {
totalSupply_ = totalSupply_.add(_amount);
balances[_to] = balances[_to].add(_amount);
}

/**
* @dev total number of tokens in existence
*/
function totalSupply() public view returns (uint256) {
return totalSupply_;
}

/**
* @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) public returns (bool) {
require(_to != address(0),"Only allow send to other.");
require(_value <= balances[msg.sender], "Insufficient fund");

balances[msg.sender] = balances[msg.sender].sub(_value);
balances[_to] = balances[_to].add(_value);
emit Transfer(msg.sender, _to, _value);
return true;
}

/**
* @dev Gets the balance of the specified address.
* @param _owner The address to query the the balance of.
* @return An uint256 representing the amount owned by the passed address.
*/
function balanceOf(address _owner) public view returns (uint256) {
return balances[_owner];
}


/**
* @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) public returns (bool) {
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;
}

/**
* @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
*
* Beware that changing an allowance with this method brings the risk that someone may use both the old
* and the new allowance by unfortunate transaction ordering. One possible solution to mitigate this
* race condition is to first reduce the spender's allowance to 0 and set the desired value afterwards:
* https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
* @param _spender The address which will spend the funds.
* @param _value The amount of tokens to be spent.
*/
function approve(address _spender, uint256 _value) public returns (bool) {
allowed[msg.sender][_spender] = _value;
emit Approval(msg.sender, _spender, _value);
return true;
}

/**
* @dev Function to check the amount of tokens that an owner allowed to a spender.
* @param _owner address The address which owns the funds.
* @param _spender address The address which will spend the funds.
* @return A uint256 specifying the amount of tokens still available for the spender.
*/
function allowance(address _owner, address _spender) public view returns (uint256) {
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, 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;
}

/**
* @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, 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;
}




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) {
totalSupply_ = totalSupply_.add(_amount);
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;
}

}
Oops, something went wrong.

0 comments on commit 4af7050

Please sign in to comment.
You can’t perform that action at this time.