Compare commits
No commits in common. "master" and "feature/truffle+openzeppelin" have entirely different histories.
master
...
feature/tr
|
@ -1,2 +0,0 @@
|
|||
package-lock.json
|
||||
/node_modules
|
|
@ -1,26 +0,0 @@
|
|||
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
|
32
DISCLAIMERS
32
DISCLAIMERS
|
@ -1,32 +0,0 @@
|
|||
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.
|
||||
|
||||
DCC
|
||||
Copyright (C) 2018 NEETSEC INTERNATIONAL INC.
|
||||
Copyright (C) 2018 David E. Perez Negron Rocha
|
||||
|
||||
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
|
||||
|
@ -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
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
DCC Copyright (C) 2018 NEETSEC INTERNATIONAL INC.
|
||||
DCC Copyright (C) 2018 David E. Perez Negron Rocha
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
|
194
README.md
194
README.md
|
@ -1,189 +1,9 @@
|
|||
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)
|
||||
# DCC
|
||||
|
||||
Decentralized Carbon Credits in an ERC20 by Neetsec
|
||||
Decentralized Carbon Credits in an ERC20 by neetsec
|
||||
|
||||
## Table of Contents
|
||||
|
||||
[[_TOC_]]
|
||||
|
||||
## 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 |
|
||||
|
||||
## Contract Devs
|
||||
|
||||
* [David E. Perez Negron R.](mailto:david@neetsec.com)
|
||||
# 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
|
||||
|
|
|
@ -22,8 +22,6 @@ import "@openzeppelin/contracts/math/SafeMath.sol";
|
|||
contract Ownable is Context {
|
||||
address payable private _owner;
|
||||
using SafeMath for uint256;
|
||||
string public _CCDBAddress;
|
||||
|
||||
|
||||
event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
|
||||
|
||||
|
@ -85,14 +83,6 @@ contract Ownable is Context {
|
|||
emit OwnershipTransferred(_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;
|
||||
}
|
||||
}
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -153,15 +143,6 @@ contract DECA is ERC20, Ownable {
|
|||
_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.
|
||||
function getETH() public onlyOwner {
|
||||
require(now >= endDate);
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"name": "carbon-token",
|
||||
"version": "1.2.0",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "truffle-config.js",
|
||||
"directories": {
|
||||
|
@ -13,11 +13,10 @@
|
|||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"@openzeppelin/contracts": "^2.4.0",
|
||||
"truffle": "^5.1.3"
|
||||
"openzeppelin-solidity": "2.4.0",
|
||||
"solc": "^0.6.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"web3": "^1.2.4"
|
||||
}
|
||||
}
|
||||
|
||||
|
|
85
test/DECA.js
85
test/DECA.js
|
@ -84,7 +84,6 @@ contract('DECA', function (accs) {
|
|||
})
|
||||
|
||||
}),
|
||||
|
||||
describe('check pause', function () {
|
||||
it('should get/set pause', async function () {
|
||||
let p = await this.deca.getPause.call();
|
||||
|
@ -200,55 +199,46 @@ contract('DECA', function (accs) {
|
|||
|
||||
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");
|
||||
})
|
||||
})
|
||||
|
||||
describe('transferAnyERC20Token', async function () {
|
||||
it('check transfer from external', async function () {
|
||||
|
||||
var sender = await getHighBalance();
|
||||
await web3.eth.sendTransaction({
|
||||
from: sender.address,
|
||||
to: this.deca.address,
|
||||
value: 1,
|
||||
gas: 6712390
|
||||
});
|
||||
let decaBalance = await this.deca.balanceOf.call(this.deca.address)
|
||||
await this.deca.transfer(this.deca.address, 10, {from: sender.address, gas: 6712390})
|
||||
decaBalance = await this.deca.balanceOf.call(this.deca.address)
|
||||
assert.equal(decaBalance.toString(10), '10', " contract should have balance")
|
||||
|
||||
let wasErr = false;
|
||||
try {
|
||||
let ok = await this.deca.transferAnyERC20Token(this.deca.address, 10, {
|
||||
from: this.creator.address,
|
||||
gas: 6712390
|
||||
})
|
||||
assert.equal(true, ok, "transferAnyERC20Token should return positive result")
|
||||
} catch (err) {
|
||||
console.dir(err)
|
||||
wasErr = true;
|
||||
}
|
||||
|
||||
assert.equal(true, wasErr, "transferAnyERC20Token should proces without error")
|
||||
})
|
||||
})
|
||||
// SOMEHOW THIS FUNCTIONS TEST WORKED IN ROPSTEN
|
||||
// SOMEHOW THIS FUNCTIONS TEST WORKED IN ROPSTEN
|
||||
// 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.only('check getETH', 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();
|
||||
|
@ -277,4 +267,5 @@ contract('DECA', function (accs) {
|
|||
//
|
||||
// })
|
||||
// })
|
||||
|
||||
})
|
||||
|
|
BIN
uml/diagram.png
BIN
uml/diagram.png
Binary file not shown.
Before Width: | Height: | Size: 152 KiB |
Loading…
Reference in New Issue