From 8d3497982d73937f80a225f79c0dd878c1e80f53 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron Rocha" Date: Wed, 16 Oct 2019 17:52:58 -0500 Subject: [PATCH 1/7] First issues updates, two more to be fixed --- DECA_ERC20_0.4.18.sol | 65 ++---- DECA_IERC20_0.4.18.json | 448 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 469 insertions(+), 44 deletions(-) diff --git a/DECA_ERC20_0.4.18.sol b/DECA_ERC20_0.4.18.sol index 6063b80..5e47401 100644 --- a/DECA_ERC20_0.4.18.sol +++ b/DECA_ERC20_0.4.18.sol @@ -1,4 +1,4 @@ -pragma solidity ^0.4.26; +pragma solidity 0.4.26; // ---------------------------------------------------------------------------- // 'DECA' DEcentralized CArbon tokens - ITDE (initial token distribution event) @@ -16,7 +16,6 @@ pragma solidity ^0.4.26; // fork and modifications to fix DECA's ICO needs by p1r0 and kaicudon // ---------------------------------------------------------------------------- - // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- @@ -39,7 +38,6 @@ contract SafeMath { } } - // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md @@ -56,7 +54,6 @@ contract ERC20Interface { event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } - // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call // @@ -66,7 +63,6 @@ contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes data) public; } - // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- @@ -89,9 +85,11 @@ contract Owned { function updateCCDBAddress(string CCDBAddress) public onlyOwner { _CCDBAddress = CCDBAddress; } + function transferOwnership(address _newOwner) public onlyOwner { newOwner = _newOwner; } + function acceptOwnership() public { require(msg.sender == newOwner); emit OwnershipTransferred(owner, newOwner); @@ -100,42 +98,24 @@ contract Owned { } } - // ---------------------------------------------------------------------------- // ERC20 Token, with the addition of symbol, name and decimals and assisted // token transfers // ---------------------------------------------------------------------------- contract DECAToken is ERC20Interface, Owned, SafeMath { - string public symbol; - string public name; - uint8 public decimals; + string public symbol = "DECA"; + string public name = "DEcentralized CArbon tokens"; + uint8 public decimals = 18; uint public _totalSupply; - uint public startDate; - uint public preICOEnds; - uint public bonus1Ends; - uint public bonus2Ends; - uint public endDate; + //for testing change weeks for hours... + uint public preICOEnds = now + 1 hours; + uint public bonus1Ends = now + 3 hours; + uint public bonus2Ends = now + 6 hours; + uint public endDate = now + 11 hours; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; - - // ------------------------------------------------------------------------ - // Constructor - // ------------------------------------------------------------------------ - constructor () public { - symbol = "DECA"; - name = "DEcentralized CArbon tokens"; - decimals = 18; - //for testing change weeks for days... - preICOEnds = now + 1 weeks; - bonus1Ends = now + 3 weeks; - bonus2Ends = now + 6 weeks; - endDate = now + 11 weeks; - - } - - // ------------------------------------------------------------------------ // Total supply: Get the total token supply // ------------------------------------------------------------------------ @@ -151,7 +131,6 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { return balances[tokenOwner]; } - // ------------------------------------------------------------------------ // Transfer the balance from token owner's account to `to` account // - Owner's account must have sufficient balance to transfer @@ -164,7 +143,6 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { return true; } - // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account @@ -179,7 +157,6 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { return true; } - // ------------------------------------------------------------------------ // Transfer `tokens` from the `from` account to the `to` account // @@ -197,7 +174,6 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { return true; } - // ------------------------------------------------------------------------ // Returns the amount of tokens approved by the owner that can be // transferred to the spender's account @@ -206,7 +182,6 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { return allowed[tokenOwner][spender]; } - // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account. The `spender` contract function @@ -223,13 +198,13 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { // 1,000 DECA Tokens per 1 ETH // ------------------------------------------------------------------------ function () public payable { - require(now >= startDate && now <= endDate); + require(now <= endDate); uint tokens; uint toOwner; uint toSender; - uint percentage; + uint divBy; - percentage = 2; // percentage that goes to the owner + divBy = 10; // division to get 10% if (now <= preICOEnds) { tokens = msg.value * 2000; @@ -240,17 +215,21 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { } else { tokens = msg.value * 1000; } - toOwner = safeDiv(tokens, percentage); // percentage assigned to the contract owner (DAO) + toOwner = safeDiv(tokens, divBy); // divBy to get the percentage assigned to the contract owner (for exchange to Cabron Credits) toSender = tokens; // tokens goes to sender balances[msg.sender] = safeAdd(balances[msg.sender], toSender); balances[owner] = safeAdd(balances[owner], toOwner); - _totalSupply = safeAdd(_totalSupply, safeAdd(tokens,safeDiv(tokens, percentage))); + _totalSupply = safeAdd(_totalSupply, safeAdd(toSender,toOwner)); emit Transfer(address(0), msg.sender, toSender); emit Transfer(address(0), owner, toOwner); - owner.transfer(msg.value); } - + //Close down the ICO and Claim the Ether. + function getETH() public onlyOwner { + require(now >= endDate ); + // transfer the ETH balance in the contract to the owner + owner.transfer(address(this).balance); + } // ------------------------------------------------------------------------ // Owner can transfer out any accidentally sent ERC20 tokens diff --git a/DECA_IERC20_0.4.18.json b/DECA_IERC20_0.4.18.json index fe810cd..1fd9656 100644 --- a/DECA_IERC20_0.4.18.json +++ b/DECA_IERC20_0.4.18.json @@ -1 +1,447 @@ -[ { "constant": true, "inputs": [], "name": "name", "outputs": [ { "name": "", "type": "string", "value": "Decentralized Carbon tokens" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x06fdde03" }, { "constant": false, "inputs": [ { "name": "spender", "type": "address" }, { "name": "tokens", "type": "uint256" } ], "name": "approve", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0x095ea7b3" }, { "constant": true, "inputs": [], "name": "startDate", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x0b97bc86" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x18160ddd" }, { "constant": false, "inputs": [ { "name": "tokenAddress", "type": "address" }, { "name": "tokens", "type": "uint256" } ], "name": "transferAnyDECAToken", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0x1893e0fb" }, { "constant": false, "inputs": [ { "name": "from", "type": "address" }, { "name": "to", "type": "address" }, { "name": "tokens", "type": "uint256" } ], "name": "transferFrom", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0x23b872dd" }, { "constant": true, "inputs": [], "name": "decimals", "outputs": [ { "name": "", "type": "uint8", "value": "18" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x313ce567" }, { "constant": true, "inputs": [], "name": "_CCDBAddress", "outputs": [ { "name": "", "type": "string", "value": "" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x34dc584d" }, { "constant": true, "inputs": [], "name": "_totalSupply", "outputs": [ { "name": "", "type": "uint256", "value": "0" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x3eaaf86b" }, { "constant": true, "inputs": [ { "name": "tokenOwner", "type": "address" } ], "name": "balanceOf", "outputs": [ { "name": "balance", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x70a08231" }, { "constant": false, "inputs": [], "name": "acceptOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0x79ba5097" }, { "constant": false, "inputs": [ { "name": "CCDBAddress", "type": "string" } ], "name": "updateCCDBAddress", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0x7a26788e" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [ { "name": "", "type": "address", "value": "0xA18e00831aeE32FE3182E814A183881FCEFB2eD0" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x8da5cb5b" }, { "constant": true, "inputs": [], "name": "symbol", "outputs": [ { "name": "", "type": "string", "value": "DECA" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0x95d89b41" }, { "constant": false, "inputs": [ { "name": "to", "type": "address" }, { "name": "tokens", "type": "uint256" } ], "name": "transfer", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0xa9059cbb" }, { "constant": true, "inputs": [], "name": "endDate", "outputs": [ { "name": "", "type": "uint256", "value": "1567276288" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0xc24a0f8b" }, { "constant": false, "inputs": [ { "name": "spender", "type": "address" }, { "name": "tokens", "type": "uint256" }, { "name": "data", "type": "bytes" } ], "name": "approveAndCall", "outputs": [ { "name": "success", "type": "bool" } ], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0xcae9ca51" }, { "constant": true, "inputs": [], "name": "newOwner", "outputs": [ { "name": "", "type": "address", "value": "0x0000000000000000000000000000000000000000" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0xd4ee1d90" }, { "constant": true, "inputs": [ { "name": "tokenOwner", "type": "address" }, { "name": "spender", "type": "address" } ], "name": "allowance", "outputs": [ { "name": "remaining", "type": "uint256" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0xdd62ed3e" }, { "constant": true, "inputs": [], "name": "bonus1Ends", "outputs": [ { "name": "", "type": "uint256", "value": "1566585088" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0xe8294aad" }, { "constant": true, "inputs": [], "name": "bonus2Ends", "outputs": [ { "name": "", "type": "uint256", "value": "1566844288" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0xef0b44db" }, { "constant": false, "inputs": [ { "name": "_newOwner", "type": "address" } ], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function", "signature": "0xf2fde38b" }, { "constant": true, "inputs": [], "name": "preICOEnds", "outputs": [ { "name": "", "type": "uint256", "value": "1566412288" } ], "payable": false, "stateMutability": "view", "type": "function", "signature": "0xfc5fc8ae" }, { "inputs": [], "payable": false, "stateMutability": "nonpayable", "type": "constructor", "signature": "constructor" }, { "payable": true, "stateMutability": "payable", "type": "fallback" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "_from", "type": "address" }, { "indexed": true, "name": "_to", "type": "address" } ], "name": "OwnershipTransferred", "type": "event", "signature": "0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "from", "type": "address" }, { "indexed": true, "name": "to", "type": "address" }, { "indexed": false, "name": "tokens", "type": "uint256" } ], "name": "Transfer", "type": "event", "signature": "0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef" }, { "anonymous": false, "inputs": [ { "indexed": true, "name": "tokenOwner", "type": "address" }, { "indexed": true, "name": "spender", "type": "address" }, { "indexed": false, "name": "tokens", "type": "uint256" } ], "name": "Approval", "type": "event", "signature": "0x8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925" } ] +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "getETH", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "from", + "type": "address" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "_CCDBAddress", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "_totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "tokenOwner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "CCDBAddress", + "type": "string" + } + ], + "name": "updateCCDBAddress", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "to", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "endDate", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + }, + { + "name": "data", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "newOwner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "tokenAddress", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "transferAnyERC20Token", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "tokenOwner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "remaining", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "bonus1Ends", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "bonus2Ends", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "preICOEnds", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "name": "_to", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "tokens", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "tokenOwner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "tokens", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + } +] From d71d0e3c4c4ec535c6899cff98bfed80f7ce2e83 Mon Sep 17 00:00:00 2001 From: Oscar Martinez Date: Wed, 16 Oct 2019 21:54:38 -0500 Subject: [PATCH 2/7] Fix allowance double spend exploit, testing is missing --- DECA_ERC20_0.4.26.sol | 268 ++++++++++++++++++++++++++++++++++++++++ DECA_IERC20_0.4.18.json | 2 +- 2 files changed, 269 insertions(+), 1 deletion(-) create mode 100644 DECA_ERC20_0.4.26.sol diff --git a/DECA_ERC20_0.4.26.sol b/DECA_ERC20_0.4.26.sol new file mode 100644 index 0000000..dda4528 --- /dev/null +++ b/DECA_ERC20_0.4.26.sol @@ -0,0 +1,268 @@ +pragma solidity 0.4.26; + +// ---------------------------------------------------------------------------- +// 'DECA' DEcentralized CArbon tokens - ITDE (initial token distribution event) +// +// Deployed to : 0xD9497a4ee4D9E6E73EC1126D2f7827DEA8A51154 +// Network : Ropsten +// Symbol : DECA +// Name : Decentralized Carbon tokens +// Total supply: Gazillion +// Decimals : 18 +// +// Enjoy. +// +// (c) by Moritz Neto & Daniel Bar with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. +// fork and modifications to fix DECA's ICO needs by p1r0 and kaicudon +// ---------------------------------------------------------------------------- + +// ---------------------------------------------------------------------------- +// Safe maths +// ---------------------------------------------------------------------------- +contract SafeMath { + function safeAdd(uint a, uint b) internal pure returns (uint c) { + c = a + b; + require(c >= a); + } + function safeSub(uint a, uint b) internal pure returns (uint c) { + require(b <= a); + c = a - b; + } + function safeMul(uint a, uint b) internal pure returns (uint c) { + c = a * b; + require(a == 0 || c / a == b); + } + function safeDiv(uint a, uint b) internal pure returns (uint c) { + require(b > 0); + c = a / b; + } +} + +// ---------------------------------------------------------------------------- +// ERC Token Standard #20 Interface +// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md +// ---------------------------------------------------------------------------- +contract ERC20Interface { + function totalSupply() public constant returns (uint); + function balanceOf(address tokenOwner) public constant returns (uint balance); + function allowance(address tokenOwner, address spender) public constant returns (uint remaining); + function transfer(address to, uint tokens) public returns (bool success); + function approve(address spender, uint tokens) public returns (bool success); + function transferFrom(address from, address to, uint tokens) public returns (bool success); + + event Transfer(address indexed from, address indexed to, uint tokens); + event Approval(address indexed tokenOwner, address indexed spender, uint tokens); +} + +// ---------------------------------------------------------------------------- +// Contract function to receive approval and execute function in one call +// +// Borrowed from MiniMeToken +// ---------------------------------------------------------------------------- +contract ApproveAndCallFallBack { + function receiveApproval(address from, uint256 tokens, address token, bytes data) public; +} + +// ---------------------------------------------------------------------------- +// Owned contract +// ---------------------------------------------------------------------------- +contract Owned { + address public owner; + address public newOwner; + string public _CCDBAddress; + + event OwnershipTransferred(address indexed _from, address indexed _to); + + constructor () public { + owner = msg.sender; + } + + modifier onlyOwner { + require(msg.sender == owner); + _; + } + + function updateCCDBAddress(string CCDBAddress) public onlyOwner { + _CCDBAddress = CCDBAddress; + } + + function transferOwnership(address _newOwner) public onlyOwner { + newOwner = _newOwner; + } + + function acceptOwnership() public { + require(msg.sender == newOwner); + emit OwnershipTransferred(owner, newOwner); + owner = newOwner; + newOwner = address(0); + } +} + +// ---------------------------------------------------------------------------- +// ERC20 Token, with the addition of symbol, name and decimals and assisted +// token transfers +// ---------------------------------------------------------------------------- +contract DECAToken is ERC20Interface, Owned, SafeMath { + string public symbol = "DECA"; + string public name = "DEcentralized CArbon tokens"; + uint8 public decimals = 18; + uint public _totalSupply; + //for testing change weeks for hours... + uint public preICOEnds = now + 1 hours; + uint public bonus1Ends = now + 3 hours; + uint public bonus2Ends = now + 6 hours; + uint public endDate = now + 11 hours; + + mapping(address => uint) balances; + mapping(address => mapping(address => uint)) allowed; + + // ------------------------------------------------------------------------ + // Total supply: Get the total token supply + // ------------------------------------------------------------------------ + + function totalSupply() public constant returns (uint) { + return _totalSupply - balances[address(0)]; + } + + // ------------------------------------------------------------------------ + // Get the token balance for account `tokenOwner` + // ------------------------------------------------------------------------ + function balanceOf(address tokenOwner) public constant returns (uint balance) { + return balances[tokenOwner]; + } + + // ------------------------------------------------------------------------ + // Transfer the balance from token owner's account to `to` account + // - Owner's account must have sufficient balance to transfer + // - 0 value transfers are allowed + // ------------------------------------------------------------------------ + function transfer(address to, uint tokens) public returns (bool success) { + balances[msg.sender] = safeSub(balances[msg.sender], tokens); + balances[to] = safeAdd(balances[to], tokens); + emit Transfer(msg.sender, to, tokens); + return true; + } + + // ------------------------------------------------------------------------ + // Token owner can approve for `spender` to transferFrom(...) `tokens` + // from the token owner's account + // + // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md + // recommends that there are no checks for the approval double-spend attack + // as this should be implemented in user interfaces + // ------------------------------------------------------------------------ + function approve(address spender, uint tokens) public returns (bool success) { + // approve should only be called when setting an initial allowance, + // or when resetting it to zero. To increase and decrease it, use + // 'increaseApproval' and 'decreaseApproval' + if (allowed[msg.sender][spender] == 0 || tokens == 0){ + emit Approval(msg.sender, spender, tokens); + return true; + } + return false; + } + + /* + * 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) + */ + function increaseApproval (address spender, uint tokens) public returns (bool success){ + allowed[msg.sender][spender] = safeAdd(allowed[msg.sender][spender], tokens); + emit Approval(msg.sender, spender, allowed[msg.sender][spender]); + return true; + } + + function decreaseApproval (address spender, uint tokens) public returns (bool success) { + uint oldValue = allowed[msg.sender][spender]; + if (tokens > oldValue) { + allowed[msg.sender][spender] = 0; + } + else{ + allowed[msg.sender][spender] = safeSub(oldValue, tokens); + } + emit Approval(msg.sender, spender, allowed[msg.sender][spender]); + return true; + } + + // ------------------------------------------------------------------------ + // Transfer `tokens` from the `from` account to the `to` account + // + // The calling account must already have sufficient tokens approve(...)-d + // for spending from the `from` account and + // - From account must have sufficient balance to transfer + // - Spender must have sufficient allowance to transfer + // - 0 value transfers are allowed + // ------------------------------------------------------------------------ + function transferFrom(address from, address to, uint tokens) public returns (bool success) { + balances[from] = safeSub(balances[from], tokens); + allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); + balances[to] = safeAdd(balances[to], tokens); + emit Transfer(from, to, tokens); + return true; + } + + // ------------------------------------------------------------------------ + // Returns the amount of tokens approved by the owner that can be + // transferred to the spender's account + // ------------------------------------------------------------------------ + function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { + return allowed[tokenOwner][spender]; + } + + // ------------------------------------------------------------------------ + // Token owner can approve for `spender` to transferFrom(...) `tokens` + // from the token owner's account. The `spender` contract function + // `receiveApproval(...)` is then executed + // ------------------------------------------------------------------------ + function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { + allowed[msg.sender][spender] = tokens; + emit Approval(msg.sender, spender, tokens); + ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); + return true; + } + + // ------------------------------------------------------------------------ + // 1,000 DECA Tokens per 1 ETH + // ------------------------------------------------------------------------ + function () public payable { + require(now <= endDate); + uint tokens; + uint toOwner; + uint toSender; + uint divBy; + + divBy = 10; // division to get 10% + + if (now <= preICOEnds) { + tokens = msg.value * 2000; + } else if (now > preICOEnds && now <= bonus1Ends ) { + tokens = msg.value * 1500; + } else if (now > bonus1Ends && now <= bonus2Ends) { + tokens = msg.value * 1250; + } else { + tokens = msg.value * 1000; + } + toOwner = safeDiv(tokens, divBy); // divBy to get the percentage assigned to the contract owner (for exchange to Cabron Credits) + toSender = tokens; // tokens goes to sender + balances[msg.sender] = safeAdd(balances[msg.sender], toSender); + balances[owner] = safeAdd(balances[owner], toOwner); + _totalSupply = safeAdd(_totalSupply, safeAdd(toSender,toOwner)); + emit Transfer(address(0), msg.sender, toSender); + emit Transfer(address(0), owner, toOwner); + } + + //Close down the ICO and Claim the Ether. + function getETH() public onlyOwner { + require(now >= endDate ); + // transfer the ETH balance in the contract to the owner + owner.transfer(address(this).balance); + } + + // ------------------------------------------------------------------------ + // Owner can transfer out any accidentally sent ERC20 tokens + // ------------------------------------------------------------------------ + function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { + return ERC20Interface(tokenAddress).transfer(owner, tokens); + } +} \ No newline at end of file diff --git a/DECA_IERC20_0.4.18.json b/DECA_IERC20_0.4.18.json index 1fd9656..872e710 100644 --- a/DECA_IERC20_0.4.18.json +++ b/DECA_IERC20_0.4.18.json @@ -444,4 +444,4 @@ "name": "Approval", "type": "event" } -] +] \ No newline at end of file From ce76b50a5606775c0d6e6ba45bd5d8705f2902d3 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron Rocha" Date: Thu, 17 Oct 2019 00:33:01 -0500 Subject: [PATCH 3/7] Update the Interface and delete the oldest version, ToDo: update to solidity 0.5.3 --- DECA_ERC20_0.4.18.sol | 240 ------------------ ...C20_0.4.18.json => DECA_IERC20_0.4.26.json | 48 +++- 2 files changed, 47 insertions(+), 241 deletions(-) delete mode 100644 DECA_ERC20_0.4.18.sol rename DECA_IERC20_0.4.18.json => DECA_IERC20_0.4.26.json (90%) diff --git a/DECA_ERC20_0.4.18.sol b/DECA_ERC20_0.4.18.sol deleted file mode 100644 index 5e47401..0000000 --- a/DECA_ERC20_0.4.18.sol +++ /dev/null @@ -1,240 +0,0 @@ -pragma solidity 0.4.26; - -// ---------------------------------------------------------------------------- -// 'DECA' DEcentralized CArbon tokens - ITDE (initial token distribution event) -// -// Deployed to : 0xD9497a4ee4D9E6E73EC1126D2f7827DEA8A51154 -// Network : Ropsten -// Symbol : DECA -// Name : Decentralized Carbon tokens -// Total supply: Gazillion -// Decimals : 18 -// -// Enjoy. -// -// (c) by Moritz Neto & Daniel Bar with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. -// fork and modifications to fix DECA's ICO needs by p1r0 and kaicudon -// ---------------------------------------------------------------------------- - -// ---------------------------------------------------------------------------- -// Safe maths -// ---------------------------------------------------------------------------- -contract SafeMath { - function safeAdd(uint a, uint b) internal pure returns (uint c) { - c = a + b; - require(c >= a); - } - function safeSub(uint a, uint b) internal pure returns (uint c) { - require(b <= a); - c = a - b; - } - function safeMul(uint a, uint b) internal pure returns (uint c) { - c = a * b; - require(a == 0 || c / a == b); - } - function safeDiv(uint a, uint b) internal pure returns (uint c) { - require(b > 0); - c = a / b; - } -} - -// ---------------------------------------------------------------------------- -// ERC Token Standard #20 Interface -// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md -// ---------------------------------------------------------------------------- -contract ERC20Interface { - function totalSupply() public constant returns (uint); - function balanceOf(address tokenOwner) public constant returns (uint balance); - function allowance(address tokenOwner, address spender) public constant returns (uint remaining); - function transfer(address to, uint tokens) public returns (bool success); - function approve(address spender, uint tokens) public returns (bool success); - function transferFrom(address from, address to, uint tokens) public returns (bool success); - - event Transfer(address indexed from, address indexed to, uint tokens); - event Approval(address indexed tokenOwner, address indexed spender, uint tokens); -} - -// ---------------------------------------------------------------------------- -// Contract function to receive approval and execute function in one call -// -// Borrowed from MiniMeToken -// ---------------------------------------------------------------------------- -contract ApproveAndCallFallBack { - function receiveApproval(address from, uint256 tokens, address token, bytes data) public; -} - -// ---------------------------------------------------------------------------- -// Owned contract -// ---------------------------------------------------------------------------- -contract Owned { - address public owner; - address public newOwner; - string public _CCDBAddress; - - event OwnershipTransferred(address indexed _from, address indexed _to); - - constructor () public { - owner = msg.sender; - } - - modifier onlyOwner { - require(msg.sender == owner); - _; - } - - function updateCCDBAddress(string CCDBAddress) public onlyOwner { - _CCDBAddress = CCDBAddress; - } - - function transferOwnership(address _newOwner) public onlyOwner { - newOwner = _newOwner; - } - - function acceptOwnership() public { - require(msg.sender == newOwner); - emit OwnershipTransferred(owner, newOwner); - owner = newOwner; - newOwner = address(0); - } -} - -// ---------------------------------------------------------------------------- -// ERC20 Token, with the addition of symbol, name and decimals and assisted -// token transfers -// ---------------------------------------------------------------------------- -contract DECAToken is ERC20Interface, Owned, SafeMath { - string public symbol = "DECA"; - string public name = "DEcentralized CArbon tokens"; - uint8 public decimals = 18; - uint public _totalSupply; - //for testing change weeks for hours... - uint public preICOEnds = now + 1 hours; - uint public bonus1Ends = now + 3 hours; - uint public bonus2Ends = now + 6 hours; - uint public endDate = now + 11 hours; - - mapping(address => uint) balances; - mapping(address => mapping(address => uint)) allowed; - - // ------------------------------------------------------------------------ - // Total supply: Get the total token supply - // ------------------------------------------------------------------------ - - function totalSupply() public constant returns (uint) { - return _totalSupply - balances[address(0)]; - } - - // ------------------------------------------------------------------------ - // Get the token balance for account `tokenOwner` - // ------------------------------------------------------------------------ - function balanceOf(address tokenOwner) public constant returns (uint balance) { - return balances[tokenOwner]; - } - - // ------------------------------------------------------------------------ - // Transfer the balance from token owner's account to `to` account - // - Owner's account must have sufficient balance to transfer - // - 0 value transfers are allowed - // ------------------------------------------------------------------------ - function transfer(address to, uint tokens) public returns (bool success) { - balances[msg.sender] = safeSub(balances[msg.sender], tokens); - balances[to] = safeAdd(balances[to], tokens); - emit Transfer(msg.sender, to, tokens); - return true; - } - - // ------------------------------------------------------------------------ - // Token owner can approve for `spender` to transferFrom(...) `tokens` - // from the token owner's account - // - // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md - // recommends that there are no checks for the approval double-spend attack - // as this should be implemented in user interfaces - // ------------------------------------------------------------------------ - function approve(address spender, uint tokens) public returns (bool success) { - allowed[msg.sender][spender] = tokens; - emit Approval(msg.sender, spender, tokens); - return true; - } - - // ------------------------------------------------------------------------ - // Transfer `tokens` from the `from` account to the `to` account - // - // The calling account must already have sufficient tokens approve(...)-d - // for spending from the `from` account and - // - From account must have sufficient balance to transfer - // - Spender must have sufficient allowance to transfer - // - 0 value transfers are allowed - // ------------------------------------------------------------------------ - function transferFrom(address from, address to, uint tokens) public returns (bool success) { - balances[from] = safeSub(balances[from], tokens); - allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); - balances[to] = safeAdd(balances[to], tokens); - emit Transfer(from, to, tokens); - return true; - } - - // ------------------------------------------------------------------------ - // Returns the amount of tokens approved by the owner that can be - // transferred to the spender's account - // ------------------------------------------------------------------------ - function allowance(address tokenOwner, address spender) public constant returns (uint remaining) { - return allowed[tokenOwner][spender]; - } - - // ------------------------------------------------------------------------ - // Token owner can approve for `spender` to transferFrom(...) `tokens` - // from the token owner's account. The `spender` contract function - // `receiveApproval(...)` is then executed - // ------------------------------------------------------------------------ - function approveAndCall(address spender, uint tokens, bytes data) public returns (bool success) { - allowed[msg.sender][spender] = tokens; - emit Approval(msg.sender, spender, tokens); - ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, this, data); - return true; - } - - // ------------------------------------------------------------------------ - // 1,000 DECA Tokens per 1 ETH - // ------------------------------------------------------------------------ - function () public payable { - require(now <= endDate); - uint tokens; - uint toOwner; - uint toSender; - uint divBy; - - divBy = 10; // division to get 10% - - if (now <= preICOEnds) { - tokens = msg.value * 2000; - } else if (now > preICOEnds && now <= bonus1Ends ) { - tokens = msg.value * 1500; - } else if (now > bonus1Ends && now <= bonus2Ends) { - tokens = msg.value * 1250; - } else { - tokens = msg.value * 1000; - } - toOwner = safeDiv(tokens, divBy); // divBy to get the percentage assigned to the contract owner (for exchange to Cabron Credits) - toSender = tokens; // tokens goes to sender - balances[msg.sender] = safeAdd(balances[msg.sender], toSender); - balances[owner] = safeAdd(balances[owner], toOwner); - _totalSupply = safeAdd(_totalSupply, safeAdd(toSender,toOwner)); - emit Transfer(address(0), msg.sender, toSender); - emit Transfer(address(0), owner, toOwner); - } - - //Close down the ICO and Claim the Ether. - function getETH() public onlyOwner { - require(now >= endDate ); - // transfer the ETH balance in the contract to the owner - owner.transfer(address(this).balance); - } - - // ------------------------------------------------------------------------ - // Owner can transfer out any accidentally sent ERC20 tokens - // ------------------------------------------------------------------------ - function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { - return ERC20Interface(tokenAddress).transfer(owner, tokens); - } -} diff --git a/DECA_IERC20_0.4.18.json b/DECA_IERC20_0.4.26.json similarity index 90% rename from DECA_IERC20_0.4.18.json rename to DECA_IERC20_0.4.26.json index 872e710..4dadc9c 100644 --- a/DECA_IERC20_0.4.18.json +++ b/DECA_IERC20_0.4.26.json @@ -128,6 +128,29 @@ "stateMutability": "view", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "decreaseApproval", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": true, "inputs": [ @@ -276,6 +299,29 @@ "stateMutability": "view", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "increaseApproval", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": false, "inputs": [ @@ -444,4 +490,4 @@ "name": "Approval", "type": "event" } -] \ No newline at end of file +] From 6d084101433ac02dc13d4c19740af1cdebdf905c Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron Rocha" Date: Thu, 24 Oct 2019 00:38:06 -0500 Subject: [PATCH 4/7] update version from develop commit fc1c6377 , Must update security issues based on DECA_ERC20_0.4.26.sol --- DECA_ERC20_0.5.3.sol | 307 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 307 insertions(+) create mode 100644 DECA_ERC20_0.5.3.sol diff --git a/DECA_ERC20_0.5.3.sol b/DECA_ERC20_0.5.3.sol new file mode 100644 index 0000000..0ec3394 --- /dev/null +++ b/DECA_ERC20_0.5.3.sol @@ -0,0 +1,307 @@ +pragma solidity 0.5.3; + +// ---------------------------------------------------------------------------- +// 'DECA' DEcentralized CArbon tokens - ITDE (initial token distribution event) +// +// Deployed to : 0xD9497a4ee4D9E6E73EC1126D2f7827DEA8A51154 +// Network : Ropsten +// Symbol : DECA +// Name : Decentralized Carbon tokens +// Total supply: Gazillion +// Decimals : 18 +// +// Enjoy. +// +// (c) by Moritz Neto & Daniel Bar with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. +// fork and modifications to fix DECA's ICO needs by p1r0 and kaicudon +// ---------------------------------------------------------------------------- + + +// ---------------------------------------------------------------------------- +// Safe maths +// ---------------------------------------------------------------------------- +contract SafeMath { + function safeAdd(uint a, uint b) internal pure returns (uint c) { + c = a + b; + require(c >= a); + } + function safeSub(uint a, uint b) internal pure returns (uint c) { + require(b <= a); + c = a - b; + } + function safeMul(uint a, uint b) internal pure returns (uint c) { + c = a * b; + require(a == 0 || c / a == b); + } + function safeDiv(uint a, uint b) internal pure returns (uint c) { + require(b > 0); + c = a / b; + } +} + + +// ---------------------------------------------------------------------------- +// ERC Token Standard #20 Interface +// https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md +// ---------------------------------------------------------------------------- +contract ERC20Interface { + function getTotalSupply() public view returns (uint); + function balanceOf(address tokenOwner) public view returns (uint balance); + function allowance(address tokenOwner, address spender) public view returns (uint remaining); + function transfer(address to, uint tokens) public returns (bool success); + function approve(address spender, uint tokens) public returns (bool success); + function transferFrom(address from, address to, uint tokens) public returns (bool success); + + event Transfer(address indexed from, address indexed to, uint tokens); + event Approval(address indexed tokenOwner, address indexed spender, uint tokens); +} + + +// ---------------------------------------------------------------------------- +// Contract function to receive approval and execute function in one call +// +// Borrowed from MiniMeToken +// ---------------------------------------------------------------------------- +contract ApproveAndCallFallBack { + function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; +} + + +// ---------------------------------------------------------------------------- +// Owned contract +// ---------------------------------------------------------------------------- +contract Owned { + address payable public owner; + address payable public newOwner; + string public CCDBAddress; + + event OwnershipTransferred(address indexed _from, address indexed _to); + + constructor () public { + owner = msg.sender; + } + + modifier onlyOwner { + require(msg.sender == owner); + _; + } + + function updateCCDBAddress(string memory _CCDBAddress) public onlyOwner { + CCDBAddress = _CCDBAddress; + } + function transferOwnership(address payable _newOwner) public onlyOwner { + newOwner = _newOwner; + } + function acceptOwnership() public { + require(msg.sender == newOwner); + emit OwnershipTransferred(owner, newOwner); + owner = newOwner; + newOwner = address(0); + } +} + + +// ---------------------------------------------------------------------------- +// ERC20 Token, with the addition of symbol, name and decimals and assisted +// token transfers +// ---------------------------------------------------------------------------- +contract DECAToken is ERC20Interface, Owned, SafeMath { + string public symbol; + string public name; + uint8 public decimals; + uint public totalSupply; + uint public startDate; + uint public preICOEnds; + uint public bonus1Ends; + uint public bonus2Ends; + uint public endDate; + + mapping(address => uint) balances; + mapping(address => mapping(address => uint)) allowed; + + + // ------------------------------------------------------------------------ + // Constructor + // ------------------------------------------------------------------------ + constructor () public { + symbol = "DECA"; + name = "DEcentralized CArbon tokens"; + decimals = 18; + //for testing change weeks for days... + preICOEnds = now + 1 days; + bonus1Ends = now + 3 days; + bonus2Ends = now + 6 days; + endDate = now + 11 days; + + } + + modifier onlyValidAddress(address addr) { + require(addr != address(0), "Address cannot be zero"); + _; + } + + modifier onlySufficientBalance(address from, uint256 tokens) { + require(tokens <= balances[from], "Insufficient balance"); + _; + } + + modifier onlySufficientAllowance(address owner, address spender, uint256 value) { + require(value <= allowed[owner][spender], "Insufficient allowance"); + _; + } + + // ------------------------------------------------------------------------ + // Total supply: Get the total token supply + // ------------------------------------------------------------------------ + + function getTotalSupply() public view returns (uint) { + return totalSupply - balances[address(0)]; + } + + // ------------------------------------------------------------------------ + // Get the token balance for account `tokenOwner` + // ------------------------------------------------------------------------ + function balanceOf(address tokenOwner) public view returns (uint balance) { + return balances[tokenOwner]; + } + + // ------------------------------------------------------------------------ + // Transfer the balance from token owner's account to `to` account + // - Owner's account must have sufficient balance to transfer + // - 0 value transfers are allowed + // ------------------------------------------------------------------------ + function transfer(address to, uint tokens) public onlySufficientBalance(msg.sender, tokens) returns (bool success) { + balances[msg.sender] = safeSub(balances[msg.sender], tokens); + balances[to] = safeAdd(balances[to], tokens); + emit Transfer(msg.sender, to, tokens); + return true; + } + + // ------------------------------------------------------------------------ + // Token owner can approve for `spender` to transferFrom(...) `tokens` + // from the token owner's account + // + // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md + // recommends that there are no checks for the approval double-spend attack + // as this should be implemented in user interfaces + // ------------------------------------------------------------------------ + function approve(address spender, uint tokens) public returns (bool success) { + allowed[msg.sender][spender] = tokens; + emit Approval(msg.sender, spender, tokens); + return true; + } + + // ------------------------------------------------------------------------ + // Increases the amount of tokens that an owner allowed to a spender. + // + // approve should be called when _allowance[spender] == 0. To increment + // allowed value is better to use this function to avoid 2 calls (and wait until + // the first transaction is mined) + // 'spender' The address which will spend the funds. + // 'addedValue' The amount of tokens to increase the allowance by. + // ------------------------------------------------------------------------ + function increaseAllowance(address spender, uint256 addedValue) public + onlyValidAddress(spender) + returns (bool){ + allowed[msg.sender][spender] = safeAdd(allowed[msg.sender][spender], addedValue); + emit Approval(msg.sender, spender, allowed[msg.sender][spender]); + return true; + } + + // ------------------------------------------------------------------------ + // Decreases the amount of tokens that an owner allowed to a spender. + // + // approve should be called when _allowance[spender] == 0. To decrement + // allowed value is better to use this function to avoid 2 calls (and wait until + // the first transaction is mined) + // 'spender' The address which will spend the funds. + // 'param' subtractedValue The amount of tokens to decrease the allowance by. + // ------------------------------------------------------------------------ + function decreaseAllowance(address spender, uint256 subtractedValue) public + onlyValidAddress(spender) + onlySufficientAllowance(msg.sender, spender, subtractedValue) + returns (bool){ + allowed[msg.sender][spender] = safeSub(allowed[msg.sender][spender], subtractedValue); + emit Approval(msg.sender, spender, allowed[msg.sender][spender]); + return true; + } + + // ------------------------------------------------------------------------ + // Transfer `tokens` from the `from` account to the `to` account + // + // The calling account must already have sufficient tokens approve(...)-d + // for spending from the `from` account and + // - From account must have sufficient balance to transfer + // - Spender must have sufficient allowance to transfer + // - 0 value transfers are allowed + // ------------------------------------------------------------------------ + function transferFrom(address from, address to, uint tokens) public + onlyValidAddress(to) + onlySufficientBalance(from, tokens) + onlySufficientAllowance(from, msg.sender, tokens) + returns (bool success) { + balances[from] = safeSub(balances[from], tokens); + allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); + balances[to] = safeAdd(balances[to], tokens); + emit Transfer(from, to, tokens); + return true; + } + + // ------------------------------------------------------------------------ + // Returns the amount of tokens approved by the owner that can be + // transferred to the spender's account + // ------------------------------------------------------------------------ + function allowance(address tokenOwner, address spender) public view returns (uint remaining) { + return allowed[tokenOwner][spender]; + } + + // ------------------------------------------------------------------------ + // Token owner can approve for `spender` to transferFrom(...) `tokens` + // from the token owner's account. The `spender` contract function + // `receiveApproval(...)` is then executed + // ------------------------------------------------------------------------ + function approveAndCall(address spender, uint tokens, bytes memory data) public returns (bool success) { + allowed[msg.sender][spender] = tokens; + emit Approval(msg.sender, spender, tokens); + ApproveAndCallFallBack(spender).receiveApproval(msg.sender, tokens, address(this), data); + return true; + } + + // ------------------------------------------------------------------------ + // 1,000 DECA Tokens per 1 ETH + // ------------------------------------------------------------------------ + function () external payable { + require(now >= startDate && now <= endDate); + uint tokens; + uint toOwner; + uint toSender; + uint percentage; + + percentage = 2; // percentage that goes to the owner + + if (now <= preICOEnds) { + tokens = msg.value * 2000; + } else if (now > preICOEnds && now <= bonus1Ends ) { + tokens = msg.value * 1500; + } else if (now > bonus1Ends && now <= bonus2Ends) { + tokens = msg.value * 1250; + } else { + tokens = msg.value * 1000; + } + toOwner = safeDiv(tokens, percentage); // percentage assigned to the contract owner (DAO) + toSender = tokens; // tokens goes to sender + balances[msg.sender] = safeAdd(balances[msg.sender], toSender); + balances[owner] = safeAdd(balances[owner], toOwner); + totalSupply = safeAdd(totalSupply, safeAdd(tokens,safeDiv(tokens, percentage))); + emit Transfer(address(0), msg.sender, toSender); + emit Transfer(address(0), owner, toOwner); + address(owner).transfer(msg.value); + } + + // ------------------------------------------------------------------------ + // Owner can transfer out any accidentally sent ERC20 tokens + // ------------------------------------------------------------------------ + function transferAnyERC20Token(address tokenAddress, uint tokens) public onlyOwner returns (bool success) { + return ERC20Interface(tokenAddress).transfer(owner, tokens); + } +} From 872a28108a0f5ac10bb0e2f92bdc7c799f1003c9 Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron Rocha" Date: Fri, 1 Nov 2019 15:00:02 -0600 Subject: [PATCH 5/7] fixed: The owner would receive significantlymore tokens than they should (the owner does get 20% for exchange to carbon credits), fixed: Arbitrary token minting by the owner (with function getETH at line 286), fixed: Outdated Syntax (now at 0.5.3), fixed: Unlocked Pragma, fixed: lines 247 and 243 repeatcomputations,fixed: the field startDate appears to be unused --- DECA_ERC20_0.5.3.sol | 63 +++--- DECA_IERC20_0.5.3.json | 493 +++++++++++++++++++++++++++++++++++++++++ 2 files changed, 520 insertions(+), 36 deletions(-) create mode 100644 DECA_IERC20_0.5.3.json diff --git a/DECA_ERC20_0.5.3.sol b/DECA_ERC20_0.5.3.sol index 0ec3394..ff349cc 100644 --- a/DECA_ERC20_0.5.3.sol +++ b/DECA_ERC20_0.5.3.sol @@ -106,35 +106,20 @@ contract Owned { // token transfers // ---------------------------------------------------------------------------- contract DECAToken is ERC20Interface, Owned, SafeMath { - string public symbol; - string public name; - uint8 public decimals; + string public symbol = "DECA"; + string public name = "DEcentralized CArbon tokens"; + uint8 public decimals = 18; uint public totalSupply; - uint public startDate; - uint public preICOEnds; - uint public bonus1Ends; - uint public bonus2Ends; - uint public endDate; + //for testing change weeks for hours... + uint public preICOEnds = now + 1 hours; + uint public bonus1Ends = now + 3 hours; + uint public bonus2Ends = now + 6 hours; + uint public endDate = now + 11 hours; mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; - - // ------------------------------------------------------------------------ - // Constructor - // ------------------------------------------------------------------------ - constructor () public { - symbol = "DECA"; - name = "DEcentralized CArbon tokens"; - decimals = 18; - //for testing change weeks for days... - preICOEnds = now + 1 days; - bonus1Ends = now + 3 days; - bonus2Ends = now + 6 days; - endDate = now + 11 days; - - } - + //functions that helps against Allowance Double-Spend Exploit modifier onlyValidAddress(address addr) { require(addr != address(0), "Address cannot be zero"); _; @@ -271,31 +256,37 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { // 1,000 DECA Tokens per 1 ETH // ------------------------------------------------------------------------ function () external payable { - require(now >= startDate && now <= endDate); + require(now <= endDate); uint tokens; uint toOwner; uint toSender; - uint percentage; - - percentage = 2; // percentage that goes to the owner + uint divBy; + // division to get 20% of the total supply for carbon credits + divBy = 4; if (now <= preICOEnds) { - tokens = msg.value * 2000; + tokens = msg.value * 200; } else if (now > preICOEnds && now <= bonus1Ends ) { - tokens = msg.value * 1500; + tokens = msg.value * 150; } else if (now > bonus1Ends && now <= bonus2Ends) { - tokens = msg.value * 1250; + tokens = msg.value * 125; } else { - tokens = msg.value * 1000; + tokens = msg.value * 100; } - toOwner = safeDiv(tokens, percentage); // percentage assigned to the contract owner (DAO) - toSender = tokens; // tokens goes to sender + toOwner = safeDiv(tokens, divBy); // divBy to get the percentage assigned to the contract owner (for exchange to Cabron Credits) + toSender = tokens; //tokens that goes to the sender balances[msg.sender] = safeAdd(balances[msg.sender], toSender); balances[owner] = safeAdd(balances[owner], toOwner); - totalSupply = safeAdd(totalSupply, safeAdd(tokens,safeDiv(tokens, percentage))); + totalSupply = safeAdd(totalSupply, safeAdd(toSender,toOwner)); emit Transfer(address(0), msg.sender, toSender); emit Transfer(address(0), owner, toOwner); - address(owner).transfer(msg.value); + } + + //Close down the ICO and claim the Ether. + function getETH() public onlyOwner { + require(now >= endDate ); + // transfer the ETH balance in the contract to the owner + owner.transfer(address(this).balance); } // ------------------------------------------------------------------------ diff --git a/DECA_IERC20_0.5.3.json b/DECA_IERC20_0.5.3.json new file mode 100644 index 0000000..c3cb068 --- /dev/null +++ b/DECA_IERC20_0.5.3.json @@ -0,0 +1,493 @@ +[ + { + "constant": true, + "inputs": [], + "name": "name", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "getETH", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "from", + "type": "address" + }, + { + "name": "to", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "decimals", + "outputs": [ + { + "name": "", + "type": "uint8" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "tokenOwner", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "name": "balance", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_CCDBAddress", + "type": "string" + } + ], + "name": "updateCCDBAddress", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "owner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "symbol", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "name": "", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "to", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "endDate", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "getTotalSupply", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + }, + { + "name": "data", + "type": "bytes" + } + ], + "name": "approveAndCall", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "newOwner", + "outputs": [ + { + "name": "", + "type": "address" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "CCDBAddress", + "outputs": [ + { + "name": "", + "type": "string" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "tokenAddress", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "transferAnyERC20Token", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [ + { + "name": "tokenOwner", + "type": "address" + }, + { + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "name": "remaining", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "bonus1Ends", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "bonus2Ends", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "constant": false, + "inputs": [ + { + "name": "_newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, + { + "constant": true, + "inputs": [], + "name": "preICOEnds", + "outputs": [ + { + "name": "", + "type": "uint256" + } + ], + "payable": false, + "stateMutability": "view", + "type": "function" + }, + { + "payable": true, + "stateMutability": "payable", + "type": "fallback" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "name": "_to", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "from", + "type": "address" + }, + { + "indexed": true, + "name": "to", + "type": "address" + }, + { + "indexed": false, + "name": "tokens", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "name": "tokenOwner", + "type": "address" + }, + { + "indexed": true, + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "name": "tokens", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + } +] From 6fe80e4f6a31c7c5e87f28380b580240a530b2cb Mon Sep 17 00:00:00 2001 From: "David E. Perez Negron Rocha" Date: Fri, 1 Nov 2019 15:18:38 -0600 Subject: [PATCH 6/7] fixed: the fields in lines 109-117 should bedeclared constants. NOTE: issues with time as constants in lines 114-117 --- DECA_ERC20_0.5.3.sol | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/DECA_ERC20_0.5.3.sol b/DECA_ERC20_0.5.3.sol index ff349cc..1d10d1e 100644 --- a/DECA_ERC20_0.5.3.sol +++ b/DECA_ERC20_0.5.3.sol @@ -106,9 +106,9 @@ contract Owned { // token transfers // ---------------------------------------------------------------------------- contract DECAToken is ERC20Interface, Owned, SafeMath { - string public symbol = "DECA"; - string public name = "DEcentralized CArbon tokens"; - uint8 public decimals = 18; + string constant public symbol = "DECA"; + string constant public name = "DEcentralized CArbon tokens"; + uint8 constant public decimals = 18; uint public totalSupply; //for testing change weeks for hours... uint public preICOEnds = now + 1 hours; From c1b7d8fe9679c090f4a0e11d5c4c5311cbd41d37 Mon Sep 17 00:00:00 2001 From: P1R0 Date: Wed, 6 Nov 2019 07:22:42 +0000 Subject: [PATCH 7/7] General updates on documentation and changes against the Allowance Double-Spend Exploit, must verify if it works. --- DECA_ERC20_0.5.3.sol | 112 ++++++++++++++++------------------------- DECA_IERC20_0.5.3.json | 52 +++++++++---------- 2 files changed, 69 insertions(+), 95 deletions(-) diff --git a/DECA_ERC20_0.5.3.sol b/DECA_ERC20_0.5.3.sol index 1d10d1e..e7da5bf 100644 --- a/DECA_ERC20_0.5.3.sol +++ b/DECA_ERC20_0.5.3.sol @@ -3,20 +3,18 @@ pragma solidity 0.5.3; // ---------------------------------------------------------------------------- // 'DECA' DEcentralized CArbon tokens - ITDE (initial token distribution event) // -// Deployed to : 0xD9497a4ee4D9E6E73EC1126D2f7827DEA8A51154 +// Deployed to : ------ // Network : Ropsten // Symbol : DECA // Name : Decentralized Carbon tokens // Total supply: Gazillion // Decimals : 18 // -// Enjoy. -// // (c) by Moritz Neto & Daniel Bar with BokkyPooBah / Bok Consulting Pty Ltd Au 2017. The MIT Licence. -// fork and modifications to fix DECA's ICO needs by p1r0 and kaicudon +// fork and modifications to fix DECA's ICO needs by p1r0 , +// Oscar and kaicudon // ---------------------------------------------------------------------------- - // ---------------------------------------------------------------------------- // Safe maths // ---------------------------------------------------------------------------- @@ -39,7 +37,6 @@ contract SafeMath { } } - // ---------------------------------------------------------------------------- // ERC Token Standard #20 Interface // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md @@ -50,23 +47,22 @@ contract ERC20Interface { function allowance(address tokenOwner, address spender) public view returns (uint remaining); function transfer(address to, uint tokens) public returns (bool success); function approve(address spender, uint tokens) public returns (bool success); + function increaseApproval (address spender, uint tokens) public returns (bool success); + function decreaseApproval (address spender, uint tokens) public returns (bool success); function transferFrom(address from, address to, uint tokens) public returns (bool success); - + event Transfer(address indexed from, address indexed to, uint tokens); event Approval(address indexed tokenOwner, address indexed spender, uint tokens); } - // ---------------------------------------------------------------------------- // Contract function to receive approval and execute function in one call -// // Borrowed from MiniMeToken // ---------------------------------------------------------------------------- contract ApproveAndCallFallBack { function receiveApproval(address from, uint256 tokens, address token, bytes memory data) public; } - // ---------------------------------------------------------------------------- // Owned contract // ---------------------------------------------------------------------------- @@ -85,7 +81,10 @@ contract Owned { require(msg.sender == owner); _; } - + // ---------------------------------------------------------------------------- + //Function that updates the orbitDB address at IPFS + //This database will store the carbon credits gotten by the 20% DECAS that the contract owner recives + // ---------------------------------------------------------------------------- function updateCCDBAddress(string memory _CCDBAddress) public onlyOwner { CCDBAddress = _CCDBAddress; } @@ -119,26 +118,9 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { mapping(address => uint) balances; mapping(address => mapping(address => uint)) allowed; - //functions that helps against Allowance Double-Spend Exploit - modifier onlyValidAddress(address addr) { - require(addr != address(0), "Address cannot be zero"); - _; - } - - modifier onlySufficientBalance(address from, uint256 tokens) { - require(tokens <= balances[from], "Insufficient balance"); - _; - } - - modifier onlySufficientAllowance(address owner, address spender, uint256 value) { - require(value <= allowed[owner][spender], "Insufficient allowance"); - _; - } - // ------------------------------------------------------------------------ // Total supply: Get the total token supply // ------------------------------------------------------------------------ - function getTotalSupply() public view returns (uint) { return totalSupply - balances[address(0)]; } @@ -155,7 +137,7 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { // - Owner's account must have sufficient balance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ - function transfer(address to, uint tokens) public onlySufficientBalance(msg.sender, tokens) returns (bool success) { + function transfer(address to, uint tokens) public returns (bool success) { balances[msg.sender] = safeSub(balances[msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); emit Transfer(msg.sender, to, tokens); @@ -165,48 +147,37 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { // ------------------------------------------------------------------------ // Token owner can approve for `spender` to transferFrom(...) `tokens` // from the token owner's account - // - // https://github.com/ethereum/EIPs/blob/master/EIPS/eip-20-token-standard.md - // recommends that there are no checks for the approval double-spend attack - // as this should be implemented in user interfaces // ------------------------------------------------------------------------ function approve(address spender, uint tokens) public returns (bool success) { - allowed[msg.sender][spender] = tokens; - emit Approval(msg.sender, spender, tokens); - return true; + // approve should only be called when setting an initial allowance, + // or when resetting it to zero. To increase and decrease it, use + // 'increaseApproval' and 'decreaseApproval' + if (allowed[msg.sender][spender] == 0 || tokens == 0){ + emit Approval(msg.sender, spender, tokens); + return true; + } + return false; } // ------------------------------------------------------------------------ - // Increases the amount of tokens that an owner allowed to a spender. - // - // approve should be called when _allowance[spender] == 0. To increment - // allowed value is better to use this function to avoid 2 calls (and wait until + // 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) - // 'spender' The address which will spend the funds. - // 'addedValue' The amount of tokens to increase the allowance by. // ------------------------------------------------------------------------ - function increaseAllowance(address spender, uint256 addedValue) public - onlyValidAddress(spender) - returns (bool){ - allowed[msg.sender][spender] = safeAdd(allowed[msg.sender][spender], addedValue); + function increaseApproval (address spender, uint tokens) public returns (bool success){ + allowed[msg.sender][spender] = safeAdd(allowed[msg.sender][spender], tokens); emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } - // ------------------------------------------------------------------------ - // Decreases the amount of tokens that an owner allowed to a spender. - // - // approve should be called when _allowance[spender] == 0. To decrement - // allowed value is better to use this function to avoid 2 calls (and wait until - // the first transaction is mined) - // 'spender' The address which will spend the funds. - // 'param' subtractedValue The amount of tokens to decrease the allowance by. - // ------------------------------------------------------------------------ - function decreaseAllowance(address spender, uint256 subtractedValue) public - onlyValidAddress(spender) - onlySufficientAllowance(msg.sender, spender, subtractedValue) - returns (bool){ - allowed[msg.sender][spender] = safeSub(allowed[msg.sender][spender], subtractedValue); + function decreaseApproval (address spender, uint tokens) public returns (bool success) { + uint oldValue = allowed[msg.sender][spender]; + if (tokens > oldValue) { + allowed[msg.sender][spender] = 0; + } + else{ + allowed[msg.sender][spender] = safeSub(oldValue, tokens); + } emit Approval(msg.sender, spender, allowed[msg.sender][spender]); return true; } @@ -220,11 +191,7 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { // - Spender must have sufficient allowance to transfer // - 0 value transfers are allowed // ------------------------------------------------------------------------ - function transferFrom(address from, address to, uint tokens) public - onlyValidAddress(to) - onlySufficientBalance(from, tokens) - onlySufficientAllowance(from, msg.sender, tokens) - returns (bool success) { + function transferFrom(address from, address to, uint tokens) public returns (bool success) { balances[from] = safeSub(balances[from], tokens); allowed[from][msg.sender] = safeSub(allowed[from][msg.sender], tokens); balances[to] = safeAdd(balances[to], tokens); @@ -253,7 +220,7 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { } // ------------------------------------------------------------------------ - // 1,000 DECA Tokens per 1 ETH + // 100 DECA Tokens per 1 ETH // ------------------------------------------------------------------------ function () external payable { require(now <= endDate); @@ -261,8 +228,14 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { uint toOwner; uint toSender; uint divBy; - // division to get 20% of the total supply for carbon credits - divBy = 4; + // ------------------------------------------------------------------------ + // We want to have 20% of the DECA tokens market cap in order to exchange + // them for carbon credits and have a better decentralization + // NOTE: The Contract Owner must publish this usage in the orbitdb database + // in order to prove that it's not holding using them with any other propose + // (this can be also verified by the blockchain). + // ------------------------------------------------------------------------ + divBy = 4; // 25% extra printed to be 20% of the marketcap, please see README.md if (now <= preICOEnds) { tokens = msg.value * 200; @@ -273,7 +246,8 @@ contract DECAToken is ERC20Interface, Owned, SafeMath { } else { tokens = msg.value * 100; } - toOwner = safeDiv(tokens, divBy); // divBy to get the percentage assigned to the contract owner (for exchange to Cabron Credits) + + toOwner = safeDiv(tokens, divBy); //created 25% extra to the contract owner toSender = tokens; //tokens that goes to the sender balances[msg.sender] = safeAdd(balances[msg.sender], toSender); balances[owner] = safeAdd(balances[owner], toOwner); diff --git a/DECA_IERC20_0.5.3.json b/DECA_IERC20_0.5.3.json index c3cb068..fb501fa 100644 --- a/DECA_IERC20_0.5.3.json +++ b/DECA_IERC20_0.5.3.json @@ -108,14 +108,14 @@ "type": "address" }, { - "name": "addedValue", + "name": "tokens", "type": "uint256" } ], - "name": "increaseAllowance", + "name": "decreaseApproval", "outputs": [ { - "name": "", + "name": "success", "type": "bool" } ], @@ -193,29 +193,6 @@ "stateMutability": "view", "type": "function" }, - { - "constant": false, - "inputs": [ - { - "name": "spender", - "type": "address" - }, - { - "name": "subtractedValue", - "type": "uint256" - } - ], - "name": "decreaseAllowance", - "outputs": [ - { - "name": "", - "type": "bool" - } - ], - "payable": false, - "stateMutability": "nonpayable", - "type": "function" - }, { "constant": false, "inputs": [ @@ -322,6 +299,29 @@ "stateMutability": "view", "type": "function" }, + { + "constant": false, + "inputs": [ + { + "name": "spender", + "type": "address" + }, + { + "name": "tokens", + "type": "uint256" + } + ], + "name": "increaseApproval", + "outputs": [ + { + "name": "success", + "type": "bool" + } + ], + "payable": false, + "stateMutability": "nonpayable", + "type": "function" + }, { "constant": false, "inputs": [