First Functional version, added pause and test scripts, ToDO: Remove TransferAnyERC20 and from test

This commit is contained in:
David E. Perez Negron Rocha 2020-02-17 23:18:07 -06:00
parent 9034a8af4d
commit 9dbda4b93d
16 changed files with 7546 additions and 5957 deletions

View File

@ -1,3 +1,9 @@
# DCC
Decentralized Carbon Credits in an ERC20 by neetsec
Decentralized Carbon Credits in an ERC20 by neetsec
# In order to run tests:
- npm i -g ganache-cli
- edit last line at run-rpc.sh, fix to the correct path to your ganache-cli
- open shell and execute "./run-rpc.sh"
- open second shell, and execute "truffle tests

View File

@ -19,14 +19,14 @@
"absolutePath": "@openzeppelin/contracts/GSN/Context.sol",
"exportedSymbols": {
"Context": [
381
417
]
},
"id": 382,
"id": 418,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 356,
"id": 392,
"literals": [
"solidity",
"^",
@ -42,40 +42,40 @@
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"id": 381,
"id": 417,
"linearizedBaseContracts": [
381
417
],
"name": "Context",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 359,
"id": 395,
"nodeType": "Block",
"src": "726:3:2",
"statements": []
},
"documentation": null,
"id": 360,
"id": 396,
"implemented": true,
"kind": "constructor",
"modifiers": [],
"name": "",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 357,
"id": 393,
"nodeType": "ParameterList",
"parameters": [],
"src": "714:2:2"
},
"returnParameters": {
"id": 358,
"id": 394,
"nodeType": "ParameterList",
"parameters": [],
"src": "726:0:2"
},
"scope": 381,
"scope": 417,
"src": "702:27:2",
"stateMutability": "nonpayable",
"superFunction": null,
@ -83,7 +83,7 @@
},
{
"body": {
"id": 368,
"id": 404,
"nodeType": "Block",
"src": "850:34:2",
"statements": [
@ -92,18 +92,18 @@
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 365,
"id": 401,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1057,
"referencedDeclaration": 1093,
"src": "867:3:2",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 366,
"id": 402,
"isConstant": false,
"isLValue": false,
"isPure": false,
@ -117,36 +117,36 @@
"typeString": "address payable"
}
},
"functionReturnParameters": 364,
"id": 367,
"functionReturnParameters": 400,
"id": 403,
"nodeType": "Return",
"src": "860:17:2"
}
]
},
"documentation": null,
"id": 369,
"id": 405,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "_msgSender",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 361,
"id": 397,
"nodeType": "ParameterList",
"parameters": [],
"src": "807:2:2"
},
"returnParameters": {
"id": 364,
"id": 400,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 363,
"id": 399,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 369,
"scope": 405,
"src": "833:15:2",
"stateVariable": false,
"storageLocation": "default",
@ -155,7 +155,7 @@
"typeString": "address payable"
},
"typeName": {
"id": 362,
"id": 398,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "833:15:2",
@ -171,7 +171,7 @@
],
"src": "832:17:2"
},
"scope": 381,
"scope": 417,
"src": "788:96:2",
"stateMutability": "view",
"superFunction": null,
@ -179,25 +179,25 @@
},
{
"body": {
"id": 379,
"id": 415,
"nodeType": "Block",
"src": "947:165:2",
"statements": [
{
"expression": {
"argumentTypes": null,
"id": 374,
"id": 410,
"name": "this",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1071,
"referencedDeclaration": 1107,
"src": "957:4:2",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Context_$381",
"typeIdentifier": "t_contract$_Context_$417",
"typeString": "contract Context"
}
},
"id": 375,
"id": 411,
"nodeType": "ExpressionStatement",
"src": "957:4:2"
},
@ -206,18 +206,18 @@
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 376,
"id": 412,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1057,
"referencedDeclaration": 1093,
"src": "1097:3:2",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 377,
"id": 413,
"isConstant": false,
"isLValue": false,
"isPure": false,
@ -231,36 +231,36 @@
"typeString": "bytes calldata"
}
},
"functionReturnParameters": 373,
"id": 378,
"functionReturnParameters": 409,
"id": 414,
"nodeType": "Return",
"src": "1090:15:2"
}
]
},
"documentation": null,
"id": 380,
"id": 416,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "_msgData",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 370,
"id": 406,
"nodeType": "ParameterList",
"parameters": [],
"src": "907:2:2"
},
"returnParameters": {
"id": 373,
"id": 409,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 372,
"id": 408,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 380,
"scope": 416,
"src": "933:12:2",
"stateVariable": false,
"storageLocation": "memory",
@ -269,7 +269,7 @@
"typeString": "bytes"
},
"typeName": {
"id": 371,
"id": 407,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "933:5:2",
@ -284,14 +284,14 @@
],
"src": "932:14:2"
},
"scope": 381,
"scope": 417,
"src": "890:222:2",
"stateMutability": "view",
"superFunction": null,
"visibility": "internal"
}
],
"scope": 382,
"scope": 418,
"src": "525:589:2"
}
],
@ -301,14 +301,14 @@
"absolutePath": "@openzeppelin/contracts/GSN/Context.sol",
"exportedSymbols": {
"Context": [
381
417
]
},
"id": 382,
"id": 418,
"nodeType": "SourceUnit",
"nodes": [
{
"id": 356,
"id": 392,
"literals": [
"solidity",
"^",
@ -324,40 +324,40 @@
"contractKind": "contract",
"documentation": null,
"fullyImplemented": true,
"id": 381,
"id": 417,
"linearizedBaseContracts": [
381
417
],
"name": "Context",
"nodeType": "ContractDefinition",
"nodes": [
{
"body": {
"id": 359,
"id": 395,
"nodeType": "Block",
"src": "726:3:2",
"statements": []
},
"documentation": null,
"id": 360,
"id": 396,
"implemented": true,
"kind": "constructor",
"modifiers": [],
"name": "",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 357,
"id": 393,
"nodeType": "ParameterList",
"parameters": [],
"src": "714:2:2"
},
"returnParameters": {
"id": 358,
"id": 394,
"nodeType": "ParameterList",
"parameters": [],
"src": "726:0:2"
},
"scope": 381,
"scope": 417,
"src": "702:27:2",
"stateMutability": "nonpayable",
"superFunction": null,
@ -365,7 +365,7 @@
},
{
"body": {
"id": 368,
"id": 404,
"nodeType": "Block",
"src": "850:34:2",
"statements": [
@ -374,18 +374,18 @@
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 365,
"id": 401,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1057,
"referencedDeclaration": 1093,
"src": "867:3:2",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 366,
"id": 402,
"isConstant": false,
"isLValue": false,
"isPure": false,
@ -399,36 +399,36 @@
"typeString": "address payable"
}
},
"functionReturnParameters": 364,
"id": 367,
"functionReturnParameters": 400,
"id": 403,
"nodeType": "Return",
"src": "860:17:2"
}
]
},
"documentation": null,
"id": 369,
"id": 405,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "_msgSender",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 361,
"id": 397,
"nodeType": "ParameterList",
"parameters": [],
"src": "807:2:2"
},
"returnParameters": {
"id": 364,
"id": 400,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 363,
"id": 399,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 369,
"scope": 405,
"src": "833:15:2",
"stateVariable": false,
"storageLocation": "default",
@ -437,7 +437,7 @@
"typeString": "address payable"
},
"typeName": {
"id": 362,
"id": 398,
"name": "address",
"nodeType": "ElementaryTypeName",
"src": "833:15:2",
@ -453,7 +453,7 @@
],
"src": "832:17:2"
},
"scope": 381,
"scope": 417,
"src": "788:96:2",
"stateMutability": "view",
"superFunction": null,
@ -461,25 +461,25 @@
},
{
"body": {
"id": 379,
"id": 415,
"nodeType": "Block",
"src": "947:165:2",
"statements": [
{
"expression": {
"argumentTypes": null,
"id": 374,
"id": 410,
"name": "this",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1071,
"referencedDeclaration": 1107,
"src": "957:4:2",
"typeDescriptions": {
"typeIdentifier": "t_contract$_Context_$381",
"typeIdentifier": "t_contract$_Context_$417",
"typeString": "contract Context"
}
},
"id": 375,
"id": 411,
"nodeType": "ExpressionStatement",
"src": "957:4:2"
},
@ -488,18 +488,18 @@
"argumentTypes": null,
"expression": {
"argumentTypes": null,
"id": 376,
"id": 412,
"name": "msg",
"nodeType": "Identifier",
"overloadedDeclarations": [],
"referencedDeclaration": 1057,
"referencedDeclaration": 1093,
"src": "1097:3:2",
"typeDescriptions": {
"typeIdentifier": "t_magic_message",
"typeString": "msg"
}
},
"id": 377,
"id": 413,
"isConstant": false,
"isLValue": false,
"isPure": false,
@ -513,36 +513,36 @@
"typeString": "bytes calldata"
}
},
"functionReturnParameters": 373,
"id": 378,
"functionReturnParameters": 409,
"id": 414,
"nodeType": "Return",
"src": "1090:15:2"
}
]
},
"documentation": null,
"id": 380,
"id": 416,
"implemented": true,
"kind": "function",
"modifiers": [],
"name": "_msgData",
"nodeType": "FunctionDefinition",
"parameters": {
"id": 370,
"id": 406,
"nodeType": "ParameterList",
"parameters": [],
"src": "907:2:2"
},
"returnParameters": {
"id": 373,
"id": 409,
"nodeType": "ParameterList",
"parameters": [
{
"constant": false,
"id": 372,
"id": 408,
"name": "",
"nodeType": "VariableDeclaration",
"scope": 380,
"scope": 416,
"src": "933:12:2",
"stateVariable": false,
"storageLocation": "memory",
@ -551,7 +551,7 @@
"typeString": "bytes"
},
"typeName": {
"id": 371,
"id": 407,
"name": "bytes",
"nodeType": "ElementaryTypeName",
"src": "933:5:2",
@ -566,14 +566,14 @@
],
"src": "932:14:2"
},
"scope": 381,
"scope": 417,
"src": "890:222:2",
"stateMutability": "view",
"superFunction": null,
"visibility": "internal"
}
],
"scope": 382,
"scope": 418,
"src": "525:589:2"
}
],
@ -585,7 +585,7 @@
},
"networks": {},
"schemaVersion": "3.0.19",
"updatedAt": "2019-12-29T01:52:30.751Z",
"updatedAt": "2020-02-18T05:14:13.973Z",
"devdoc": {
"methods": {}
},

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because one or more lines are too long

