Updates Ready for Master, NOTE: includes the integration of the previously audited function updateCCDBAddress

This commit is contained in:
David E. Perez Negron Rocha 2020-05-08 20:20:18 -05:00
parent ec7e25a456
commit 22c466bf17
8 changed files with 226 additions and 3264 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
package-lock.json
/node_modules

26
.gitlab-ci.yml Normal file
View File

@ -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

View File

@ -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 David E. Perez Negron Rocha
Copyright (C) 2018 NEETSEC INTERNATIONAL INC.
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 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 is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.

190
README.md
View File

@ -1,9 +1,185 @@
# DCC
Decentralized Carbon Credits ERC20
===
![build](https://img.shields.io/gitlab/pipeline/deca-currency/dcc)
[![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:
- 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
## 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 |

View File

@ -22,6 +22,8 @@ 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);
@ -83,6 +85,14 @@ 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;
}
}
// ----------------------------------------------------------------------------

3253
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -13,10 +13,11 @@
"author": "",
"license": "ISC",
"dependencies": {
"openzeppelin-solidity": "2.4.0",
"solc": "^0.6.0"
"@openzeppelin/contracts": "^2.4.0",
"truffle": "^5.1.3"
},
"devDependencies": {
"web3": "^1.2.4"
}
}

BIN
uml/diagram.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB