Compare commits
11 Commits
feature/tr
...
master
Author | SHA1 | Date |
---|---|---|
David E. Perez Negron Rocha | bcf24dfb70 | |
David E. Perez Negron Rocha | 0b45255267 | |
David E. Perez Negron Rocha | efc8046b2b | |
David E. Perez Negron Rocha | 83414e1780 | |
David E. Perez Negron Rocha | 618de6cb61 | |
David E. Perez Negron Rocha | d97f7cd426 | |
David E. Perez Negron Rocha | 3d723163e8 | |
David E. Perez Negron Rocha | ced2d42dc3 | |
David E. Perez Negron Rocha | 628cf32976 | |
David E. Perez Negron Rocha | 22c466bf17 | |
David E. Perez Negron Rocha | ec7e25a456 |
|
@ -0,0 +1,2 @@
|
||||||
|
package-lock.json
|
||||||
|
/node_modules
|
|
@ -0,0 +1,26 @@
|
||||||
|
image: node:12.16.3
|
||||||
|
|
||||||
|
before_script:
|
||||||
|
- npm install -g ganache-cli
|
||||||
|
- npm install -g truffle@5.1.3
|
||||||
|
- npm i @openzeppelin/contracts@2.4.0
|
||||||
|
|
||||||
|
stages:
|
||||||
|
- build
|
||||||
|
- test
|
||||||
|
|
||||||
|
|
||||||
|
build:
|
||||||
|
stage: build
|
||||||
|
script:
|
||||||
|
- truffle compile
|
||||||
|
tags:
|
||||||
|
- docker
|
||||||
|
|
||||||
|
test:
|
||||||
|
stage: test
|
||||||
|
script:
|
||||||
|
- ./run-rpc.sh &
|
||||||
|
- truffle test
|
||||||
|
tags:
|
||||||
|
- docker
|
|
@ -0,0 +1,32 @@
|
||||||
|
Disclaimers for DECA offering:
|
||||||
|
|
||||||
|
General Disclaimer:
|
||||||
|
|
||||||
|
This Offering may be subject to securities regulations in your country of
|
||||||
|
residence. As such, you may wish to consult with your investment advisor.
|
||||||
|
The complete explanation of the DECA project and the merits of the investment
|
||||||
|
in DECA are outlined in the White Paper and other supporting documents.
|
||||||
|
These are available for review on the DECA website (https://deca.eco).
|
||||||
|
|
||||||
|
Further Disclaimer if investor is located in North America:
|
||||||
|
|
||||||
|
This Offering may be subject to securities regulations in your country of
|
||||||
|
residence. As such, you may wish to consult with your investment advisor.
|
||||||
|
The complete explanation of the DECA project and the merits of the investment
|
||||||
|
in DECA are outlined in the White Paper and other supporting documents.
|
||||||
|
These are available for review on the DECA website (https://deca.eco).
|
||||||
|
|
||||||
|
Investors who are located in North America may qualify for investment under an
|
||||||
|
“accredited investor” exemption. While this exemption may vary by jurisdiction,
|
||||||
|
the general criteria is outlined as follows:
|
||||||
|
|
||||||
|
“Accredited Investor”, means a purchaser that:
|
||||||
|
|
||||||
|
(a) Has, in each of the past two years, had gross income before taxes of
|
||||||
|
$200,000 (or $300,000 with a spouse) and has a reasonable expectation of
|
||||||
|
achieving such income in the current year;
|
||||||
|
|
||||||
|
(b) Has financial assets of $1,000,000 (either alone or with a spouse), where
|
||||||
|
financial assets means cash and securities; or
|
||||||
|
|
||||||
|
(c) Has net assets of $5,000,000 (either alone or with a spouse).
|
4
LICENSE
4
LICENSE
|
@ -632,7 +632,7 @@ state the exclusion of warranty; and each file should have at least
|
||||||
the "copyright" line and a pointer to where the full notice is found.
|
the "copyright" line and a pointer to where the full notice is found.
|
||||||
|
|
||||||
DCC
|
DCC
|
||||||
Copyright (C) 2018 David E. Perez Negron Rocha
|
Copyright (C) 2018 NEETSEC INTERNATIONAL INC.
|
||||||
|
|
||||||
This program is free software: you can redistribute it and/or modify
|
This program is free software: you can redistribute it and/or modify
|
||||||
it under the terms of the GNU General Public License as published by
|
it under the terms of the GNU General Public License as published by
|
||||||
|
@ -652,7 +652,7 @@ Also add information on how to contact you by electronic and paper mail.
|
||||||
If the program does terminal interaction, make it output a short
|
If the program does terminal interaction, make it output a short
|
||||||
notice like this when it starts in an interactive mode:
|
notice like this when it starts in an interactive mode:
|
||||||
|
|
||||||
DCC Copyright (C) 2018 David E. Perez Negron Rocha
|
DCC Copyright (C) 2018 NEETSEC INTERNATIONAL INC.
|
||||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||||
This is free software, and you are welcome to redistribute it
|
This is free software, and you are welcome to redistribute it
|
||||||
under certain conditions; type `show c' for details.
|
under certain conditions; type `show c' for details.
|
||||||
|
|
190
README.md
190
README.md
|
@ -1,9 +1,185 @@
|
||||||
# DCC
|
Decentralized Carbon Credits ERC20
|
||||||
|
===
|
||||||
|
![build](https://gitlab.com/deca-currency/dcc/badges/develop/pipeline.svg)
|
||||||
|
[![Gitter](https://img.shields.io/gitter/room/nwjs/nw.js.svg)](https://gitter.im/deca-currency/community)
|
||||||
|
[![License: GPL v3](https://img.shields.io/badge/License-GPLv3-blue.svg)](https://www.gnu.org/licenses/gpl-3.0)
|
||||||
|
|
||||||
Decentralized Carbon Credits in an ERC20 by neetsec
|
Decentralized Carbon Credits in an ERC20 by Neetsec
|
||||||
|
|
||||||
# In order to run tests:
|
## Table of Contents
|
||||||
- npm i -g ganache-cli
|
|
||||||
- edit last line at run-rpc.sh, fix to the correct path to your ganache-cli
|
[[_TOC_]]
|
||||||
- open shell and execute "./run-rpc.sh"
|
|
||||||
- open second shell, and execute "truffle tests
|
## DECA Project Tree
|
||||||
|
```sh
|
||||||
|
|-- LICENSE
|
||||||
|
|-- README.md
|
||||||
|
|-- contracts
|
||||||
|
|-- build
|
||||||
|
| |-- contracts
|
||||||
|
| |-- Context.json
|
||||||
|
| |-- DECA.json
|
||||||
|
| |-- ERC20.json
|
||||||
|
| |-- IERC20.json
|
||||||
|
| |-- Migrations.json
|
||||||
|
| |-- Ownable.json
|
||||||
|
| `-- SafeMath.json
|
||||||
|
| |-- DECA.sol
|
||||||
|
| `-- Migrations.sol
|
||||||
|
|-- migrations
|
||||||
|
| |-- 1_initial_migration.js
|
||||||
|
| `-- 2_deploy_contracts.js
|
||||||
|
|-- package.json
|
||||||
|
|-- run-rpc.sh
|
||||||
|
|-- test
|
||||||
|
| `-- DECA.js
|
||||||
|
|-- truffle.js
|
||||||
|
|-- .gitignore
|
||||||
|
|-- .gitlab-ci.yml
|
||||||
|
```
|
||||||
|
|
||||||
|
## Requirements
|
||||||
|
|
||||||
|
* Node.js >= 12
|
||||||
|
* @openzeppelin/contracts = 2.4.0
|
||||||
|
|
||||||
|
#### Global install
|
||||||
|
* ganache-cli >= 6.9.1
|
||||||
|
* truffle = 5.1.3
|
||||||
|
|
||||||
|
## Instalation
|
||||||
|
|
||||||
|
**Download and install Node.js v12.x and npm.**
|
||||||
|
|
||||||
|
* Node.js
|
||||||
|
|
||||||
|
**Using Ubuntu**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ curl -sL https://deb.nodesource.com/setup_12.x | sudo -E bash -
|
||||||
|
$ sudo apt-get install -y nodejs
|
||||||
|
```
|
||||||
|
**Using Debian, as root**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ curl -sL https://deb.nodesource.com/setup_12.x | bash -
|
||||||
|
$ apt-get install -y nodejs
|
||||||
|
```
|
||||||
|
|
||||||
|
**Clone the repo**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ git clone https://gitlab.com/deca-currency/dcc.git
|
||||||
|
$ cd dcc
|
||||||
|
```
|
||||||
|
|
||||||
|
**Install the dependencies**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ npm install
|
||||||
|
```
|
||||||
|
|
||||||
|
**Install ganache-cli**
|
||||||
|
```sh
|
||||||
|
$ sudo npm install -g ganache-cli
|
||||||
|
```
|
||||||
|
|
||||||
|
**Install truffle**
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ sudo npm install -g truffle@5.1.3
|
||||||
|
```
|
||||||
|
|
||||||
|
## Testing the Smart Contract:
|
||||||
|
- can see the test in pipelines or you can run it locally
|
||||||
|
|
||||||
|
#### Running locally
|
||||||
|
- open shell and execute "./run-rpc.sh" (remember change /usr/local/bin/ganache-cli to your path)
|
||||||
|
```sh
|
||||||
|
$ ./run-rpc.sh
|
||||||
|
```
|
||||||
|
|
||||||
|
- open second shell, and execute
|
||||||
|
|
||||||
|
```sh
|
||||||
|
$ truffle tests
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
|
## Class Diagram ERC20 Token generated with [sol2uml](https://github.com/naddison36/sol2uml)
|
||||||
|
|
||||||
|
<p align="center">
|
||||||
|
<img src="uml/diagram.png" width="720" />
|
||||||
|
</p>
|
||||||
|
|
||||||
|
## Specification
|
||||||
|
|
||||||
|
### Methods
|
||||||
|
|
||||||
|
Apart from the [ERC20 standard](https://eips.ethereum.org/EIPS/eip-20) methods that our token complies, we introduce some
|
||||||
|
improvements, either for security or others that match DECA specific requirements.
|
||||||
|
|
||||||
|
**Notes:**
|
||||||
|
|
||||||
|
* The following specifications use syntax from Solidity (0.5.12)
|
||||||
|
|
||||||
|
#### owner
|
||||||
|
|
||||||
|
Returns the address of the current owner.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function owner() public view returns (address payable)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### isOwner
|
||||||
|
|
||||||
|
Returns true if the caller is the current owner.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function isOwner() public view returns (bool)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### transferOwnership
|
||||||
|
|
||||||
|
Can only be called by the current owner.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function transferOwnership(address payable newOwner) public onlyOwner
|
||||||
|
```
|
||||||
|
|
||||||
|
#### updateCCDBAddress
|
||||||
|
Updates the official orbitDB address for carbon credits.
|
||||||
|
|
||||||
|
Can Only be updated by the current owner
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function updateCCDBAddress(string memory newCCDBAddress) public onlyOwner
|
||||||
|
```
|
||||||
|
|
||||||
|
#### transferAnyERC20Token
|
||||||
|
|
||||||
|
Owner can transfer out any accidentally sent ERC20 tokens
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function transferAnyERC20Token(address payable tokenAddress, uint tokens) public onlyOwner returns (bool success)
|
||||||
|
```
|
||||||
|
|
||||||
|
#### getETH
|
||||||
|
|
||||||
|
Close down the ICO and claim the Ether.
|
||||||
|
|
||||||
|
```sh
|
||||||
|
function getETH() public onlyOwner { require(now >= endDate); owner().transfer(address(this).balance); }
|
||||||
|
```
|
||||||
|
|
||||||
|
## DECA Promotion Dates
|
||||||
|
|
||||||
|
Now, based on the total Ethereums we got by the ICO (ETHTS)
|
||||||
|
and considering our promodates which are:
|
||||||
|
|
||||||
|
| PROMO | TIME (weeks) | DECA TOKENS PER ETH |
|
||||||
|
|--------|--------------|---------------------|
|
||||||
|
| preICO | 1 | 300 |
|
||||||
|
| Bonus1 | 2 | 275 |
|
||||||
|
| Bonus2 | 3 | 250 |
|
||||||
|
| ICO | 5 | 225 |
|
||||||
|
|
|
@ -22,6 +22,8 @@ import "@openzeppelin/contracts/math/SafeMath.sol";
|
||||||
contract Ownable is Context {
|
contract Ownable is Context {
|
||||||
address payable private _owner;
|
address payable private _owner;
|
||||||
using SafeMath for uint256;
|
using SafeMath for uint256;
|
||||||
|
string public _CCDBAddress;
|
||||||
|
|
||||||
|
|
||||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
||||||
|
|
||||||
|
@ -83,6 +85,14 @@ contract Ownable is Context {
|
||||||
emit OwnershipTransferred(_owner, newOwner);
|
emit OwnershipTransferred(_owner, newOwner);
|
||||||
_owner = newOwner;
|
_owner = newOwner;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*Function that updates the official orbitDB address for carbon credits.
|
||||||
|
*Can Only be updated by the current owner
|
||||||
|
*/
|
||||||
|
function updateCCDBAddress(string memory newCCDBAddress) public onlyOwner {
|
||||||
|
_CCDBAddress = newCCDBAddress;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
|
@ -143,6 +153,15 @@ contract DECA is ERC20, Ownable {
|
||||||
_mint(msg.sender, toSender);
|
_mint(msg.sender, toSender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Add weeks in case ICO gets not enough funds
|
||||||
|
function appendWeeks(uint addWeeks ) public onlyOwner {
|
||||||
|
require(now >= bonus2Ends && now < endDate);
|
||||||
|
// Fix Integer Overflow / Underflow
|
||||||
|
require(endDate < (endDate + (addWeeks * 1 weeks)));
|
||||||
|
// add weeks to the endDate
|
||||||
|
endDate += (addWeeks * 1 weeks);
|
||||||
|
}
|
||||||
|
|
||||||
//Close down the ICO and claim the Ether.
|
//Close down the ICO and claim the Ether.
|
||||||
function getETH() public onlyOwner {
|
function getETH() public onlyOwner {
|
||||||
require(now >= endDate);
|
require(now >= endDate);
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "carbon-token",
|
"name": "carbon-token",
|
||||||
"version": "1.0.0",
|
"version": "1.2.0",
|
||||||
"description": "",
|
"description": "",
|
||||||
"main": "truffle-config.js",
|
"main": "truffle-config.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
@ -13,10 +13,11 @@
|
||||||
"author": "",
|
"author": "",
|
||||||
"license": "ISC",
|
"license": "ISC",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"openzeppelin-solidity": "2.4.0",
|
"@openzeppelin/contracts": "^2.4.0",
|
||||||
"solc": "^0.6.0"
|
"truffle": "^5.1.3"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"web3": "^1.2.4"
|
"web3": "^1.2.4"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
87
test/DECA.js
87
test/DECA.js
|
@ -84,6 +84,7 @@ contract('DECA', function (accs) {
|
||||||
})
|
})
|
||||||
|
|
||||||
}),
|
}),
|
||||||
|
|
||||||
describe('check pause', function () {
|
describe('check pause', function () {
|
||||||
it('should get/set pause', async function () {
|
it('should get/set pause', async function () {
|
||||||
let p = await this.deca.getPause.call();
|
let p = await this.deca.getPause.call();
|
||||||
|
@ -199,46 +200,55 @@ contract('DECA', function (accs) {
|
||||||
|
|
||||||
assert.equal(true, wasErr, "crowdsale should be stopped")
|
assert.equal(true, wasErr, "crowdsale should be stopped")
|
||||||
})
|
})
|
||||||
|
it('check appendWeeks', async function () {
|
||||||
|
await increaseTime(duration.weeks(10))
|
||||||
|
// get endDate before
|
||||||
|
let endDateBefore = await this.deca.endDate.call();
|
||||||
|
// add one week
|
||||||
|
await this.deca.appendWeeks(1, {
|
||||||
|
from: this.creator.address,
|
||||||
|
gas: 6712390
|
||||||
|
});
|
||||||
|
// get endDate after
|
||||||
|
let endDateAfter = await this.deca.endDate.call();
|
||||||
|
// 1 week = 604800 seconds
|
||||||
|
assert.equal(604800, endDateAfter - endDateBefore, "appendWeeks does not work");
|
||||||
})
|
})
|
||||||
// SOMEHOW THIS FUNCTIONS TEST WORKED IN ROPSTEN
|
})
|
||||||
// describe('transferAnyERC20Token', async function () {
|
|
||||||
// it('check transfer from external', async function () {
|
describe('transferAnyERC20Token', async function () {
|
||||||
// this.deca2 = await DECA.new({
|
it('check transfer from external', async function () {
|
||||||
// from: this.creator.address,
|
|
||||||
// gas: 6712390
|
var sender = await getHighBalance();
|
||||||
// })
|
await web3.eth.sendTransaction({
|
||||||
//
|
from: sender.address,
|
||||||
// var sender = await getHighBalance();
|
to: this.deca.address,
|
||||||
// await web3.eth.sendTransaction({
|
value: 1,
|
||||||
// from: sender.address,
|
gas: 6712390
|
||||||
// to: this.deca2.address,
|
});
|
||||||
// value: 1,
|
let decaBalance = await this.deca.balanceOf.call(this.deca.address)
|
||||||
// gas: 6712390
|
await this.deca.transfer(this.deca.address, 10, {from: sender.address, gas: 6712390})
|
||||||
// });
|
decaBalance = await this.deca.balanceOf.call(this.deca.address)
|
||||||
// let deca2Balance = await this.deca2.balanceOf.call(sender.address)
|
assert.equal(decaBalance.toString(10), '10', " contract should have balance")
|
||||||
// console.log('DECA2 BALANCE : ', deca2Balance.toString(10))
|
|
||||||
//
|
let wasErr = false;
|
||||||
// assert.equal(deca2Balance.toString(10), '300', " sender should have balance")
|
try {
|
||||||
//
|
let ok = await this.deca.transferAnyERC20Token(this.deca.address, 10, {
|
||||||
// let wasErr = false;
|
from: this.creator.address,
|
||||||
// try {
|
gas: 6712390
|
||||||
// let ok = await this.deca.transferAnyERC20Token(this.deca2.address, 1, {
|
})
|
||||||
// from: this.creator.address,
|
assert.equal(true, ok, "transferAnyERC20Token should return positive result")
|
||||||
// gas: 6712390
|
} catch (err) {
|
||||||
// })
|
console.dir(err)
|
||||||
// assert.equal(true, ok, "transferAnyERC20Token should return positive result")
|
wasErr = true;
|
||||||
// } catch (err) {
|
}
|
||||||
// console.dir(err)
|
|
||||||
// wasErr = true;
|
assert.equal(true, wasErr, "transferAnyERC20Token should proces without error")
|
||||||
// }
|
})
|
||||||
// deca2Balance = await this.deca2.balanceOf.call(sender.address)
|
})
|
||||||
//
|
// SOMEHOW THIS FUNCTIONS TEST WORKED IN ROPSTEN
|
||||||
// assert.equal(deca2Balance.toString(10), '0', " sender should have 0 on balance")
|
|
||||||
// })
|
|
||||||
// })
|
|
||||||
// describe('check payout', async function () {
|
// describe('check payout', async function () {
|
||||||
// it('check getETH', async function () {
|
// it.only('check getETH', async function () {
|
||||||
// let decaBalance = await web3.eth.getBalance(this.deca.address);
|
// let decaBalance = await web3.eth.getBalance(this.deca.address);
|
||||||
// assert.equal(decaBalance.toString(10), '0', " wrong contract balance")
|
// assert.equal(decaBalance.toString(10), '0', " wrong contract balance")
|
||||||
// var sender = await getHighBalance();
|
// var sender = await getHighBalance();
|
||||||
|
@ -267,5 +277,4 @@ contract('DECA', function (accs) {
|
||||||
//
|
//
|
||||||
// })
|
// })
|
||||||
// })
|
// })
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Binary file not shown.
After Width: | Height: | Size: 152 KiB |
Loading…
Reference in New Issue