File diff suppressed because it is too large Load Diff

View File

@ -1,6 +1,7 @@
pragma solidity 0.5.12;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import "@openzeppelin/contracts/math/SafeMath.sol";
// ----------------------------------------------------------------------------
// 'DECA' DEcentralized CArbon tokens - ITDE (initial token distribution event)
@ -88,7 +89,7 @@ contract Ownable is Context {
// ERC20 Token, with the addition of symbol, name and decimals and assisted
// token transfers
// ----------------------------------------------------------------------------
contract DECAToken is ERC20, Ownable {
contract DECA is ERC20, Ownable {
using SafeMath for uint256;
string constant public symbol = "DECA";
string constant public name = "DEcentralized CArbon tokens";
@ -98,25 +99,39 @@ contract DECAToken is ERC20, Ownable {
uint public bonus1Ends = now + 3 weeks;
uint public bonus2Ends = now + 6 weeks;
uint public endDate = now + 11 weeks;
bool private _pause = false;
modifier notPaused() {
require(!_pause, "crowdsale on pause");
_;
}
function getPause() view public returns (bool){
return _pause;
}
function setPause(bool p) external onlyOwner {
_pause = p;
}
// ------------------------------------------------------------------------
// 100 DECA Tokens per 1 ETH
// ------------------------------------------------------------------------
function() external payable {
function() notPaused external payable {
require(now <= endDate);
uint tokens;
uint toOwner;
uint toSender;
uint divBy;
divBy = 40; //2.5% extra printed to be 2% of the marketcap, please see README.md
divBy = 40;
//2.5% extra printed to be 2% of the marketcap, please see README.md
if (now <= preICOEnds) {
tokens = msg.value * 200;
tokens = msg.value * 300;
} else if (now > preICOEnds && now <= bonus1Ends) {
tokens = msg.value * 150;
tokens = msg.value * 275;
} else if (now > bonus1Ends && now <= bonus2Ends) {
tokens = msg.value * 125;
tokens = msg.value * 250;
} else {
tokens = msg.value * 100;
tokens = msg.value * 225;
}
toOwner = tokens.div(divBy);

View File

@ -1,4 +1,5 @@
pragma solidity >=0.4.21 <0.7.0;
pragma solidity 0.5.12;
//pragma solidity 0.5.16;
contract Migrations {
address public owner;

View File

@ -0,0 +1,8 @@
const DECA = artifacts.require("DECA");
module.exports = function (deployer) {
module.exports = function (deployer) {
deployer.deploy(DECA, {
gas: 6712390
});
};
};

View File

@ -1,8 +0,0 @@
var DECAToken = artifacts.require("DECAToken");
module.exports = function(deployer) {
const name = "DEcentralized CArbon tokens";
const symbol = "DECA";
const decimals = 18;
deployer.deploy(DECAToken, name, symbol, decimals);
};

81
run-rpc.sh Executable file
View File

@ -0,0 +1,81 @@
#!/bin/bash
# We define 10 accounts with balance 1M ether, needed for high-value tests.
accounts=(
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501200,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501201,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501202,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501203,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501204,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501205,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501206,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501207,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501208,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501209,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501210,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501211,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501212,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501213,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501214,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501215,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501216,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501217,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501218,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501219,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501220,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501221,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501222,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501223,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501224,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501225,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501226,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501227,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501228,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501229,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501230,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501231,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501232,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501233,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501234,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501235,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501236,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501237,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501238,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501239,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501230,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501240,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501241,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501242,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501243,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501244,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501245,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501246,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501247,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501248,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501249,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501250,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501251,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501252,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501253,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501254,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501255,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501256,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501257,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501258,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501259,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501350,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501351,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501352,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501353,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501354,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501355,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501356,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501357,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501358,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
--account="0x2bdd21761a483f71054e14f5b827213567971c676928d9a1808cbfa4b7501359,999999999999999999999999999999999999999999999999999999999999999999999999999999999999999999"
)
/usr/local/bin/ganache-cli "${accounts[@]}" --gasPrice 1

270
test/DECA.js Normal file
View File

@ -0,0 +1,270 @@
const DECA = artifacts.require('./DECA.sol')
// fix legacy web3 bugs
web3.toAsciiOriginal = web3.toAscii;
web3.toAscii = function (input) {
return web3.toAsciiOriginal(input).replace(/\u0000/g, '')
}
let accCounter = 0;
function increaseTime(duration) {
const id = Date.now()
return new Promise((resolve, reject) => {
web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_increaseTime',
params: [duration],
id: id,
}, err1 => {
if (err1) return reject(err1)
web3.currentProvider.send({
jsonrpc: '2.0',
method: 'evm_mine',
id: id + 1,
}, (err2, res) => {
return err2 ? reject(err2) : resolve(res)
})
})
})
}
function latestTime() {
return web3.eth.getBlock('latest').timestamp;
}
//bypass testrpc bug
async function getHighBalance() {
var accounts = await web3.eth.getAccounts();
var acc = accounts[accCounter];
console.dir(acc)
var b = await web3.eth.getBalance(acc);
console.dir(b)
let high = {
"address": acc,
"balance": b
}
accCounter++;
return high;
}
const duration = {
seconds: function (val) {
return val
},
minutes: function (val) {
return val * this.seconds(60)
},
hours: function (val) {
return val * this.minutes(60)
},
days: function (val) {
return val * this.hours(24)
},
weeks: function (val) {
return val * this.days(7)
},
years: function (val) {
return val * this.days(365)
}
};
contract('DECA', function (accs) {
beforeEach(async function () {
this.creator = await getHighBalance();
this.deca = await DECA.new({
from: this.creator.address,
gas: 6712390
})
}),
describe('check pause', function () {
it('should get/set pause', async function () {
let p = await this.deca.getPause.call();
assert.equal(false, p, "pause should be disabled")
await this.deca.setPause(true, {from: this.creator.address, gas: 6712390})
p = await this.deca.getPause.call();
assert.equal(true, p, "pause should be enabled")
})
it('should fail on pay', async function () {
await this.deca.setPause(true, {from: this.creator.address, gas: 6712390})
let wasErr = false;
try {
let rs = await web3.eth.sendTransaction({
from: this.creator.address,
to: this.deca.address,
value: 225,
gas: 6712390
});
} catch (err) {
wasErr = true;
}
await this.deca.setPause(false, {from: this.creator.address, gas: 6712390})
wasErr = false;
try {
let rs = await web3.eth.sendTransaction({
from: this.creator.address,
to: this.deca.address,
value: 225,
gas: 6712390
});
} catch (err) {
wasErr = true;
}
assert.equal(false, wasErr, "pause should work")
})
it('check intruder pause', async function () {
var sender = await getHighBalance();
await increaseTime(duration.days(1))
await web3.eth.sendTransaction({
from: sender.address,
to: this.deca.address,
value: 1,
gas: 6712390
});
let wasErr = false;
try {
await this.deca.setPause(true, {from: sender.address, gas: 6712390})
} catch (err) {
wasErr = true;
}
assert.equal(true, wasErr, "only owner could pause")
let own = await this.deca.owner();
assert.equal(this.creator.address, own, "owner does not match")
})
})
describe('check crowdsale dates', function () {
it('check preICOEnds', async function () {
var sender = await getHighBalance();
await increaseTime(duration.days(1))
await web3.eth.sendTransaction({
from: sender.address,
to: this.deca.address,
value: 1,
gas: 6712390
});
let bonus2Ends = await this.deca.balanceOf.call(sender.address)
assert.equal(bonus2Ends.toString(10), '300', "preICOEnds wrong token balance")
})
it('check bonus1Ends', async function () {
var sender = await getHighBalance();
await increaseTime(duration.days(7) + duration.hours(1))
await web3.eth.sendTransaction({
from: sender.address,
to: this.deca.address,
value: 1,
gas: 6712390
});
let bonus2Ends = await this.deca.balanceOf.call(sender.address)
assert.equal(bonus2Ends.toString(10), '275', "bonus1Ends wrong token balance")
})
it('check bonus2Ends', async function () {
var sender = await getHighBalance();
await increaseTime(duration.weeks(3) + duration.hours(1))
await web3.eth.sendTransaction({
from: sender.address,
to: this.deca.address,
value: 1,
gas: 6712390
});
let bonus2Ends = await this.deca.balanceOf.call(sender.address)
assert.equal(bonus2Ends.toString(10), '250', "bonus2Ends wrong token balance")
})
it('check endDate', async function () {
await increaseTime(duration.weeks(11) + duration.hours(1))
let wasErr = false;
try {
let rs = await web3.eth.sendTransaction({
from: this.creator.address,
to: this.deca.address,
value: 225,
gas: 6712390
});
} catch (err) {
wasErr = true;
}
assert.equal(true, wasErr, "crowdsale should be stopped")
})
})
describe('transferAnyERC20Token', async function () {
it('check transfer from external', async function () {
this.deca2 = await DECA.new({
from: this.creator.address,
gas: 6712390
})
var sender = await getHighBalance();
await web3.eth.sendTransaction({
from: sender.address,
to: this.deca2.address,
value: 1,
gas: 6712390
});
let deca2Balance = await this.deca2.balanceOf.call(sender.address)
console.log('DECA2 BALANCE : ', deca2Balance.toString(10))
assert.equal(deca2Balance.toString(10), '300', " sender should have balance")
let wasErr = false;
try {
let ok = await this.deca.transferAnyERC20Token(this.deca2.address, 1, {
from: this.creator.address,
gas: 6712390
})
assert.equal(true, ok, "transferAnyERC20Token should return positive result")
} catch (err) {
console.dir(err)
wasErr = true;
}
deca2Balance = await this.deca2.balanceOf.call(sender.address)
assert.equal(deca2Balance.toString(10), '0', " sender should have 0 on balance")
})
})
describe('check payout', async function () {
it('check getETH', async function () {
let decaBalance = await web3.eth.getBalance(this.deca.address);
assert.equal(decaBalance.toString(10), '0', " wrong contract balance")
var sender = await getHighBalance();
await web3.eth.sendTransaction({
from: sender.address,
to: this.deca.address,
value: 1000,
gas: 6712390
});
decaBalance = await web3.eth.getBalance(this.deca.address);
assert.equal(decaBalance.toString(10), '1000', " wrong contract balance")
let senderTokenBalance = await this.deca.balanceOf.call(sender.address)
assert.equal(senderTokenBalance.toString(10), '200000', " wrong sender balance")
await increaseTime(duration.weeks(12));
let wasErr = false;
try {
await this.deca.getETH({from: this.creator.address, gas: 6712390})
} catch (err) {
console.dir(err)
wasErr = true;
}
assert.equal(false, wasErr, "getETH not possible to test because of bug in truffle, check status of bug: https://github.com/trufflesuite/truffle/issues/2811")
decaBalance = await web3.eth.getBalance(this.deca.address);
assert.equal(decaBalance.toString(10), '0', " balance of the DECA expected to be empty")
})
})
})

View File

@ -1,93 +0,0 @@
/**
* Use this file to configure your truffle project. It's seeded with some
* common settings for different networks and features like migrations,
* compilation and testing. Uncomment the ones you need or modify
* them to suit your project as necessary.
*
* More information about configuration can be found at:
*
* truffleframework.com/docs/advanced/configuration
*
* To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
* to sign your transactions before they're sent to a remote public node. Infura accounts
* are available for free at: infura.io/register.
*
* You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
* public/private key pairs. If you're publishing your code to GitHub make sure you load this
* phrase from a file you've .gitignored so it doesn't accidentally become public.
*
*/
// const HDWalletProvider = require('truffle-hdwallet-provider');
// const infuraKey = "fj4jll3k.....";
//
// const fs = require('fs');
// const mnemonic = fs.readFileSync(".secret").toString().trim();
module.exports = {
/**
* Networks define how you connect to your ethereum client and let you set the
* defaults web3 uses to send transactions. If you don't specify one truffle
* will spin up a development blockchain for you on port 9545 when you
* run `develop` or `test`. You can ask a truffle command to use a specific
* network from the command line, e.g
*
* $ truffle test --network <network-name>
*/
networks: {
// Useful for testing. The `development` name is special - truffle uses it by default
// if it's defined here and no other network is specified at the command line.
// You should run a client (like ganache-cli, geth or parity) in a separate terminal
// tab if you use this network and you must also set the `host`, `port` and `network_id`
// options below to some value.
//
// development: {
// host: "127.0.0.1", // Localhost (default: none)
// port: 8545, // Standard Ethereum port (default: none)
// network_id: "*", // Any network (default: none)
// },
// Another network with more advanced options...
// advanced: {
// port: 8777, // Custom port
// network_id: 1342, // Custom network
// gas: 8500000, // Gas sent with each transaction (default: ~6700000)
// gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
// from: <address>, // Account to send txs from (default: accounts[0])
// websockets: true // Enable EventEmitter interface for web3 (default: false)
// },
// Useful for deploying to a public network.
// NB: It's important to wrap the provider as a function.
// ropsten: {
// provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
// network_id: 3, // Ropsten's id
// gas: 5500000, // Ropsten has a lower block limit than mainnet
// confirmations: 2, // # of confs to wait between deployments. (default: 0)
// timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
// skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
// },
// Useful for private networks
// private: {
// provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
// network_id: 2111, // This network is yours, in the cloud.
// production: true // Treats this network as if it was a public net. (default: false)
// }
development: {
host: "localhost",
port: 8545,
network_id: "*",
gas: 6712390
}
},
// Set default mocha options here, use special reporters etc.
mocha: {
// timeout: 100000
},
}

16
truffle.js Normal file
View File

@ -0,0 +1,16 @@
module.exports = {
networks: {
development: {
host: "localhost",
port: 8545,
network_id: "*",
gas: 6712390
},
ropsten: {
network_id: 3,
host: "localhost",
port: 8545,
gas: 2900000
}
}
};