├── token-templates
├── definitions
│ └── EThaler
│ │ └── latest
│ │ ├── EThaler.md
│ │ └── EThaler.proto
├── formulas
│ └── tF{d,t,p,c,SC}
│ │ └── latest
│ │ ├── tF{d,t,p,c,SC}.md
│ │ ├── tF{d,t,p,c,SC}.proto
│ │ └── tF{d,t,p,c,SC}.json
└── specifications
│ └── EThaler
│ └── latest
│ ├── EThaler-spec.docx
│ └── EThaler-spec.pdf
├── src
├── CLI
│ ├── settings.gradle
│ ├── wallets
│ │ └── .gitignore
│ ├── gradle
│ │ └── wrapper
│ │ │ ├── gradle-wrapper.jar
│ │ │ └── gradle-wrapper.properties
│ ├── src
│ │ └── main
│ │ │ ├── resources
│ │ │ ├── config
│ │ │ │ ├── config.properties.bak
│ │ │ │ └── config.properties
│ │ │ ├── logback.xml
│ │ │ └── wallets
│ │ │ │ ├── 140d8.json
│ │ │ │ ├── 140d9.json
│ │ │ │ ├── 140new.json
│ │ │ │ ├── 140new1.json
│ │ │ │ ├── 140owner.json
│ │ │ │ ├── CBWallet.json
│ │ │ │ ├── test.json
│ │ │ │ └── Dealer1Wallet.json
│ │ │ └── java
│ │ │ └── com
│ │ │ └── swapshub
│ │ │ └── ethaler
│ │ │ └── client
│ │ │ ├── MaskingThread.java
│ │ │ ├── NetWorkUtil.java
│ │ │ ├── PasswordField.java
│ │ │ └── EThalerApplication.java
│ ├── config
│ │ └── config.properties
│ ├── PrepareeThalerClient.sh
│ ├── PrepareeThalerClient.bat
│ ├── StarteThalerClient.sh
│ ├── StarteThalerClient.bat
│ ├── .gitignore
│ ├── ReadMe.txt
│ ├── build.gradle
│ └── gradlew.bat
├── node_modules
│ └── openzeppelin-solidity
│ │ ├── contracts
│ │ ├── lifecycle
│ │ │ ├── README.adoc
│ │ │ └── Pausable.sol
│ │ ├── math
│ │ │ ├── README.adoc
│ │ │ └── Math.sol
│ │ ├── cryptography
│ │ │ ├── README.adoc
│ │ │ ├── MerkleProof.sol
│ │ │ └── ECDSA.sol
│ │ ├── ownership
│ │ │ ├── README.adoc
│ │ │ ├── Secondary.sol
│ │ │ └── Ownable.sol
│ │ ├── payment
│ │ │ ├── README.adoc
│ │ │ ├── escrow
│ │ │ │ ├── ConditionalEscrow.sol
│ │ │ │ ├── Escrow.sol
│ │ │ │ └── RefundEscrow.sol
│ │ │ └── PullPayment.sol
│ │ ├── token
│ │ │ ├── ERC721
│ │ │ │ ├── ERC721Holder.sol
│ │ │ │ ├── IERC721Full.sol
│ │ │ │ ├── IERC721Metadata.sol
│ │ │ │ ├── IERC721Enumerable.sol
│ │ │ │ ├── ERC721Burnable.sol
│ │ │ │ ├── ERC721Full.sol
│ │ │ │ ├── ERC721Pausable.sol
│ │ │ │ ├── ERC721MetadataMintable.sol
│ │ │ │ ├── IERC721Receiver.sol
│ │ │ │ ├── ERC721Mintable.sol
│ │ │ │ ├── README.adoc
│ │ │ │ ├── IERC721.sol
│ │ │ │ └── ERC721Metadata.sol
│ │ │ ├── ERC1155
│ │ │ │ ├── ERC1155Receiver.sol
│ │ │ │ ├── README.md
│ │ │ │ ├── ERC1155Holder.sol
│ │ │ │ ├── IERC1155.sol
│ │ │ │ └── IERC1155Receiver.sol
│ │ │ ├── ERC777
│ │ │ │ ├── README.adoc
│ │ │ │ ├── IERC777Recipient.sol
│ │ │ │ └── IERC777Sender.sol
│ │ │ └── ERC20
│ │ │ │ ├── ERC20Mintable.sol
│ │ │ │ ├── ERC20Burnable.sol
│ │ │ │ ├── ERC20Capped.sol
│ │ │ │ ├── ERC20Pausable.sol
│ │ │ │ ├── README.adoc
│ │ │ │ ├── ERC20Detailed.sol
│ │ │ │ ├── TokenTimelock.sol
│ │ │ │ ├── IERC20.sol
│ │ │ │ └── SafeERC20.sol
│ │ ├── utils
│ │ │ ├── README.adoc
│ │ │ ├── Arrays.sol
│ │ │ ├── Create2.sol
│ │ │ ├── ReentrancyGuard.sol
│ │ │ ├── Address.sol
│ │ │ ├── SafeCast.sol
│ │ │ └── EnumerableSet.sol
│ │ ├── access
│ │ │ ├── README.adoc
│ │ │ ├── Roles.sol
│ │ │ └── roles
│ │ │ │ ├── CapperRole.sol
│ │ │ │ ├── MinterRole.sol
│ │ │ │ ├── PauserRole.sol
│ │ │ │ ├── SignerRole.sol
│ │ │ │ ├── WhitelistAdminRole.sol
│ │ │ │ └── WhitelistedRole.sol
│ │ ├── crowdsale
│ │ │ ├── README.adoc
│ │ │ ├── distribution
│ │ │ │ ├── RefundablePostDeliveryCrowdsale.sol
│ │ │ │ ├── FinalizableCrowdsale.sol
│ │ │ │ ├── PostDeliveryCrowdsale.sol
│ │ │ │ └── RefundableCrowdsale.sol
│ │ │ ├── validation
│ │ │ │ ├── WhitelistCrowdsale.sol
│ │ │ │ ├── PausableCrowdsale.sol
│ │ │ │ ├── CappedCrowdsale.sol
│ │ │ │ ├── IndividuallyCappedCrowdsale.sol
│ │ │ │ └── TimedCrowdsale.sol
│ │ │ ├── emission
│ │ │ │ ├── MintedCrowdsale.sol
│ │ │ │ └── AllowanceCrowdsale.sol
│ │ │ └── price
│ │ │ │ └── IncreasingPriceCrowdsale.sol
│ │ ├── drafts
│ │ │ ├── ERC1046
│ │ │ │ └── ERC20Metadata.sol
│ │ │ ├── README.adoc
│ │ │ ├── Strings.sol
│ │ │ ├── Counters.sol
│ │ │ ├── SignedSafeMath.sol
│ │ │ └── ERC20Migrator.sol
│ │ ├── introspection
│ │ │ ├── IERC1820Implementer.sol
│ │ │ ├── IERC165.sol
│ │ │ ├── ERC1820Implementer.sol
│ │ │ ├── README.adoc
│ │ │ └── ERC165.sol
│ │ ├── package.json
│ │ ├── GSN
│ │ │ ├── Context.sol
│ │ │ ├── README.adoc
│ │ │ ├── GSNRecipientSignature.sol
│ │ │ └── IRelayRecipient.sol
│ │ └── build
│ │ │ └── contracts
│ │ │ └── ERC165NotSupported.json
│ │ ├── LICENSE
│ │ ├── build
│ │ └── contracts
│ │ │ └── ERC165NotSupported.json
│ │ └── package.json
├── migrations
│ ├── 1_initial_migration.js
│ └── 2_deploy_eThaler.js
├── package.json
├── contracts
│ └── Migrations.sol
├── commands.txt
├── README.md
└── truffle-config-ganache.js
├── docs
├── CMSIG-eThaler-demo.pdf
├── status
│ ├── eThaler Project Update-2020-05-27.pdf
│ ├── eThaler Project Update-2020-04-03.pptx
│ ├── eThaler Project Update-2020-04-17.pptx
│ ├── eThaler Project Update-2020-04-22.pptx
│ └── eThaler Project Update-2020-05-01.pptx
├── erc-20 vs erc-1155.md
├── README.md
├── References.md
└── UI-Flow.md
└── .github
└── settings.yml
/token-templates/definitions/EThaler/latest/EThaler.md:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/token-templates/definitions/EThaler/latest/EThaler.proto:
--------------------------------------------------------------------------------
1 |
--------------------------------------------------------------------------------
/src/CLI/settings.gradle:
--------------------------------------------------------------------------------
1 | rootProject.name = 'eThalerClient'
2 |
3 |
--------------------------------------------------------------------------------
/docs/CMSIG-eThaler-demo.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/docs/CMSIG-eThaler-demo.pdf
--------------------------------------------------------------------------------
/src/CLI/wallets/.gitignore:
--------------------------------------------------------------------------------
1 | # Ignore everything in this directory
2 |
3 | *
4 | # except this file
5 |
6 | !.gitignore
--------------------------------------------------------------------------------
/token-templates/formulas/tF{d,t,p,c,SC}/latest/tF{d,t,p,c,SC}.md:
--------------------------------------------------------------------------------
1 | # eThaler a TTF TokenTemplate
2 | # models wholesale CBDC
3 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/lifecycle/README.adoc:
--------------------------------------------------------------------------------
1 | = Lifecycle
2 |
3 | == Pausable
4 |
5 | {{Pausable}}
6 |
--------------------------------------------------------------------------------
/src/CLI/gradle/wrapper/gradle-wrapper.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/src/CLI/gradle/wrapper/gradle-wrapper.jar
--------------------------------------------------------------------------------
/docs/status/eThaler Project Update-2020-05-27.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/docs/status/eThaler Project Update-2020-05-27.pdf
--------------------------------------------------------------------------------
/docs/status/eThaler Project Update-2020-04-03.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/docs/status/eThaler Project Update-2020-04-03.pptx
--------------------------------------------------------------------------------
/docs/status/eThaler Project Update-2020-04-17.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/docs/status/eThaler Project Update-2020-04-17.pptx
--------------------------------------------------------------------------------
/docs/status/eThaler Project Update-2020-04-22.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/docs/status/eThaler Project Update-2020-04-22.pptx
--------------------------------------------------------------------------------
/docs/status/eThaler Project Update-2020-05-01.pptx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/docs/status/eThaler Project Update-2020-05-01.pptx
--------------------------------------------------------------------------------
/src/migrations/1_initial_migration.js:
--------------------------------------------------------------------------------
1 | const Migrations = artifacts.require("Migrations");
2 |
3 | module.exports = function(deployer) {
4 | deployer.deploy(Migrations);
5 | };
6 |
7 |
--------------------------------------------------------------------------------
/token-templates/specifications/EThaler/latest/EThaler-spec.docx:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/token-templates/specifications/EThaler/latest/EThaler-spec.docx
--------------------------------------------------------------------------------
/token-templates/specifications/EThaler/latest/EThaler-spec.pdf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/hyperledger-labs/eThaler/HEAD/token-templates/specifications/EThaler/latest/EThaler-spec.pdf
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/math/README.adoc:
--------------------------------------------------------------------------------
1 | = Math
2 |
3 | These are math-related utilities.
4 |
5 | == Libraries
6 |
7 | {{SafeMath}}
8 |
9 | {{Math}}
10 |
--------------------------------------------------------------------------------
/.github/settings.yml:
--------------------------------------------------------------------------------
1 | #
2 | # SPDX-License-Identifier: Apache-2.0
3 | #
4 | repository:
5 | name: eThaler
6 | description: Model a sample CBDC in TTF and implement in Besu
7 | archived: true
8 | private: false
9 |
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/config/config.properties.bak:
--------------------------------------------------------------------------------
1 | BESU_URL=http://127.0.0.1:9545
2 | #ETHALER_CONTRACT_ADDR=0x1a21603d62d0718e5210634BAD9e7Fe711634215
3 | ETHALER_CONTRACT_ADDR=0x8B6C06367c83b940cB35f904be9517572C78ED02
4 | LOG_LEVEL=INFO
--------------------------------------------------------------------------------
/src/CLI/gradle/wrapper/gradle-wrapper.properties:
--------------------------------------------------------------------------------
1 | distributionBase=GRADLE_USER_HOME
2 | distributionPath=wrapper/dists
3 | distributionUrl=https\://services.gradle.org/distributions/gradle-5.2.1-bin.zip
4 | zipStoreBase=GRADLE_USER_HOME
5 | zipStorePath=wrapper/dists
6 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/cryptography/README.adoc:
--------------------------------------------------------------------------------
1 | = Cryptography
2 |
3 | This collection of libraries provides simple and safe ways to use different cryptographic primitives.
4 |
5 | == Libraries
6 |
7 | {{ECDSA}}
8 |
9 | {{MerkleProof}}
10 |
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/config/config.properties:
--------------------------------------------------------------------------------
1 | #BESU_URL=http://127.0.0.1:9545
2 | #localETHALER_CONTRACT_ADDR=0x1a21603d62d0718e5210634BAD9e7Fe711634215
3 | BESU_URL=http://192.168.0.140:8545
4 | ETHALER_CONTRACT_ADDR=0xE62b93777e666224cC8029c21a31311554e2F10E
5 | LOG_LEVEL=INFO
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/ownership/README.adoc:
--------------------------------------------------------------------------------
1 | = Ownership
2 |
3 | Contract modules for simple authorization and access control mechanisms.
4 |
5 | TIP: For more complex needs see xref:access.adoc[Access].
6 |
7 | == Contracts
8 |
9 | {{Ownable}}
10 |
11 | {{Secondary}}
12 |
--------------------------------------------------------------------------------
/src/CLI/config/config.properties:
--------------------------------------------------------------------------------
1 | #modify as required for your env
2 | BESU_URL=http://100.35.18.66:8545
3 | ETHALER_CONTRACT_ADDR=0x620f34A905eB4937514B6C393B6c73c6B01e62Af
4 | LOG_LEVEL=INFO
5 | #for ethereum development
6 | CHAIN_ID=2018
7 | POLLING_ATTEMPTS=10
8 | #value in milliseconds
9 | POLLING_INTERVAL=1000
10 |
--------------------------------------------------------------------------------
/token-templates/formulas/tF{d,t,p,c,SC}/latest/tF{d,t,p,c,SC}.proto:
--------------------------------------------------------------------------------
1 | syntax = "proto3";
2 |
3 | package eThaler;
4 |
5 | import "tokens.proto";
6 | import "google/protobuf/any.proto";
7 |
8 | option csharp_namespace = "TTI.TTF.TokenTemplates.eThaler";
9 | option java_package = "org.tti.ttf.TokenTemplates.eThaler";
10 | option java_multiple_files = true;
11 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/payment/README.adoc:
--------------------------------------------------------------------------------
1 | = Payment
2 |
3 | NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned!
4 |
5 | == Utilities
6 |
7 | {{PaymentSplitter}}
8 |
9 | {{PullPayment}}
10 |
11 | == Escrow
12 |
13 | {{Escrow}}
14 |
15 | {{ConditionalEscrow}}
16 |
17 | {{RefundEscrow}}
18 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Holder.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC721Receiver.sol";
4 |
5 | contract ERC721Holder is IERC721Receiver {
6 | function onERC721Received(address, address, uint256, bytes memory) public returns (bytes4) {
7 | return this.onERC721Received.selector;
8 | }
9 | }
10 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/README.adoc:
--------------------------------------------------------------------------------
1 | = Utilities
2 |
3 | Miscellaneous contracts containing utility functions, often related to working with different data types.
4 |
5 | == Contracts
6 |
7 | {{Address}}
8 |
9 | {{SafeCast}}
10 |
11 | {{Arrays}}
12 |
13 | {{EnumerableSet}}
14 |
15 | {{Create2}}
16 |
17 | {{ReentrancyGuard}}
18 |
--------------------------------------------------------------------------------
/src/CLI/PrepareeThalerClient.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | #Copyright 2020 Swapshub
4 | #Licensed under the Apache License, Version 2.0 (the "License");
5 | #you may not use this file except in compliance with the License.
6 | #You may obtain a copy of the License at
7 | #http://www.apache.org/licenses/LICENSE-2.0
8 |
9 |
10 | gradlew build copyJars createeThalerClientScript
--------------------------------------------------------------------------------
/src/CLI/PrepareeThalerClient.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | REM Copyright 2020 Swapshub
3 | REM Licensed under the Apache License, Version 2.0 (the "License");
4 | REM you may not use this file except in compliance with the License.
5 | REM You may obtain a copy of the License at
6 | REM http://www.apache.org/licenses/LICENSE-2.0
7 |
8 |
9 | gradlew build copyJars createeThalerClientScript
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n
5 |
6 |
7 |
8 |
9 |
10 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/README.adoc:
--------------------------------------------------------------------------------
1 | = Access
2 |
3 | NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned!
4 |
5 | == Library
6 |
7 | {{Roles}}
8 |
9 | == Roles
10 |
11 | {{CapperRole}}
12 |
13 | {{MinterRole}}
14 |
15 | {{PauserRole}}
16 |
17 | {{SignerRole}}
18 |
19 | {{WhitelistAdminRole}}
20 |
21 | {{WhitelistedRole}}
22 |
--------------------------------------------------------------------------------
/src/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "eThaler",
3 | "version": "1.0.0",
4 | "description": "",
5 | "main": "truffle-config.js",
6 | "directories": {
7 | "test": "test"
8 | },
9 | "scripts": {
10 | "test": "echo \"Error: no test specified\" && exit 1"
11 | },
12 | "author": "",
13 | "license": "ISC",
14 | "devDependencies": {
15 | "openzeppelin-solidity": "^2.4.0"
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC1155/ERC1155Receiver.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC1155Receiver.sol";
4 | import "../../introspection/ERC165.sol";
5 |
6 | contract ERC1155Receiver is ERC165, IERC1155Receiver {
7 | constructor() public {
8 | _registerInterface(
9 | ERC1155Receiver(0).onERC1155Received.selector ^
10 | ERC1155Receiver(0).onERC1155BatchReceived.selector
11 | );
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/IERC721Full.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC721.sol";
4 | import "./IERC721Enumerable.sol";
5 | import "./IERC721Metadata.sol";
6 |
7 | /**
8 | * @title ERC-721 Non-Fungible Token Standard, full implementation interface
9 | * @dev See https://eips.ethereum.org/EIPS/eip-721
10 | */
11 | contract IERC721Full is IERC721, IERC721Enumerable, IERC721Metadata {
12 | // solhint-disable-previous-line no-empty-blocks
13 | }
14 |
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/140d8.json:
--------------------------------------------------------------------------------
1 | {"address":"ce880c57b65543e37d80d7ddd71db8a3ade94f81","id":"ec6e6754-b22f-443b-aa24-514479150520","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"91b5794b17d11b59b84ac6aaa19cf77b5d261c557c2131009d602f46ed81a01d","cipherparams":{"iv":"f1765323527bd44e7a63db43295b95da"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"397d76fa4b430aaf19114a77118bc154ddeae7748ed76a67ad17069ad0eb3363"},"mac":"e61bf48227fb010bbdc21ec381c3accc9d98ff8147c398a6d05b474665e9a91d"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/140d9.json:
--------------------------------------------------------------------------------
1 | {"address":"dd8b50c96453587a609f09cd05a24a4714d7f1ef","id":"75d7e1e1-8868-4546-8fd8-ecce692c93a3","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"ca836281f222c50d9022d2f8bb62a1ccb25726107c8b273b1df10f505e734d16","cipherparams":{"iv":"bc43cd9415f30654be8f99b6aecbe23e"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"ac56365a3cd910fa61b8e233621e41b7339b3d76d579b2945b0dfcac19cb4688"},"mac":"ddb231f662a8f3c8822871676810fa34b3854ac8731f19fb625dfb4a23d15ddf"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/140new.json:
--------------------------------------------------------------------------------
1 | {"address":"fe3b557e8fb62b89f4916b721be55ceb828dbd73","id":"f922104b-c4b5-450a-a5b6-cc808a8b5d58","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"ca38c5395e5376e93fb718645d87a1af82870cc953faf0dbfa0871d498edcad6","cipherparams":{"iv":"bcbc244818f5810672f2e850e2227d92"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"2183a00006bee951ac496b0d74ba2d62e5e86486897e7aea7dba1e3d809330f2"},"mac":"ac84a0f1e1c9fe568125bdea9e029831712235b52f8e0538af09f24ba75c6e7b"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/140new1.json:
--------------------------------------------------------------------------------
1 | {"address":"9866b3ceabd1a5e8c390e177228894867806754f","id":"f84c1bbe-3987-491f-abd0-1ea935514e81","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"8d5f5470ff80be34e1a98db883a867f0a15183c29fe5e3e7e67f7c8983e0ca1c","cipherparams":{"iv":"3b14ad44d410d60630d204a48c8e2c09"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"01c38a99e1265ea5ba3e6950b16cd8471e60a6195c8e967266858aaefdfbf8e7"},"mac":"3e5d79af671324cb55c31b96da7a299e6386c3ef2fff52abcaa8b5eb8ef00e43"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/140owner.json:
--------------------------------------------------------------------------------
1 | {"address":"fe3b557e8fb62b89f4916b721be55ceb828dbd73","id":"6b04222e-169b-428d-af87-cec46a66dbd2","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"760d8558de24f8ae0f1e07d42c2f571fb1922ff8b168be43f9a6c53bbf0faa14","cipherparams":{"iv":"9838740ab9d161d1b8af9d45a8aa9820"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"428c6e09a4b8614458499127a88bfa9540d924ab5835311743d9738deb12334c"},"mac":"bce4d691ad05ed5c3ae73965e7ca65109b99d68abced8bcefeb0a91789d66156"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/CBWallet.json:
--------------------------------------------------------------------------------
1 | {"address":"7c27de1467f5119815c79ad095e763288060eb64","id":"c75346c1-443d-47e7-9064-aeda9576b89e","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"27540aa0e9f352a73790a462d9ac8474f6923f43349c9515b181ece788d1302b","cipherparams":{"iv":"267bde8b62fc1d29ba988c0d09a5aa7e"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"0c732f5b06fbb28d16c0ba90172418141e8863647e5462d273428128277c827c"},"mac":"faa0e1628cdfae0d92cd6327ec2600cde52f20046e6226e830a0bd46f4dd1d36"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/test.json:
--------------------------------------------------------------------------------
1 | {"address":"1d697fc9c79e28e1e10298a13746d678e1be64dc","id":"e209ddc1-5b0f-4ac7-9a31-50abbf84232e","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"695ad2edca76281cea9aa6b151b87022f9a5c7f25f19a98aa980a49735668668","cipherparams":{"iv":"5133e636db551a7171c8ef09351ac842"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":262144,"p":1,"r":8,"salt":"01ffff30af581ec93923a3d5cd32fa4f43e78c371c51c57ab4a3b88e035df9d6"},"mac":"b574ddf31766ed50e73b4e056190a2b80e2d05234fcf7be5b6280a41babe1f96"}}
--------------------------------------------------------------------------------
/src/CLI/src/main/resources/wallets/Dealer1Wallet.json:
--------------------------------------------------------------------------------
1 | {"address":"d511e7a5f3cb36c18e535ce0454f1819e2e0c366","id":"a95e6636-d73c-42f8-91f6-50fb56286a7b","version":3,"crypto":{"cipher":"aes-128-ctr","ciphertext":"3d1a1b9989e853f5ea928cb7f6cbc0cf7a9072a7b461233fe7db08f1defb7ad9","cipherparams":{"iv":"3b9dde09fd75119db8045f3019a36ad0"},"kdf":"scrypt","kdfparams":{"dklen":32,"n":4096,"p":6,"r":8,"salt":"8e73b341dd2b42d4d7bf5acc83ea2bbecfff9ba61e2ecc5d83609625171b39d3"},"mac":"781784e1846b55b387e40a816b902082cc4936414ac16b915d123150f6ed924d"}}
--------------------------------------------------------------------------------
/src/migrations/2_deploy_eThaler.js:
--------------------------------------------------------------------------------
1 |
2 | // Note: Interfaces and abstract contracts cannot be deployed and hence not linked
3 | const SafeMath = artifacts.require("SafeMath");
4 | const ERC1155 = artifacts.require("ERC1155");
5 | const eThaler = artifacts.require("eThaler");
6 |
7 | module.exports = function(deployer) {
8 | deployer.deploy(SafeMath);
9 | deployer.link(SafeMath, ERC1155);
10 | deployer.deploy(ERC1155);
11 | deployer.link(ERC1155, eThaler);
12 | deployer.deploy(eThaler);
13 | };
14 |
15 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/IERC721Metadata.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC721.sol";
4 |
5 | /**
6 | * @title ERC-721 Non-Fungible Token Standard, optional metadata extension
7 | * @dev See https://eips.ethereum.org/EIPS/eip-721
8 | */
9 | contract IERC721Metadata is IERC721 {
10 | function name() external view returns (string memory);
11 | function symbol() external view returns (string memory);
12 | function tokenURI(uint256 tokenId) external view returns (string memory);
13 | }
14 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC1155/README.md:
--------------------------------------------------------------------------------
1 | ---
2 | sections:
3 | - title: Core
4 | contracts:
5 | - IERC1155
6 | - ERC1155
7 | - IERC1155Receiver
8 | ---
9 |
10 | This set of interfaces and contracts are all related to the [ERC1155 Multi Token Standard](https://eips.ethereum.org/EIPS/eip-1155).
11 |
12 | The EIP consists of two interfaces which fulfill different roles, found here as `IERC1155` and `IERC1155Receiver`. Only `IERC1155` is required for a contract to be ERC1155 compliant. The basic functionality is implemented in `ERC1155`.
13 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/IERC721Enumerable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC721.sol";
4 |
5 | /**
6 | * @title ERC-721 Non-Fungible Token Standard, optional enumeration extension
7 | * @dev See https://eips.ethereum.org/EIPS/eip-721
8 | */
9 | contract IERC721Enumerable is IERC721 {
10 | function totalSupply() public view returns (uint256);
11 | function tokenOfOwnerByIndex(address owner, uint256 index) public view returns (uint256 tokenId);
12 |
13 | function tokenByIndex(uint256 index) public view returns (uint256);
14 | }
15 |
--------------------------------------------------------------------------------
/src/CLI/StarteThalerClient.sh:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 |
4 | #Copyright 2020 Swapshub
5 | #Licensed under the Apache License, Version 2.0 (the "License");
6 | #you may not use this file except in compliance with the License.
7 | #You may obtain a copy of the License at
8 | #http://www.apache.org/licenses/LICENSE-2.0
9 |
10 |
11 | ARG=""
12 |
13 | echo 'Starting eThalerClient'
14 | START_DIR=`pwd`
15 |
16 | #change directory
17 | cd build/runeThalerClient
18 |
19 | if [ $# -eq 1 ]
20 | then
21 | ARG=$1
22 | ./eThalerClient $START_DIR $ARG
23 | else
24 | ./eThalerClient $START_DIR
25 | fi
26 |
27 |
28 |
29 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC1155/ERC1155Holder.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC1155Receiver.sol";
4 |
5 | contract ERC1155Holder is ERC1155Receiver {
6 |
7 | function onERC1155Received(address, address, uint256, uint256, bytes calldata) external returns (bytes4)
8 | {
9 | return this.onERC1155Received.selector;
10 | }
11 |
12 |
13 | function onERC1155BatchReceived(address, address, uint256[] calldata, uint256[] calldata, bytes calldata) external returns (bytes4)
14 | {
15 | return this.onERC1155BatchReceived.selector;
16 | }
17 | }
18 |
--------------------------------------------------------------------------------
/src/CLI/StarteThalerClient.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | REM Copyright 2020 Swapshub
3 | REM Licensed under the Apache License, Version 2.0 (the "License");
4 | REM you may not use this file except in compliance with the License.
5 | REM You may obtain a copy of the License at
6 | REM http://www.apache.org/licenses/LICENSE-2.0
7 |
8 | @echo off
9 | @rem echo Starting eThalerClient
10 |
11 |
12 | set DIRNAME=%~dp0
13 |
14 | @rem echo %DIRNAME%
15 |
16 | set CMD_LINE_ARGS= %DIRNAME% %*
17 |
18 | @rem change directory
19 | @rem cd build/runeThalerClient
20 | call ./build/runeThalerClient/eThalerClient.bat %CMD_LINE_ARGS%
--------------------------------------------------------------------------------
/src/contracts/Migrations.sol:
--------------------------------------------------------------------------------
1 | pragma solidity >=0.4.21 <0.7.0;
2 |
3 | contract Migrations {
4 | address public owner;
5 | uint public last_completed_migration;
6 |
7 | constructor() public {
8 | owner = msg.sender;
9 | }
10 |
11 | modifier restricted() {
12 | if (msg.sender == owner) _;
13 | }
14 |
15 | function setCompleted(uint completed) public restricted {
16 | last_completed_migration = completed;
17 | }
18 |
19 | function upgrade(address new_address) public restricted {
20 | Migrations upgraded = Migrations(new_address);
21 | upgraded.setCompleted(last_completed_migration);
22 | }
23 | }
24 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/README.adoc:
--------------------------------------------------------------------------------
1 | = Crowdsales
2 |
3 | NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned!
4 |
5 | == Core
6 |
7 | {{Crowdsale}}
8 |
9 | == Emission
10 |
11 | {{AllowanceCrowdsale}}
12 |
13 | {{MintedCrowdsale}}
14 |
15 | == Validation
16 |
17 | {{CappedCrowdsale}}
18 |
19 | {{IndividuallyCappedCrowdsale}}
20 |
21 | {{PausableCrowdsale}}
22 |
23 | {{TimedCrowdsale}}
24 |
25 | {{WhitelistCrowdsale}}
26 |
27 | == Distribution
28 |
29 | {{FinalizableCrowdsale}}
30 |
31 | {{PostDeliveryCrowdsale}}
32 |
33 | {{RefundableCrowdsale}}
34 |
35 | {{RefundablePostDeliveryCrowdsale}}
36 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC777/README.adoc:
--------------------------------------------------------------------------------
1 | = ERC 777
2 | This set of interfaces and contracts are all related to the [ERC777 token standard](https://eips.ethereum.org/EIPS/eip-777).
3 |
4 | TIP: For an overview of ERC777 tokens and a walkthrough on how to create a token contract read our xref:ROOT:tokens.adoc#ERC777[ERC777 guide].
5 |
6 | The token behavior itself is implemented in the core contracts: {IERC777}, {ERC777}.
7 |
8 | Additionally there are interfaces used to develop contracts that react to token movements: {IERC777Sender}, {IERC777Recipient}.
9 |
10 | == Core
11 |
12 | {{IERC777}}
13 |
14 | {{ERC777}}
15 |
16 | == Hooks
17 |
18 | {{IERC777Sender}}
19 |
20 | {{IERC777Recipient}}
21 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Burnable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "./ERC721.sol";
5 |
6 | /**
7 | * @title ERC721 Burnable Token
8 | * @dev ERC721 Token that can be irreversibly burned (destroyed).
9 | */
10 | contract ERC721Burnable is Context, ERC721 {
11 | /**
12 | * @dev Burns a specific ERC721 token.
13 | * @param tokenId uint256 id of the ERC721 token to be burned.
14 | */
15 | function burn(uint256 tokenId) public {
16 | //solhint-disable-next-line max-line-length
17 | require(_isApprovedOrOwner(_msgSender(), tokenId), "ERC721Burnable: caller is not owner nor approved");
18 | _burn(tokenId);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Full.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC721.sol";
4 | import "./ERC721Enumerable.sol";
5 | import "./ERC721Metadata.sol";
6 |
7 | /**
8 | * @title Full ERC721 Token
9 | * @dev This implementation includes all the required and some optional functionality of the ERC721 standard
10 | * Moreover, it includes approve all functionality using operator terminology.
11 | *
12 | * See https://eips.ethereum.org/EIPS/eip-721
13 | */
14 | contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata {
15 | constructor (string memory name, string memory symbol) public ERC721Metadata(name, symbol) {
16 | // solhint-disable-previous-line no-empty-blocks
17 | }
18 | }
19 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/drafts/ERC1046/ERC20Metadata.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../token/ERC20/IERC20.sol";
4 |
5 | /**
6 | * @title ERC-1047 Token Metadata
7 | * @dev See https://eips.ethereum.org/EIPS/eip-1046
8 | * @dev {tokenURI} must respond with a URI that implements https://eips.ethereum.org/EIPS/eip-1047
9 | */
10 | contract ERC20Metadata {
11 | string private _tokenURI;
12 |
13 | constructor (string memory tokenURI_) public {
14 | _setTokenURI(tokenURI_);
15 | }
16 |
17 | function tokenURI() external view returns (string memory) {
18 | return _tokenURI;
19 | }
20 |
21 | function _setTokenURI(string memory tokenURI_) internal {
22 | _tokenURI = tokenURI_;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/introspection/IERC1820Implementer.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Interface for an ERC1820 implementer, as defined in the
5 | * https://eips.ethereum.org/EIPS/eip-1820#interface-implementation-erc1820implementerinterface[EIP].
6 | * Used by contracts that will be registered as implementers in the
7 | * {IERC1820Registry}.
8 | */
9 | interface IERC1820Implementer {
10 | /**
11 | * @dev Returns a special value (`ERC1820_ACCEPT_MAGIC`) if this contract
12 | * implements `interfaceHash` for `account`.
13 | *
14 | * See {IERC1820Registry-setInterfaceImplementer}.
15 | */
16 | function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32);
17 | }
18 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Pausable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC721.sol";
4 | import "../../lifecycle/Pausable.sol";
5 |
6 | /**
7 | * @title ERC721 Non-Fungible Pausable token
8 | * @dev ERC721 modified with pausable transfers.
9 | */
10 | contract ERC721Pausable is ERC721, Pausable {
11 | function approve(address to, uint256 tokenId) public whenNotPaused {
12 | super.approve(to, tokenId);
13 | }
14 |
15 | function setApprovalForAll(address to, bool approved) public whenNotPaused {
16 | super.setApprovalForAll(to, approved);
17 | }
18 |
19 | function _transferFrom(address from, address to, uint256 tokenId) internal whenNotPaused {
20 | super._transferFrom(from, to, tokenId);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Mintable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC20.sol";
4 | import "../../access/roles/MinterRole.sol";
5 |
6 | /**
7 | * @dev Extension of {ERC20} that adds a set of accounts with the {MinterRole},
8 | * which have permission to mint (create) new tokens as they see fit.
9 | *
10 | * At construction, the deployer of the contract is the only minter.
11 | */
12 | contract ERC20Mintable is ERC20, MinterRole {
13 | /**
14 | * @dev See {ERC20-_mint}.
15 | *
16 | * Requirements:
17 | *
18 | * - the caller must have the {MinterRole}.
19 | */
20 | function mint(address account, uint256 amount) public onlyMinter returns (bool) {
21 | _mint(account, amount);
22 | return true;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Burnable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "./ERC20.sol";
5 |
6 | /**
7 | * @dev Extension of {ERC20} that allows token holders to destroy both their own
8 | * tokens and those that they have an allowance for, in a way that can be
9 | * recognized off-chain (via event analysis).
10 | */
11 | contract ERC20Burnable is Context, ERC20 {
12 | /**
13 | * @dev Destroys `amount` tokens from the caller.
14 | *
15 | * See {ERC20-_burn}.
16 | */
17 | function burn(uint256 amount) public {
18 | _burn(_msgSender(), amount);
19 | }
20 |
21 | /**
22 | * @dev See {ERC20-_burnFrom}.
23 | */
24 | function burnFrom(address account, uint256 amount) public {
25 | _burnFrom(account, amount);
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/CLI/.gitignore:
--------------------------------------------------------------------------------
1 | # Created by .ignore support plugin (hsz.mobi)
2 | ### Java binary and package
3 | *.class
4 | *.jar
5 | *.war
6 | *.ear
7 |
8 | # virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
9 | hs_err_pid*
10 |
11 | ### Gradle files
12 | .gradle
13 | /build
14 | /out
15 | */build/**
16 | */out/**
17 | gradle.properties
18 | # Ignore Gradle GUI config
19 | gradle-app.setting
20 | # Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
21 | !gradle-wrapper.jar
22 | # Cache of project
23 | .gradletasknamecache
24 | # Work around https://youtrack.jetbrains.com/issue/IDEA-116898
25 | # gradle/wrapper/gradle-wrapper.properties
26 |
27 | # IntelliJ IDEA files
28 | .idea/**
29 | *.iml
30 | geth.sh
31 |
32 | # Sphinx generated docs
33 | docs/build
34 |
35 | /allSampleFiles/**
36 |
37 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/distribution/RefundablePostDeliveryCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./RefundableCrowdsale.sol";
4 | import "./PostDeliveryCrowdsale.sol";
5 |
6 |
7 | /**
8 | * @title RefundablePostDeliveryCrowdsale
9 | * @dev Extension of RefundableCrowdsale contract that only delivers the tokens
10 | * once the crowdsale has closed and the goal met, preventing refunds to be issued
11 | * to token holders.
12 | */
13 | contract RefundablePostDeliveryCrowdsale is RefundableCrowdsale, PostDeliveryCrowdsale {
14 | function withdrawTokens(address beneficiary) public {
15 | require(finalized(), "RefundablePostDeliveryCrowdsale: not finalized");
16 | require(goalReached(), "RefundablePostDeliveryCrowdsale: goal not reached");
17 |
18 | super.withdrawTokens(beneficiary);
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/drafts/README.adoc:
--------------------------------------------------------------------------------
1 | = Drafts
2 |
3 | Contracts in this category should be considered unstable. They are as thoroughly reviewed as everything else in OpenZeppelin Contracts, but we have doubts about their API so we don't commit to backwards compatibility. This means these contracts can receive breaking changes in a minor version, so you should pay special attention to the changelog when upgrading. For anything that is outside of this category you can read more about xref:ROOT:api-stability.adoc[API Stability].
4 |
5 | NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned!
6 |
7 | == ERC 20
8 |
9 | {{ERC20Migrator}}
10 |
11 | {{ERC20Snapshot}}
12 |
13 | {{TokenVesting}}
14 |
15 | == Miscellaneous
16 |
17 | {{Counters}}
18 |
19 | {{SignedSafeMath}}
20 |
21 | == ERC 1046
22 |
23 | {{ERC1046}}
24 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/payment/escrow/ConditionalEscrow.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./Escrow.sol";
4 |
5 | /**
6 | * @title ConditionalEscrow
7 | * @dev Base abstract escrow to only allow withdrawal if a condition is met.
8 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here.
9 | */
10 | contract ConditionalEscrow is Escrow {
11 | /**
12 | * @dev Returns whether an address is allowed to withdraw their funds. To be
13 | * implemented by derived contracts.
14 | * @param payee The destination address of the funds.
15 | */
16 | function withdrawalAllowed(address payee) public view returns (bool);
17 |
18 | function withdraw(address payable payee) public {
19 | require(withdrawalAllowed(payee), "ConditionalEscrow: payee is not allowed to withdraw");
20 | super.withdraw(payee);
21 | }
22 | }
23 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/introspection/IERC165.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Interface of the ERC165 standard, as defined in the
5 | * https://eips.ethereum.org/EIPS/eip-165[EIP].
6 | *
7 | * Implementers can declare support of contract interfaces, which can then be
8 | * queried by others ({ERC165Checker}).
9 | *
10 | * For an implementation, see {ERC165}.
11 | */
12 | interface IERC165 {
13 | /**
14 | * @dev Returns true if this contract implements the interface defined by
15 | * `interfaceId`. See the corresponding
16 | * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified[EIP section]
17 | * to learn more about how these ids are created.
18 | *
19 | * This function call must use less than 30 000 gas.
20 | */
21 | function supportsInterface(bytes4 interfaceId) external view returns (bool);
22 | }
23 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/math/Math.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Standard math utilities missing in the Solidity language.
5 | */
6 | library Math {
7 | /**
8 | * @dev Returns the largest of two numbers.
9 | */
10 | function max(uint256 a, uint256 b) internal pure returns (uint256) {
11 | return a >= b ? a : b;
12 | }
13 |
14 | /**
15 | * @dev Returns the smallest of two numbers.
16 | */
17 | function min(uint256 a, uint256 b) internal pure returns (uint256) {
18 | return a < b ? a : b;
19 | }
20 |
21 | /**
22 | * @dev Returns the average of two numbers. The result is rounded towards
23 | * zero.
24 | */
25 | function average(uint256 a, uint256 b) internal pure returns (uint256) {
26 | // (a + b) / 2 can overflow, so we distribute
27 | return (a / 2) + (b / 2) + ((a % 2 + b % 2) / 2);
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721MetadataMintable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC721Metadata.sol";
4 | import "../../access/roles/MinterRole.sol";
5 |
6 |
7 | /**
8 | * @title ERC721MetadataMintable
9 | * @dev ERC721 minting logic with metadata.
10 | */
11 | contract ERC721MetadataMintable is ERC721, ERC721Metadata, MinterRole {
12 | /**
13 | * @dev Function to mint tokens.
14 | * @param to The address that will receive the minted tokens.
15 | * @param tokenId The token id to mint.
16 | * @param tokenURI The token URI of the minted token.
17 | * @return A boolean that indicates if the operation was successful.
18 | */
19 | function mintWithTokenURI(address to, uint256 tokenId, string memory tokenURI) public onlyMinter returns (bool) {
20 | _mint(to, tokenId);
21 | _setTokenURI(tokenId, tokenURI);
22 | return true;
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "@openzeppelin/contracts",
3 | "version": "2.5.0",
4 | "description": "Secure Smart Contract library for Solidity",
5 | "files": [
6 | "**/*.sol",
7 | "/build/contracts/*.json",
8 | "!/mocks",
9 | "!/examples"
10 | ],
11 | "scripts": {
12 | "prepare": "bash ../scripts/prepare-contracts-package.sh"
13 | },
14 | "repository": {
15 | "type": "git",
16 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts.git"
17 | },
18 | "keywords": [
19 | "solidity",
20 | "ethereum",
21 | "smart",
22 | "contracts",
23 | "security",
24 | "zeppelin"
25 | ],
26 | "author": "OpenZeppelin Community ",
27 | "license": "MIT",
28 | "bugs": {
29 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues"
30 | },
31 | "homepage": "https://openzeppelin.com/contracts/"
32 | }
33 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/validation/WhitelistCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 | import "../Crowdsale.sol";
3 | import "../../access/roles/WhitelistedRole.sol";
4 |
5 |
6 | /**
7 | * @title WhitelistCrowdsale
8 | * @dev Crowdsale in which only whitelisted users can contribute.
9 | */
10 | contract WhitelistCrowdsale is WhitelistedRole, Crowdsale {
11 | /**
12 | * @dev Extend parent behavior requiring beneficiary to be whitelisted. Note that no
13 | * restriction is imposed on the account sending the transaction.
14 | * @param _beneficiary Token beneficiary
15 | * @param _weiAmount Amount of wei contributed
16 | */
17 | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view {
18 | require(isWhitelisted(_beneficiary), "WhitelistCrowdsale: beneficiary doesn't have the Whitelisted role");
19 | super._preValidatePurchase(_beneficiary, _weiAmount);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/emission/MintedCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../Crowdsale.sol";
4 | import "../../token/ERC20/ERC20Mintable.sol";
5 |
6 | /**
7 | * @title MintedCrowdsale
8 | * @dev Extension of Crowdsale contract whose tokens are minted in each purchase.
9 | * Token ownership should be transferred to MintedCrowdsale for minting.
10 | */
11 | contract MintedCrowdsale is Crowdsale {
12 | /**
13 | * @dev Overrides delivery by minting tokens upon purchase.
14 | * @param beneficiary Token purchaser
15 | * @param tokenAmount Number of tokens to be minted
16 | */
17 | function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
18 | // Potentially dangerous assumption about the type of the token.
19 | require(
20 | ERC20Mintable(address(token())).mint(beneficiary, tokenAmount),
21 | "MintedCrowdsale: minting failed"
22 | );
23 | }
24 | }
25 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/validation/PausableCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../Crowdsale.sol";
4 | import "../../lifecycle/Pausable.sol";
5 |
6 | /**
7 | * @title PausableCrowdsale
8 | * @dev Extension of Crowdsale contract where purchases can be paused and unpaused by the pauser role.
9 | */
10 | contract PausableCrowdsale is Crowdsale, Pausable {
11 | /**
12 | * @dev Validation of an incoming purchase. Use require statements to revert state when conditions are not met.
13 | * Use super to concatenate validations.
14 | * Adds the validation that the crowdsale must not be paused.
15 | * @param _beneficiary Address performing the token purchase
16 | * @param _weiAmount Value in wei involved in the purchase
17 | */
18 | function _preValidatePurchase(address _beneficiary, uint256 _weiAmount) internal view whenNotPaused {
19 | return super._preValidatePurchase(_beneficiary, _weiAmount);
20 | }
21 | }
22 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/drafts/Strings.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @title Strings
5 | * @dev String operations.
6 | */
7 | library Strings {
8 | /**
9 | * @dev Converts a `uint256` to a `string`.
10 | * via OraclizeAPI - MIT licence
11 | * https://github.com/oraclize/ethereum-api/blob/b42146b063c7d6ee1358846c198246239e9360e8/oraclizeAPI_0.4.25.sol
12 | */
13 | function fromUint256(uint256 value) internal pure returns (string memory) {
14 | if (value == 0) {
15 | return "0";
16 | }
17 | uint256 temp = value;
18 | uint256 digits;
19 | while (temp != 0) {
20 | digits++;
21 | temp /= 10;
22 | }
23 | bytes memory buffer = new bytes(digits);
24 | uint256 index = digits - 1;
25 | temp = value;
26 | while (temp != 0) {
27 | buffer[index--] = byte(uint8(48 + temp % 10));
28 | temp /= 10;
29 | }
30 | return string(buffer);
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/docs/erc-20 vs erc-1155.md:
--------------------------------------------------------------------------------
1 | ERC 20 & ERC 1155
2 | The TTF behavior model had to use a specific platform for eThaler implementation. eThaler uses
3 | Consensys Quorum which is an Ethereum variant, specifically targeted for enterprises. ERC 20
4 | and ERC 1155 are Ethereum specific standards. ERC 20 has wide adoption. Most of the tokens
5 | on the Ethereum mainnet are implemented using ERC 20. Defi tokens are also implemented in
6 | ERC 20.
7 | ERC 1155 is an evolving multi-token standard. eThaler implementation used ERC 1155 with
8 | some extensions. There are several reasons for choosing ERC 1155. In ERC 1155, a single solidity
9 | smart contract can implement multiple tokens. A single eThaler smart contract implementation
10 | addresses multiple wCBDC implementations, each with slightly different characteristics. For
11 | example, in response to COVID-19, CBs announced several special purpose financings schemes
12 | with specific restrictions in a short period of time. The ERC 1155 contract could be used to
13 | implement such schemes and also can track the effectiveness of such programs.
14 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/Roles.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @title Roles
5 | * @dev Library for managing addresses assigned to a Role.
6 | */
7 | library Roles {
8 | struct Role {
9 | mapping (address => bool) bearer;
10 | }
11 |
12 | /**
13 | * @dev Give an account access to this role.
14 | */
15 | function add(Role storage role, address account) internal {
16 | require(!has(role, account), "Roles: account already has role");
17 | role.bearer[account] = true;
18 | }
19 |
20 | /**
21 | * @dev Remove an account's access to this role.
22 | */
23 | function remove(Role storage role, address account) internal {
24 | require(has(role, account), "Roles: account does not have role");
25 | role.bearer[account] = false;
26 | }
27 |
28 | /**
29 | * @dev Check if an account has this role.
30 | * @return bool
31 | */
32 | function has(Role storage role, address account) internal view returns (bool) {
33 | require(account != address(0), "Roles: account is the zero address");
34 | return role.bearer[account];
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Capped.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC20Mintable.sol";
4 |
5 | /**
6 | * @dev Extension of {ERC20Mintable} that adds a cap to the supply of tokens.
7 | */
8 | contract ERC20Capped is ERC20Mintable {
9 | uint256 private _cap;
10 |
11 | /**
12 | * @dev Sets the value of the `cap`. This value is immutable, it can only be
13 | * set once during construction.
14 | */
15 | constructor (uint256 cap) public {
16 | require(cap > 0, "ERC20Capped: cap is 0");
17 | _cap = cap;
18 | }
19 |
20 | /**
21 | * @dev Returns the cap on the token's total supply.
22 | */
23 | function cap() public view returns (uint256) {
24 | return _cap;
25 | }
26 |
27 | /**
28 | * @dev See {ERC20Mintable-mint}.
29 | *
30 | * Requirements:
31 | *
32 | * - `value` must not cause the total supply to go over the cap.
33 | */
34 | function _mint(address account, uint256 value) internal {
35 | require(totalSupply().add(value) <= _cap, "ERC20Capped: cap exceeded");
36 | super._mint(account, value);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) 2016-2019 zOS Global Limited
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining
6 | a copy of this software and associated documentation files (the
7 | "Software"), to deal in the Software without restriction, including
8 | without limitation the rights to use, copy, modify, merge, publish,
9 | distribute, sublicense, and/or sell copies of the Software, and to
10 | permit persons to whom the Software is furnished to do so, subject to
11 | the following conditions:
12 |
13 | The above copyright notice and this permission notice shall be included
14 | in all copies or substantial portions of the Software.
15 |
16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 | OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19 | IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
21 | TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
22 | SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/GSN/Context.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /*
4 | * @dev Provides information about the current execution context, including the
5 | * sender of the transaction and its data. While these are generally available
6 | * via msg.sender and msg.data, they should not be accessed in such a direct
7 | * manner, since when dealing with GSN meta-transactions the account sending and
8 | * paying for execution may not be the actual sender (as far as an application
9 | * is concerned).
10 | *
11 | * This contract is only required for intermediate, library-like contracts.
12 | */
13 | contract Context {
14 | // Empty internal constructor, to prevent people from mistakenly deploying
15 | // an instance of this contract, which should be used via inheritance.
16 | constructor () internal { }
17 | // solhint-disable-previous-line no-empty-blocks
18 |
19 | function _msgSender() internal view returns (address payable) {
20 | return msg.sender;
21 | }
22 |
23 | function _msgData() internal view returns (bytes memory) {
24 | this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
25 | return msg.data;
26 | }
27 | }
28 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/roles/CapperRole.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../Roles.sol";
5 |
6 | contract CapperRole is Context {
7 | using Roles for Roles.Role;
8 |
9 | event CapperAdded(address indexed account);
10 | event CapperRemoved(address indexed account);
11 |
12 | Roles.Role private _cappers;
13 |
14 | constructor () internal {
15 | _addCapper(_msgSender());
16 | }
17 |
18 | modifier onlyCapper() {
19 | require(isCapper(_msgSender()), "CapperRole: caller does not have the Capper role");
20 | _;
21 | }
22 |
23 | function isCapper(address account) public view returns (bool) {
24 | return _cappers.has(account);
25 | }
26 |
27 | function addCapper(address account) public onlyCapper {
28 | _addCapper(account);
29 | }
30 |
31 | function renounceCapper() public {
32 | _removeCapper(_msgSender());
33 | }
34 |
35 | function _addCapper(address account) internal {
36 | _cappers.add(account);
37 | emit CapperAdded(account);
38 | }
39 |
40 | function _removeCapper(address account) internal {
41 | _cappers.remove(account);
42 | emit CapperRemoved(account);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/roles/MinterRole.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../Roles.sol";
5 |
6 | contract MinterRole is Context {
7 | using Roles for Roles.Role;
8 |
9 | event MinterAdded(address indexed account);
10 | event MinterRemoved(address indexed account);
11 |
12 | Roles.Role private _minters;
13 |
14 | constructor () internal {
15 | _addMinter(_msgSender());
16 | }
17 |
18 | modifier onlyMinter() {
19 | require(isMinter(_msgSender()), "MinterRole: caller does not have the Minter role");
20 | _;
21 | }
22 |
23 | function isMinter(address account) public view returns (bool) {
24 | return _minters.has(account);
25 | }
26 |
27 | function addMinter(address account) public onlyMinter {
28 | _addMinter(account);
29 | }
30 |
31 | function renounceMinter() public {
32 | _removeMinter(_msgSender());
33 | }
34 |
35 | function _addMinter(address account) internal {
36 | _minters.add(account);
37 | emit MinterAdded(account);
38 | }
39 |
40 | function _removeMinter(address account) internal {
41 | _minters.remove(account);
42 | emit MinterRemoved(account);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/roles/PauserRole.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../Roles.sol";
5 |
6 | contract PauserRole is Context {
7 | using Roles for Roles.Role;
8 |
9 | event PauserAdded(address indexed account);
10 | event PauserRemoved(address indexed account);
11 |
12 | Roles.Role private _pausers;
13 |
14 | constructor () internal {
15 | _addPauser(_msgSender());
16 | }
17 |
18 | modifier onlyPauser() {
19 | require(isPauser(_msgSender()), "PauserRole: caller does not have the Pauser role");
20 | _;
21 | }
22 |
23 | function isPauser(address account) public view returns (bool) {
24 | return _pausers.has(account);
25 | }
26 |
27 | function addPauser(address account) public onlyPauser {
28 | _addPauser(account);
29 | }
30 |
31 | function renouncePauser() public {
32 | _removePauser(_msgSender());
33 | }
34 |
35 | function _addPauser(address account) internal {
36 | _pausers.add(account);
37 | emit PauserAdded(account);
38 | }
39 |
40 | function _removePauser(address account) internal {
41 | _pausers.remove(account);
42 | emit PauserRemoved(account);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/roles/SignerRole.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../Roles.sol";
5 |
6 | contract SignerRole is Context {
7 | using Roles for Roles.Role;
8 |
9 | event SignerAdded(address indexed account);
10 | event SignerRemoved(address indexed account);
11 |
12 | Roles.Role private _signers;
13 |
14 | constructor () internal {
15 | _addSigner(_msgSender());
16 | }
17 |
18 | modifier onlySigner() {
19 | require(isSigner(_msgSender()), "SignerRole: caller does not have the Signer role");
20 | _;
21 | }
22 |
23 | function isSigner(address account) public view returns (bool) {
24 | return _signers.has(account);
25 | }
26 |
27 | function addSigner(address account) public onlySigner {
28 | _addSigner(account);
29 | }
30 |
31 | function renounceSigner() public {
32 | _removeSigner(_msgSender());
33 | }
34 |
35 | function _addSigner(address account) internal {
36 | _signers.add(account);
37 | emit SignerAdded(account);
38 | }
39 |
40 | function _removeSigner(address account) internal {
41 | _signers.remove(account);
42 | emit SignerRemoved(account);
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC777/IERC777Recipient.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Interface of the ERC777TokensRecipient standard as defined in the EIP.
5 | *
6 | * Accounts can be notified of {IERC777} tokens being sent to them by having a
7 | * contract implement this interface (contract holders can be their own
8 | * implementer) and registering it on the
9 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].
10 | *
11 | * See {IERC1820Registry} and {ERC1820Implementer}.
12 | */
13 | interface IERC777Recipient {
14 | /**
15 | * @dev Called by an {IERC777} token contract whenever tokens are being
16 | * moved or created into a registered account (`to`). The type of operation
17 | * is conveyed by `from` being the zero address or not.
18 | *
19 | * This call occurs _after_ the token contract's state is updated, so
20 | * {IERC777-balanceOf}, etc., can be used to query the post-operation state.
21 | *
22 | * This function may revert to prevent the operation from being executed.
23 | */
24 | function tokensReceived(
25 | address operator,
26 | address from,
27 | address to,
28 | uint256 amount,
29 | bytes calldata userData,
30 | bytes calldata operatorData
31 | ) external;
32 | }
33 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC777/IERC777Sender.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Interface of the ERC777TokensSender standard as defined in the EIP.
5 | *
6 | * {IERC777} Token holders can be notified of operations performed on their
7 | * tokens by having a contract implement this interface (contract holders can be
8 | * their own implementer) and registering it on the
9 | * https://eips.ethereum.org/EIPS/eip-1820[ERC1820 global registry].
10 | *
11 | * See {IERC1820Registry} and {ERC1820Implementer}.
12 | */
13 | interface IERC777Sender {
14 | /**
15 | * @dev Called by an {IERC777} token contract whenever a registered holder's
16 | * (`from`) tokens are about to be moved or destroyed. The type of operation
17 | * is conveyed by `to` being the zero address or not.
18 | *
19 | * This call occurs _before_ the token contract's state is updated, so
20 | * {IERC777-balanceOf}, etc., can be used to query the pre-operation state.
21 | *
22 | * This function may revert to prevent the operation from being executed.
23 | */
24 | function tokensToSend(
25 | address operator,
26 | address from,
27 | address to,
28 | uint256 amount,
29 | bytes calldata userData,
30 | bytes calldata operatorData
31 | ) external;
32 | }
33 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/IERC721Receiver.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @title ERC721 token receiver interface
5 | * @dev Interface for any contract that wants to support safeTransfers
6 | * from ERC721 asset contracts.
7 | */
8 | contract IERC721Receiver {
9 | /**
10 | * @notice Handle the receipt of an NFT
11 | * @dev The ERC721 smart contract calls this function on the recipient
12 | * after a {IERC721-safeTransferFrom}. This function MUST return the function selector,
13 | * otherwise the caller will revert the transaction. The selector to be
14 | * returned can be obtained as `this.onERC721Received.selector`. This
15 | * function MAY throw to revert and reject the transfer.
16 | * Note: the ERC721 contract address is always the message sender.
17 | * @param operator The address which called `safeTransferFrom` function
18 | * @param from The address which previously owned the token
19 | * @param tokenId The NFT identifier which is being transferred
20 | * @param data Additional data with no specified format
21 | * @return bytes4 `bytes4(keccak256("onERC721Received(address,address,uint256,bytes)"))`
22 | */
23 | function onERC721Received(address operator, address from, uint256 tokenId, bytes memory data)
24 | public returns (bytes4);
25 | }
26 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Pausable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC20.sol";
4 | import "../../lifecycle/Pausable.sol";
5 |
6 | /**
7 | * @title Pausable token
8 | * @dev ERC20 with pausable transfers and allowances.
9 | *
10 | * Useful if you want to stop trades until the end of a crowdsale, or have
11 | * an emergency switch for freezing all token transfers in the event of a large
12 | * bug.
13 | */
14 | contract ERC20Pausable is ERC20, Pausable {
15 | function transfer(address to, uint256 value) public whenNotPaused returns (bool) {
16 | return super.transfer(to, value);
17 | }
18 |
19 | function transferFrom(address from, address to, uint256 value) public whenNotPaused returns (bool) {
20 | return super.transferFrom(from, to, value);
21 | }
22 |
23 | function approve(address spender, uint256 value) public whenNotPaused returns (bool) {
24 | return super.approve(spender, value);
25 | }
26 |
27 | function increaseAllowance(address spender, uint256 addedValue) public whenNotPaused returns (bool) {
28 | return super.increaseAllowance(spender, addedValue);
29 | }
30 |
31 | function decreaseAllowance(address spender, uint256 subtractedValue) public whenNotPaused returns (bool) {
32 | return super.decreaseAllowance(spender, subtractedValue);
33 | }
34 | }
35 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC1155/IERC1155.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../introspection/IERC165.sol";
4 |
5 | /**
6 | @title ERC-1155 Multi Token Standard basic interface
7 | @dev See https://eips.ethereum.org/EIPS/eip-1155
8 | */
9 | contract IERC1155 is IERC165 {
10 | event TransferSingle(address indexed operator, address indexed from, address indexed to, uint256 id, uint256 value);
11 |
12 | event TransferBatch(address indexed operator, address indexed from, address indexed to, uint256[] ids, uint256[] values);
13 |
14 | event ApprovalForAll(address indexed account, address indexed operator, bool approved);
15 |
16 | event URI(string value, uint256 indexed id);
17 |
18 | function balanceOf(address account, uint256 id) public view returns (uint256);
19 |
20 | function balanceOfBatch(address[] memory accounts, uint256[] memory ids) public view returns (uint256[] memory);
21 |
22 | function setApprovalForAll(address operator, bool approved) external;
23 |
24 | function isApprovedForAll(address account, address operator) external view returns (bool);
25 |
26 | function safeTransferFrom(address from, address to, uint256 id, uint256 value, bytes calldata data) external;
27 |
28 | function safeBatchTransferFrom(address from, address to, uint256[] calldata ids, uint256[] calldata values, bytes calldata data) external;
29 | }
30 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/cryptography/MerkleProof.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev These functions deal with verification of Merkle trees (hash trees),
5 | */
6 | library MerkleProof {
7 | /**
8 | * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree
9 | * defined by `root`. For this, a `proof` must be provided, containing
10 | * sibling hashes on the branch from the leaf to the root of the tree. Each
11 | * pair of leaves and each pair of pre-images are assumed to be sorted.
12 | */
13 | function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {
14 | bytes32 computedHash = leaf;
15 |
16 | for (uint256 i = 0; i < proof.length; i++) {
17 | bytes32 proofElement = proof[i];
18 |
19 | if (computedHash <= proofElement) {
20 | // Hash(current computed hash + current element of the proof)
21 | computedHash = keccak256(abi.encodePacked(computedHash, proofElement));
22 | } else {
23 | // Hash(current element of the proof + current computed hash)
24 | computedHash = keccak256(abi.encodePacked(proofElement, computedHash));
25 | }
26 | }
27 |
28 | // Check if the computed hash (root) is equal to the provided root
29 | return computedHash == root;
30 | }
31 | }
32 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/GSN/README.adoc:
--------------------------------------------------------------------------------
1 | = Gas Station Network (GSN)
2 |
3 | _Available since v2.4.0._
4 |
5 | This set of contracts provide all the tools required to make a contract callable via the https://gsn.openzeppelin.com[Gas Station Network].
6 |
7 | TIP: If you're new to the GSN, head over to our xref:learn::sending-gasless-transactions.adoc[overview of the system] and basic guide to xref:ROOT:gsn.adoc[creating a GSN-capable contract].
8 |
9 | The core contract a recipient must inherit from is {GSNRecipient}: it includes all necessary interfaces, as well as some helper methods to make interacting with the GSN easier.
10 |
11 | Utilities to make writing xref:ROOT:gsn-strategies.adoc[GSN strategies] easy are available in {GSNRecipient}, or you can simply use one of our pre-made strategies:
12 |
13 | * {GSNRecipientERC20Fee} charges the end user for gas costs in an application-specific xref:ROOT:tokens.adoc#ERC20[ERC20 token]
14 | * {GSNRecipientSignature} accepts all relayed calls that have been signed by a trusted third party (e.g. a private key in a backend)
15 |
16 | You can also take a look at the two contract interfaces that make up the GSN protocol: {IRelayRecipient} and {IRelayHub}, but you won't need to use those directly.
17 |
18 | == Recipient
19 |
20 | {{GSNRecipient}}
21 |
22 | == Strategies
23 |
24 | {{GSNRecipientSignature}}
25 | {{GSNRecipientERC20Fee}}
26 |
27 | == Protocol
28 |
29 | {{IRelayRecipient}}
30 | {{IRelayHub}}
31 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/introspection/ERC1820Implementer.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC1820Implementer.sol";
4 |
5 | /**
6 | * @dev Implementation of the {IERC1820Implementer} interface.
7 | *
8 | * Contracts may inherit from this and call {_registerInterfaceForAddress} to
9 | * declare their willingness to be implementers.
10 | * {IERC1820Registry-setInterfaceImplementer} should then be called for the
11 | * registration to be complete.
12 | */
13 | contract ERC1820Implementer is IERC1820Implementer {
14 | bytes32 constant private ERC1820_ACCEPT_MAGIC = keccak256(abi.encodePacked("ERC1820_ACCEPT_MAGIC"));
15 |
16 | mapping(bytes32 => mapping(address => bool)) private _supportedInterfaces;
17 |
18 | /**
19 | * See {IERC1820Implementer-canImplementInterfaceForAddress}.
20 | */
21 | function canImplementInterfaceForAddress(bytes32 interfaceHash, address account) external view returns (bytes32) {
22 | return _supportedInterfaces[interfaceHash][account] ? ERC1820_ACCEPT_MAGIC : bytes32(0x00);
23 | }
24 |
25 | /**
26 | * @dev Declares the contract as willing to be an implementer of
27 | * `interfaceHash` for `account`.
28 | *
29 | * See {IERC1820Registry-setInterfaceImplementer} and
30 | * {IERC1820Registry-interfaceHash}.
31 | */
32 | function _registerInterfaceForAddress(bytes32 interfaceHash, address account) internal {
33 | _supportedInterfaces[interfaceHash][account] = true;
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/validation/CappedCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../math/SafeMath.sol";
4 | import "../Crowdsale.sol";
5 |
6 | /**
7 | * @title CappedCrowdsale
8 | * @dev Crowdsale with a limit for total contributions.
9 | */
10 | contract CappedCrowdsale is Crowdsale {
11 | using SafeMath for uint256;
12 |
13 | uint256 private _cap;
14 |
15 | /**
16 | * @dev Constructor, takes maximum amount of wei accepted in the crowdsale.
17 | * @param cap Max amount of wei to be contributed
18 | */
19 | constructor (uint256 cap) public {
20 | require(cap > 0, "CappedCrowdsale: cap is 0");
21 | _cap = cap;
22 | }
23 |
24 | /**
25 | * @return the cap of the crowdsale.
26 | */
27 | function cap() public view returns (uint256) {
28 | return _cap;
29 | }
30 |
31 | /**
32 | * @dev Checks whether the cap has been reached.
33 | * @return Whether the cap was reached
34 | */
35 | function capReached() public view returns (bool) {
36 | return weiRaised() >= _cap;
37 | }
38 |
39 | /**
40 | * @dev Extend parent behavior requiring purchase to respect the funding cap.
41 | * @param beneficiary Token purchaser
42 | * @param weiAmount Amount of wei contributed
43 | */
44 | function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
45 | super._preValidatePurchase(beneficiary, weiAmount);
46 | require(weiRaised().add(weiAmount) <= _cap, "CappedCrowdsale: cap exceeded");
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/roles/WhitelistAdminRole.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../Roles.sol";
5 |
6 | /**
7 | * @title WhitelistAdminRole
8 | * @dev WhitelistAdmins are responsible for assigning and removing Whitelisted accounts.
9 | */
10 | contract WhitelistAdminRole is Context {
11 | using Roles for Roles.Role;
12 |
13 | event WhitelistAdminAdded(address indexed account);
14 | event WhitelistAdminRemoved(address indexed account);
15 |
16 | Roles.Role private _whitelistAdmins;
17 |
18 | constructor () internal {
19 | _addWhitelistAdmin(_msgSender());
20 | }
21 |
22 | modifier onlyWhitelistAdmin() {
23 | require(isWhitelistAdmin(_msgSender()), "WhitelistAdminRole: caller does not have the WhitelistAdmin role");
24 | _;
25 | }
26 |
27 | function isWhitelistAdmin(address account) public view returns (bool) {
28 | return _whitelistAdmins.has(account);
29 | }
30 |
31 | function addWhitelistAdmin(address account) public onlyWhitelistAdmin {
32 | _addWhitelistAdmin(account);
33 | }
34 |
35 | function renounceWhitelistAdmin() public {
36 | _removeWhitelistAdmin(_msgSender());
37 | }
38 |
39 | function _addWhitelistAdmin(address account) internal {
40 | _whitelistAdmins.add(account);
41 | emit WhitelistAdminAdded(account);
42 | }
43 |
44 | function _removeWhitelistAdmin(address account) internal {
45 | _whitelistAdmins.remove(account);
46 | emit WhitelistAdminRemoved(account);
47 | }
48 | }
49 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/ownership/Secondary.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../GSN/Context.sol";
4 | /**
5 | * @dev A Secondary contract can only be used by its primary account (the one that created it).
6 | */
7 | contract Secondary is Context {
8 | address private _primary;
9 |
10 | /**
11 | * @dev Emitted when the primary contract changes.
12 | */
13 | event PrimaryTransferred(
14 | address recipient
15 | );
16 |
17 | /**
18 | * @dev Sets the primary account to the one that is creating the Secondary contract.
19 | */
20 | constructor () internal {
21 | address msgSender = _msgSender();
22 | _primary = msgSender;
23 | emit PrimaryTransferred(msgSender);
24 | }
25 |
26 | /**
27 | * @dev Reverts if called from any account other than the primary.
28 | */
29 | modifier onlyPrimary() {
30 | require(_msgSender() == _primary, "Secondary: caller is not the primary account");
31 | _;
32 | }
33 |
34 | /**
35 | * @return the address of the primary.
36 | */
37 | function primary() public view returns (address) {
38 | return _primary;
39 | }
40 |
41 | /**
42 | * @dev Transfers contract to a new primary.
43 | * @param recipient The address of new primary.
44 | */
45 | function transferPrimary(address recipient) public onlyPrimary {
46 | require(recipient != address(0), "Secondary: new primary is the zero address");
47 | _primary = recipient;
48 | emit PrimaryTransferred(recipient);
49 | }
50 | }
51 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/distribution/FinalizableCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../math/SafeMath.sol";
4 | import "../validation/TimedCrowdsale.sol";
5 |
6 | /**
7 | * @title FinalizableCrowdsale
8 | * @dev Extension of TimedCrowdsale with a one-off finalization action, where one
9 | * can do extra work after finishing.
10 | */
11 | contract FinalizableCrowdsale is TimedCrowdsale {
12 | using SafeMath for uint256;
13 |
14 | bool private _finalized;
15 |
16 | event CrowdsaleFinalized();
17 |
18 | constructor () internal {
19 | _finalized = false;
20 | }
21 |
22 | /**
23 | * @return true if the crowdsale is finalized, false otherwise.
24 | */
25 | function finalized() public view returns (bool) {
26 | return _finalized;
27 | }
28 |
29 | /**
30 | * @dev Must be called after crowdsale ends, to do some extra finalization
31 | * work. Calls the contract's finalization function.
32 | */
33 | function finalize() public {
34 | require(!_finalized, "FinalizableCrowdsale: already finalized");
35 | require(hasClosed(), "FinalizableCrowdsale: not closed");
36 |
37 | _finalized = true;
38 |
39 | _finalization();
40 | emit CrowdsaleFinalized();
41 | }
42 |
43 | /**
44 | * @dev Can be overridden to add finalization logic. The overriding function
45 | * should call super._finalization() to ensure the chain of finalization is
46 | * executed entirely.
47 | */
48 | function _finalization() internal {
49 | // solhint-disable-previous-line no-empty-blocks
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/drafts/Counters.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../math/SafeMath.sol";
4 |
5 | /**
6 | * @title Counters
7 | * @author Matt Condon (@shrugs)
8 | * @dev Provides counters that can only be incremented or decremented by one. This can be used e.g. to track the number
9 | * of elements in a mapping, issuing ERC721 ids, or counting request ids.
10 | *
11 | * Include with `using Counters for Counters.Counter;`
12 | * Since it is not possible to overflow a 256 bit integer with increments of one, `increment` can skip the {SafeMath}
13 | * overflow check, thereby saving gas. This does assume however correct usage, in that the underlying `_value` is never
14 | * directly accessed.
15 | */
16 | library Counters {
17 | using SafeMath for uint256;
18 |
19 | struct Counter {
20 | // This variable should never be directly accessed by users of the library: interactions must be restricted to
21 | // the library's function. As of Solidity v0.5.2, this cannot be enforced, though there is a proposal to add
22 | // this feature: see https://github.com/ethereum/solidity/issues/4637
23 | uint256 _value; // default: 0
24 | }
25 |
26 | function current(Counter storage counter) internal view returns (uint256) {
27 | return counter._value;
28 | }
29 |
30 | function increment(Counter storage counter) internal {
31 | // The {SafeMath} overflow check can be skipped here, see the comment at the top
32 | counter._value += 1;
33 | }
34 |
35 | function decrement(Counter storage counter) internal {
36 | counter._value = counter._value.sub(1);
37 | }
38 | }
39 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/Arrays.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../math/Math.sol";
4 |
5 | /**
6 | * @dev Collection of functions related to array types.
7 | */
8 | library Arrays {
9 | /**
10 | * @dev Searches a sorted `array` and returns the first index that contains
11 | * a value greater or equal to `element`. If no such index exists (i.e. all
12 | * values in the array are strictly less than `element`), the array length is
13 | * returned. Time complexity O(log n).
14 | *
15 | * `array` is expected to be sorted in ascending order, and to contain no
16 | * repeated elements.
17 | */
18 | function findUpperBound(uint256[] storage array, uint256 element) internal view returns (uint256) {
19 | if (array.length == 0) {
20 | return 0;
21 | }
22 |
23 | uint256 low = 0;
24 | uint256 high = array.length;
25 |
26 | while (low < high) {
27 | uint256 mid = Math.average(low, high);
28 |
29 | // Note that mid will always be strictly less than high (i.e. it will be a valid array index)
30 | // because Math.average rounds down (it does integer division with truncation).
31 | if (array[mid] > element) {
32 | high = mid;
33 | } else {
34 | low = mid + 1;
35 | }
36 | }
37 |
38 | // At this point `low` is the exclusive upper bound. We will return the inclusive upper bound.
39 | if (low > 0 && array[low - 1] == element) {
40 | return low - 1;
41 | } else {
42 | return low;
43 | }
44 | }
45 | }
46 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Mintable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ERC721.sol";
4 | import "../../access/roles/MinterRole.sol";
5 |
6 | /**
7 | * @title ERC721Mintable
8 | * @dev ERC721 minting logic.
9 | */
10 | contract ERC721Mintable is ERC721, MinterRole {
11 | /**
12 | * @dev Function to mint tokens.
13 | * @param to The address that will receive the minted token.
14 | * @param tokenId The token id to mint.
15 | * @return A boolean that indicates if the operation was successful.
16 | */
17 | function mint(address to, uint256 tokenId) public onlyMinter returns (bool) {
18 | _mint(to, tokenId);
19 | return true;
20 | }
21 |
22 | /**
23 | * @dev Function to safely mint tokens.
24 | * @param to The address that will receive the minted token.
25 | * @param tokenId The token id to mint.
26 | * @return A boolean that indicates if the operation was successful.
27 | */
28 | function safeMint(address to, uint256 tokenId) public onlyMinter returns (bool) {
29 | _safeMint(to, tokenId);
30 | return true;
31 | }
32 |
33 | /**
34 | * @dev Function to safely mint tokens.
35 | * @param to The address that will receive the minted token.
36 | * @param tokenId The token id to mint.
37 | * @param _data bytes data to send along with a safe transfer check.
38 | * @return A boolean that indicates if the operation was successful.
39 | */
40 | function safeMint(address to, uint256 tokenId, bytes memory _data) public onlyMinter returns (bool) {
41 | _safeMint(to, tokenId, _data);
42 | return true;
43 | }
44 | }
45 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/README.adoc:
--------------------------------------------------------------------------------
1 | = ERC 20
2 |
3 | This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-20[ERC20 Token Standard].
4 |
5 | TIP: For an overview of ERC20 tokens and a walkthrough on how to create a token contract read our xref:ROOT:tokens.adoc#ERC20[ERC20 guide].
6 |
7 | There a few core contracts that implement the behavior specified in the EIP:
8 |
9 | * {IERC20}: the interface all ERC20 implementations should conform to
10 | * {ERC20}: the base implementation of the ERC20 interface
11 | * {ERC20Detailed}: includes the <>,
12 | <> and <>
13 | optional standard extension to the base interface
14 |
15 | Additionally there are multiple custom extensions, including:
16 |
17 | * designation of addresses that can create token supply ({ERC20Mintable}), with an optional maximum cap ({ERC20Capped})
18 | * destruction of own tokens ({ERC20Burnable})
19 | * designation of addresses that can pause token operations for all users ({ERC20Pausable}).
20 |
21 | Finally, there are some utilities to interact with ERC20 contracts in various ways.
22 |
23 | * {SafeERC20} is a wrapper around the interface that eliminates the need to handle boolean return values.
24 | * {TokenTimelock} can hold tokens for a beneficiary until a specified time.
25 |
26 | NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned!
27 |
28 | == Core
29 |
30 | {{IERC20}}
31 |
32 | {{ERC20}}
33 |
34 | {{ERC20Detailed}}
35 |
36 | == Extensions
37 |
38 | {{ERC20Mintable}}
39 |
40 | {{ERC20Burnable}}
41 |
42 | {{ERC20Pausable}}
43 |
44 | {{ERC20Capped}}
45 |
46 | == Utilities
47 |
48 | {{SafeERC20}}
49 |
50 | {{TokenTimelock}}
51 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/introspection/README.adoc:
--------------------------------------------------------------------------------
1 | = Introspection
2 |
3 | This set of interfaces and contracts deal with [type introspection](https://en.wikipedia.org/wiki/Type_introspection) of contracts, that is, examining which functions can be called on them. This is usually referred to as a contract's _interface_.
4 |
5 | Ethereum contracts have no native concept of an interface, so applications must usually simply trust they are not making an incorrect call. For trusted setups this is a non-issue, but often unknown and untrusted third-party addresses need to be interacted with. There may even not be any direct calls to them! (e.g. `ERC20` tokens may be sent to a contract that lacks a way to transfer them out of it, locking them forever). In these cases, a contract _declaring_ its interface can be very helpful in preventing errors.
6 |
7 | There are two main ways to approach this.
8 |
9 | * Locally, where a contract implements `IERC165` and declares an interface, and a second one queries it directly via `ERC165Checker`.
10 | * Globally, where a global and unique registry (`IERC1820Registry`) is used to register implementers of a certain interface (`IERC1820Implementer`). It is then the registry that is queried, which allows for more complex setups, like contracts implementing interfaces for externally-owned accounts.
11 |
12 | Note that, in all cases, accounts simply _declare_ their interfaces, but they are not required to actually implement them. This mechanism can therefore be used to both prevent errors and allow for complex interactions (see `ERC777`), but it must not be relied on for security.
13 |
14 | == Local
15 |
16 | {{IERC165}}
17 |
18 | {{ERC165}}
19 |
20 | {{ERC165Checker}}
21 |
22 | == Global
23 |
24 | {{IERC1820Registry}}
25 |
26 | {{IERC1820Implementer}}
27 |
28 | {{ERC1820Implementer}}
29 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | # eThaler
2 |
3 |
4 | # Short Description
5 | Model a sample CBDC in TTF and implement in Besu
6 |
7 | # Scope of Lab
8 |
9 | Model a sample CBDC (eThaler) in TTF (Token Taxonomy Framework) and implement as EIP 1155 or EIP 20 in Besu. A fiat token will remove one of the major hurdles for any transfer of value network, a fundamental requirement for frictionless digital capital markets. The initial plan is to come out with a PoC as soon as possible (within 6 weeks). Implement eThaler as a wholesale token. Further work may be needed to transition into a retail token. Gap analysis and a design review will be conducted before wholescale work starts, so the design can transition easily into a retail token.
10 |
11 |
12 | Use the composable TTF token model and produce a eThaler definition in JSON.
13 | Use the eThaler definition to create all artifacts using available TTF tooling.
14 | Implement the interfaces and opther properties in Besu using an implementation standard of EIP 1155 or EIP 20.
15 |
16 | # Method
17 |
18 | The method is to develop a model using a TTF driven process. This will be used to develop a number of artifacts, which can then be driven to an EIP 1155 compatible token.
19 |
20 | [Reference to the eThaler process file](../master/docs/eThalerModelProcess.md "Model process file")
21 |
22 | # Initial Committers
23 |
24 | https://github.com/petermetz - Peter Somogyvari Accenture
25 | https://github.com/kelly-cooper - Kelly Cooper Educator
26 | https://github.com/vipinsun - Vipin Bharathan dlt.nyc
27 | https://github.com/mmani99 - Mani Pillai Swapshub
28 | https://github.com/xragrawal - Ravikant Agrawal Infosys
29 | https://github.com/junjikatto - Junji Katto Itau bank
30 |
31 | # Sponsor
32 |
33 | - https://github.com/vipinsun - Chair of the Identity workgroup
34 |
35 | # Pre-existing repository
36 | Not Applicable
37 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/access/roles/WhitelistedRole.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../Roles.sol";
5 | import "./WhitelistAdminRole.sol";
6 |
7 | /**
8 | * @title WhitelistedRole
9 | * @dev Whitelisted accounts have been approved by a WhitelistAdmin to perform certain actions (e.g. participate in a
10 | * crowdsale). This role is special in that the only accounts that can add it are WhitelistAdmins (who can also remove
11 | * it), and not Whitelisteds themselves.
12 | */
13 | contract WhitelistedRole is Context, WhitelistAdminRole {
14 | using Roles for Roles.Role;
15 |
16 | event WhitelistedAdded(address indexed account);
17 | event WhitelistedRemoved(address indexed account);
18 |
19 | Roles.Role private _whitelisteds;
20 |
21 | modifier onlyWhitelisted() {
22 | require(isWhitelisted(_msgSender()), "WhitelistedRole: caller does not have the Whitelisted role");
23 | _;
24 | }
25 |
26 | function isWhitelisted(address account) public view returns (bool) {
27 | return _whitelisteds.has(account);
28 | }
29 |
30 | function addWhitelisted(address account) public onlyWhitelistAdmin {
31 | _addWhitelisted(account);
32 | }
33 |
34 | function removeWhitelisted(address account) public onlyWhitelistAdmin {
35 | _removeWhitelisted(account);
36 | }
37 |
38 | function renounceWhitelisted() public {
39 | _removeWhitelisted(_msgSender());
40 | }
41 |
42 | function _addWhitelisted(address account) internal {
43 | _whitelisteds.add(account);
44 | emit WhitelistedAdded(account);
45 | }
46 |
47 | function _removeWhitelisted(address account) internal {
48 | _whitelisteds.remove(account);
49 | emit WhitelistedRemoved(account);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/ERC20Detailed.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC20.sol";
4 |
5 | /**
6 | * @dev Optional functions from the ERC20 standard.
7 | */
8 | contract ERC20Detailed is IERC20 {
9 | string private _name;
10 | string private _symbol;
11 | uint8 private _decimals;
12 |
13 | /**
14 | * @dev Sets the values for `name`, `symbol`, and `decimals`. All three of
15 | * these values are immutable: they can only be set once during
16 | * construction.
17 | */
18 | constructor (string memory name, string memory symbol, uint8 decimals) public {
19 | _name = name;
20 | _symbol = symbol;
21 | _decimals = decimals;
22 | }
23 |
24 | /**
25 | * @dev Returns the name of the token.
26 | */
27 | function name() public view returns (string memory) {
28 | return _name;
29 | }
30 |
31 | /**
32 | * @dev Returns the symbol of the token, usually a shorter version of the
33 | * name.
34 | */
35 | function symbol() public view returns (string memory) {
36 | return _symbol;
37 | }
38 |
39 | /**
40 | * @dev Returns the number of decimals used to get its user representation.
41 | * For example, if `decimals` equals `2`, a balance of `505` tokens should
42 | * be displayed to a user as `5,05` (`505 / 10 ** 2`).
43 | *
44 | * Tokens usually opt for a value of 18, imitating the relationship between
45 | * Ether and Wei.
46 | *
47 | * NOTE: This information is only used for _display_ purposes: it in
48 | * no way affects any of the arithmetic of the contract, including
49 | * {IERC20-balanceOf} and {IERC20-transfer}.
50 | */
51 | function decimals() public view returns (uint8) {
52 | return _decimals;
53 | }
54 | }
55 |
--------------------------------------------------------------------------------
/src/CLI/src/main/java/com/swapshub/ethaler/client/MaskingThread.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2020 Swapshub
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 | http://www.apache.org/licenses/LICENSE-2.0
7 | */
8 |
9 | package com.swapshub.ethaler.client;
10 |
11 | /**
12 | * This class attempts to erase and mask characters echoed to the console.
13 | */
14 |
15 | class MaskingThread extends Thread {
16 | private volatile boolean stop;
17 | private char echochar = '*';
18 |
19 | /**
20 | * @param prompt The prompt displayed to the user
21 | */
22 | public MaskingThread(String prompt) {
23 | System.out.print(prompt);
24 | }
25 |
26 | /**
27 | * Begin masking until asked to stop.
28 | */
29 | public void run() {
30 |
31 | int priority = Thread.currentThread().getPriority();
32 | Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
33 |
34 | try {
35 | stop = true;
36 | while (stop) {
37 | System.out.print("\010" + echochar);
38 | try {
39 | // attempt masking at this rate
40 | Thread.currentThread().sleep(1);
41 | } catch (InterruptedException iex) {
42 | Thread.currentThread().interrupt();
43 | return;
44 | }
45 | }
46 | } finally { // restore the original priority
47 | Thread.currentThread().setPriority(priority);
48 | }
49 | }
50 |
51 | /**
52 | * Instruct the thread to stop masking.
53 | */
54 | public void stopMasking() {
55 | this.stop = false;
56 | }
57 | }
58 |
--------------------------------------------------------------------------------
/docs/References.md:
--------------------------------------------------------------------------------
1 | # CBDC References
2 |
3 | Andolfatto David, 2015 on Fedcoin, Macromania a blog https://andolfatto.blogspot.com/2015/02/fedcoin-on-desirability-of-government.html
4 |
5 | Barontini Christian and Holden Henry, 2019, BIS papers #101 https://www.bis.org/publ/bppdf/bispap101.pdf
6 |
7 | Bech, M. and R Garratt. (2017) “Central bank cryptocurrencies”, BIS Quarterly Review, September 2017, Bank for International Settlements.
8 |
9 | Brainard, L speech by Feb Governor on Monetary Policy, Technology, and Globalisation Panel at “Monetary Policy: The Challenges Ahead,” . https://www.federalreserve.gov/newsevents/speech/files/brainard20191218a.pdf
10 | Bouchaud M, Lyons T, Saint Olive M, Tims K 2020 Central banks and the future of digital money https://cdn2.hubspot.net/hubfs/4795067/Enterprise/ConsenSys-CBDC-White-Paper_final_2020-01-20.pdf
11 | Coppola F. (2019) “The Case for People’s Quantitative Easing”, Polity Press (pp 52–43)
12 | The Digital Dollar Project
13 | Jinze, Etienne ( 2019) China’s CBDC, Binance research paper . https://research.binance.com/analysis/china-cbdc#fn14Ren
14 | Konig J P (2014) Fedcoin https://jpkoning.blogspot.com/2014/10/fedcoin.html
15 | Konig J P (2018) Approaches to a Central bank digital currency in Brazil https://www.r3.com/wp-content/uploads/2018/11/CBDC_Brazil_R3.pdf
16 |
17 | Riksbank, e-Krona project report 2, https://www.riksbank.se/en-gb/payments--cash/e-krona/e-krona-reports/e-krona-project-report-2/ more elaborate in pdf form.
18 |
19 | Tobias Adrian, 2019 at the IMF-Swiss National Bank Conference, Zurich, May 2019. “Stablecoins, Central Bank Digital
20 | Currencies, and Cross-Border Payments: A New Look at the International Monetary System” https://www.imf.org/en/News/Articles/2019/05/13/sp051419-stablecoins-central-bank-digital-currencies-and-cross-border-payments
21 |
22 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/introspection/ERC165.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC165.sol";
4 |
5 | /**
6 | * @dev Implementation of the {IERC165} interface.
7 | *
8 | * Contracts may inherit from this and call {_registerInterface} to declare
9 | * their support of an interface.
10 | */
11 | contract ERC165 is IERC165 {
12 | /*
13 | * bytes4(keccak256('supportsInterface(bytes4)')) == 0x01ffc9a7
14 | */
15 | bytes4 private constant _INTERFACE_ID_ERC165 = 0x01ffc9a7;
16 |
17 | /**
18 | * @dev Mapping of interface ids to whether or not it's supported.
19 | */
20 | mapping(bytes4 => bool) private _supportedInterfaces;
21 |
22 | constructor () internal {
23 | // Derived contracts need only register support for their own interfaces,
24 | // we register support for ERC165 itself here
25 | _registerInterface(_INTERFACE_ID_ERC165);
26 | }
27 |
28 | /**
29 | * @dev See {IERC165-supportsInterface}.
30 | *
31 | * Time complexity O(1), guaranteed to always use less than 30 000 gas.
32 | */
33 | function supportsInterface(bytes4 interfaceId) external view returns (bool) {
34 | return _supportedInterfaces[interfaceId];
35 | }
36 |
37 | /**
38 | * @dev Registers the contract as an implementer of the interface defined by
39 | * `interfaceId`. Support of the actual ERC165 interface is automatic and
40 | * registering its interface id is not required.
41 | *
42 | * See {IERC165-supportsInterface}.
43 | *
44 | * Requirements:
45 | *
46 | * - `interfaceId` cannot be the ERC165 invalid interface (`0xffffffff`).
47 | */
48 | function _registerInterface(bytes4 interfaceId) internal {
49 | require(interfaceId != 0xffffffff, "ERC165: invalid interface id");
50 | _supportedInterfaces[interfaceId] = true;
51 | }
52 | }
53 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/emission/AllowanceCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../Crowdsale.sol";
4 | import "../../token/ERC20/IERC20.sol";
5 | import "../../token/ERC20/SafeERC20.sol";
6 | import "../../math/SafeMath.sol";
7 | import "../../math/Math.sol";
8 |
9 | /**
10 | * @title AllowanceCrowdsale
11 | * @dev Extension of Crowdsale where tokens are held by a wallet, which approves an allowance to the crowdsale.
12 | */
13 | contract AllowanceCrowdsale is Crowdsale {
14 | using SafeMath for uint256;
15 | using SafeERC20 for IERC20;
16 |
17 | address private _tokenWallet;
18 |
19 | /**
20 | * @dev Constructor, takes token wallet address.
21 | * @param tokenWallet Address holding the tokens, which has approved allowance to the crowdsale.
22 | */
23 | constructor (address tokenWallet) public {
24 | require(tokenWallet != address(0), "AllowanceCrowdsale: token wallet is the zero address");
25 | _tokenWallet = tokenWallet;
26 | }
27 |
28 | /**
29 | * @return the address of the wallet that will hold the tokens.
30 | */
31 | function tokenWallet() public view returns (address) {
32 | return _tokenWallet;
33 | }
34 |
35 | /**
36 | * @dev Checks the amount of tokens left in the allowance.
37 | * @return Amount of tokens left in the allowance
38 | */
39 | function remainingTokens() public view returns (uint256) {
40 | return Math.min(token().balanceOf(_tokenWallet), token().allowance(_tokenWallet, address(this)));
41 | }
42 |
43 | /**
44 | * @dev Overrides parent behavior by transferring tokens from wallet.
45 | * @param beneficiary Token purchaser
46 | * @param tokenAmount Amount of tokens purchased
47 | */
48 | function _deliverTokens(address beneficiary, uint256 tokenAmount) internal {
49 | token().safeTransferFrom(_tokenWallet, beneficiary, tokenAmount);
50 | }
51 | }
52 |
--------------------------------------------------------------------------------
/src/CLI/ReadMe.txt:
--------------------------------------------------------------------------------
1 | ReadMe for Running eThalerClient application
2 |
3 | Prerequisities
4 |
5 |
6 |
7 | 1. Ensure your java version is 1.8 (for the uninitiated it is Java 8) is installed .
8 |
9 | Gradle 5.1.3 the build tool for
10 | Getting the software and Preparing
11 |
12 | 1. Get "eThaler" project in github .
13 |
14 | 2. Navigate into the foldler "eThaler/src/CLI".
15 |
16 | 3. Execute the "PrepareeThalerClient.bat" (Windows ) or "PrepareeThalerClient.sh" (Linux)
17 | (This builds, copies and creates required script files for running the CLI application)
18 |
19 |
20 | Configuring / Resource needed to run the application.
21 |
22 | 1. "config" directory contains "config.properties" file.
23 | Two properties in this file need to be modified as per the target env
24 | i. BESU_URL=
25 | ii. ETHALER_CONTRACT_ADDR=
26 |
27 | b. "wallets" directory.
28 | Application expects the wallets of "Central Banker" and "Dealer Clients" present in this directory to connect to network.
29 |
30 | To create Wallets
31 |
32 | 1. To create wallet for Central Banker , run "StarteThalerClient.sh createwallet" from "eThaler/src/CLI" folder
33 | This will prompt to provide
34 | a. wallet name
35 | b. wallet password
36 | c. private key used to deploy contract to network
37 |
38 | 2. To create wallet for dealers , run "StarteThalerClient.sh" from "eThaler/src/CLI" folder
39 | This would give 3 options.
40 | Choose option "2 Create brand new wallet"
41 | Give wallet name and password.
42 | Note the wallet account "address" displayed in the console for future use.
43 |
44 | Running :
45 |
46 | 1. Execute the "StarteThalerClient.bat" (Windows) or "StarteThalerClient.sh" (Linux) file from "eThaler/src/CLI" folder
47 | This starts the eThalerClient java CLI application.
48 |
49 | 2. Choose the option "1. Open existing wallet"
50 | Provide the wallet name and password.
51 |
52 |
53 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/drafts/SignedSafeMath.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @title SignedSafeMath
5 | * @dev Signed math operations with safety checks that revert on error.
6 | */
7 | library SignedSafeMath {
8 | int256 constant private INT256_MIN = -2**255;
9 |
10 | /**
11 | * @dev Multiplies two signed integers, reverts on overflow.
12 | */
13 | function mul(int256 a, int256 b) internal pure returns (int256) {
14 | // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
15 | // benefit is lost if 'b' is also tested.
16 | // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
17 | if (a == 0) {
18 | return 0;
19 | }
20 |
21 | require(!(a == -1 && b == INT256_MIN), "SignedSafeMath: multiplication overflow");
22 |
23 | int256 c = a * b;
24 | require(c / a == b, "SignedSafeMath: multiplication overflow");
25 |
26 | return c;
27 | }
28 |
29 | /**
30 | * @dev Integer division of two signed integers truncating the quotient, reverts on division by zero.
31 | */
32 | function div(int256 a, int256 b) internal pure returns (int256) {
33 | require(b != 0, "SignedSafeMath: division by zero");
34 | require(!(b == -1 && a == INT256_MIN), "SignedSafeMath: division overflow");
35 |
36 | int256 c = a / b;
37 |
38 | return c;
39 | }
40 |
41 | /**
42 | * @dev Subtracts two signed integers, reverts on overflow.
43 | */
44 | function sub(int256 a, int256 b) internal pure returns (int256) {
45 | int256 c = a - b;
46 | require((b >= 0 && c <= a) || (b < 0 && c > a), "SignedSafeMath: subtraction overflow");
47 |
48 | return c;
49 | }
50 |
51 | /**
52 | * @dev Adds two signed integers, reverts on overflow.
53 | */
54 | function add(int256 a, int256 b) internal pure returns (int256) {
55 | int256 c = a + b;
56 | require((b >= 0 && c >= a) || (b < 0 && c < a), "SignedSafeMath: addition overflow");
57 |
58 | return c;
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/build/contracts/ERC165NotSupported.json:
--------------------------------------------------------------------------------
1 | {
2 | "fileName": "ERC165NotSupported.sol",
3 | "contractName": "ERC165NotSupported",
4 | "source": "pragma solidity ^0.5.0;\n\ncontract ERC165NotSupported {\n // solhint-disable-previous-line no-empty-blocks\n}\n",
5 | "sourcePath": "contracts/mocks/ERC165/ERC165NotSupported.sol",
6 | "sourceMap": "25:84:58:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;25:84:58;;;;;;;",
7 | "deployedSourceMap": "25:84:58:-;;;;;",
8 | "abi": [],
9 | "ast": {
10 | "absolutePath": "contracts/mocks/ERC165/ERC165NotSupported.sol",
11 | "exportedSymbols": {
12 | "ERC165NotSupported": [
13 | 5825
14 | ]
15 | },
16 | "id": 5826,
17 | "nodeType": "SourceUnit",
18 | "nodes": [
19 | {
20 | "id": 5824,
21 | "literals": [
22 | "solidity",
23 | "^",
24 | "0.5",
25 | ".0"
26 | ],
27 | "nodeType": "PragmaDirective",
28 | "src": "0:23:58"
29 | },
30 | {
31 | "baseContracts": [],
32 | "contractDependencies": [],
33 | "contractKind": "contract",
34 | "documentation": null,
35 | "fullyImplemented": true,
36 | "id": 5825,
37 | "linearizedBaseContracts": [
38 | 5825
39 | ],
40 | "name": "ERC165NotSupported",
41 | "nodeType": "ContractDefinition",
42 | "nodes": [],
43 | "scope": 5826,
44 | "src": "25:84:58"
45 | }
46 | ],
47 | "src": "0:110:58"
48 | },
49 | "bytecode": "0x6080604052348015600f57600080fd5b50603e80601d6000396000f3fe6080604052600080fdfea265627a7a7231582004861c7fcced186597aa1e5df9f432e8c4ff6ab0d5b39c24adef70a33909d28c64736f6c63430005100032",
50 | "deployedBytecode": "0x6080604052600080fdfea265627a7a7231582004861c7fcced186597aa1e5df9f432e8c4ff6ab0d5b39c24adef70a33909d28c64736f6c63430005100032",
51 | "compiler": {
52 | "name": "solc",
53 | "version": "0.5.16+commit.9c3226ce.Emscripten.clang",
54 | "optimizer": {
55 | "enabled": false,
56 | "runs": 200
57 | },
58 | "evmVersion": "petersburg"
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/CLI/src/main/java/com/swapshub/ethaler/client/NetWorkUtil.java:
--------------------------------------------------------------------------------
1 | package com.swapshub.ethaler.client;
2 |
3 | import okhttp3.OkHttpClient;
4 | import org.web3j.protocol.Web3j;
5 | import org.web3j.protocol.http.HttpService;
6 |
7 | import java.util.concurrent.TimeUnit;
8 |
9 | public class NetWorkUtil extends GenUtil {
10 | public NetWorkUtil() {
11 | super();
12 | }
13 |
14 | /**
15 | * Connects to Besu network
16 | */
17 | void connectToNetwork() {
18 | try {
19 | printLog(" BESU_URL got from config file " + EThalerApplication.BESU_URL);
20 | printLog(" Please ensure correct contract address in config.properites file");
21 | web3j = makeConnectionToNetwork(EThalerApplication.BESU_URL);
22 | } catch (Exception ex) {
23 | printLog("Error in connecting to network : " + ex.getMessage());
24 | }
25 | }
26 |
27 | /**
28 | * connects to given url
29 | *
30 | * @param networkURL
31 | * @return
32 | * @throws Exception
33 | */
34 | private Web3j makeConnectionToNetwork(String networkURL) throws Exception {
35 | try {
36 | return Web3j.build(new HttpService(networkURL, createOkHttpClient(), false));
37 | } catch (Exception ex) {
38 | printLog("Error in creating web3j object " + ex.getMessage());
39 | throw ex;
40 | }
41 | }
42 |
43 | /**
44 | * helps in setting various connection related parameters
45 | *
46 | * @return
47 | */
48 | private OkHttpClient createOkHttpClient() {
49 | OkHttpClient.Builder builder = new OkHttpClient.Builder();
50 | configureTimeouts(builder);
51 | return builder.build();
52 | }
53 |
54 | private void configureTimeouts(OkHttpClient.Builder builder) {
55 | Long tos = 3000L;
56 | builder.connectTimeout(tos, TimeUnit.SECONDS);
57 | builder.readTimeout(tos, TimeUnit.SECONDS); // Sets the socket timeout too
58 | builder.writeTimeout(tos, TimeUnit.SECONDS);
59 | }
60 |
61 | }//end of class
62 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/build/contracts/ERC165NotSupported.json:
--------------------------------------------------------------------------------
1 | {
2 | "fileName": "ERC165NotSupported.sol",
3 | "contractName": "ERC165NotSupported",
4 | "source": "pragma solidity ^0.5.0;\n\ncontract ERC165NotSupported {\n // solhint-disable-previous-line no-empty-blocks\n}\n",
5 | "sourcePath": "contracts/mocks/ERC165/ERC165NotSupported.sol",
6 | "sourceMap": "25:84:58:-;;;;8:9:-1;5:2;;;30:1;27;20:12;5:2;25:84:58;;;;;;;",
7 | "deployedSourceMap": "25:84:58:-;;;;;",
8 | "abi": [],
9 | "ast": {
10 | "absolutePath": "contracts/mocks/ERC165/ERC165NotSupported.sol",
11 | "exportedSymbols": {
12 | "ERC165NotSupported": [
13 | 5825
14 | ]
15 | },
16 | "id": 5826,
17 | "nodeType": "SourceUnit",
18 | "nodes": [
19 | {
20 | "id": 5824,
21 | "literals": [
22 | "solidity",
23 | "^",
24 | "0.5",
25 | ".0"
26 | ],
27 | "nodeType": "PragmaDirective",
28 | "src": "0:23:58"
29 | },
30 | {
31 | "baseContracts": [],
32 | "contractDependencies": [],
33 | "contractKind": "contract",
34 | "documentation": null,
35 | "fullyImplemented": true,
36 | "id": 5825,
37 | "linearizedBaseContracts": [
38 | 5825
39 | ],
40 | "name": "ERC165NotSupported",
41 | "nodeType": "ContractDefinition",
42 | "nodes": [],
43 | "scope": 5826,
44 | "src": "25:84:58"
45 | }
46 | ],
47 | "src": "0:110:58"
48 | },
49 | "bytecode": "0x6080604052348015600f57600080fd5b50603e80601d6000396000f3fe6080604052600080fdfea265627a7a7231582004861c7fcced186597aa1e5df9f432e8c4ff6ab0d5b39c24adef70a33909d28c64736f6c63430005100032",
50 | "deployedBytecode": "0x6080604052600080fdfea265627a7a7231582004861c7fcced186597aa1e5df9f432e8c4ff6ab0d5b39c24adef70a33909d28c64736f6c63430005100032",
51 | "compiler": {
52 | "name": "solc",
53 | "version": "0.5.16+commit.9c3226ce.Emscripten.clang",
54 | "optimizer": {
55 | "enabled": false,
56 | "runs": 200
57 | },
58 | "evmVersion": "petersburg"
59 | }
60 | }
61 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/README.adoc:
--------------------------------------------------------------------------------
1 | = ERC 721
2 |
3 | This set of interfaces, contracts, and utilities are all related to the https://eips.ethereum.org/EIPS/eip-721[ERC721 Non-Fungible Token Standard].
4 |
5 | TIP: For a walkthrough on how to create an ERC721 token read our xref:ROOT:tokens.adoc#ERC721[ERC721 guide].
6 |
7 | The EIP consists of three interfaces, found here as {IERC721}, {IERC721Metadata}, and {IERC721Enumerable}. Only the first one is required in a contract to be ERC721 compliant.
8 |
9 | Each interface is implemented separately in {ERC721}, {ERC721Metadata}, and {ERC721Enumerable}. You can choose the subset of functionality you would like to support in your token by combining the
10 | desired subset through inheritance.
11 |
12 | The fully featured token implementing all three interfaces is prepackaged as {ERC721Full}.
13 |
14 | Additionally, {IERC721Receiver} can be used to prevent tokens from becoming forever locked in contracts. Imagine sending an in-game item to an exchange address that can't send it back!. When using <>, the token contract checks to see that the receiver is an {IERC721Receiver}, which implies that it knows how to handle {ERC721} tokens. If you're writing a contract that needs to receive {ERC721} tokens, you'll want to include this interface.
15 |
16 | Finally, some custom extensions are also included:
17 |
18 | * {ERC721Mintable} — like the ERC20 version, this allows certain addresses to mint new tokens
19 | * {ERC721Pausable} — like the ERC20 version, this allows addresses to freeze transfers of tokens
20 |
21 | NOTE: This page is incomplete. We're working to improve it for the next release. Stay tuned!
22 |
23 | == Core
24 |
25 | {{IERC721}}
26 |
27 | {{ERC721}}
28 |
29 | {{IERC721Metadata}}
30 |
31 | {{ERC721Metadata}}
32 |
33 | {{ERC721Enumerable}}
34 |
35 | {{IERC721Enumerable}}
36 |
37 | {{IERC721Full}}
38 |
39 | {{ERC721Full}}
40 |
41 | {{IERC721Receiver}}
42 |
43 | == Extensions
44 |
45 | {{ERC721Mintable}}
46 |
47 | {{ERC721MetadataMintable}}
48 |
49 | {{ERC721Burnable}}
50 |
51 | {{ERC721Pausable}}
52 |
53 | == Convenience
54 |
55 | {{ERC721Holder}}
56 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/IERC721.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../introspection/IERC165.sol";
4 |
5 | /**
6 | * @dev Required interface of an ERC721 compliant contract.
7 | */
8 | contract IERC721 is IERC165 {
9 | event Transfer(address indexed from, address indexed to, uint256 indexed tokenId);
10 | event Approval(address indexed owner, address indexed approved, uint256 indexed tokenId);
11 | event ApprovalForAll(address indexed owner, address indexed operator, bool approved);
12 |
13 | /**
14 | * @dev Returns the number of NFTs in `owner`'s account.
15 | */
16 | function balanceOf(address owner) public view returns (uint256 balance);
17 |
18 | /**
19 | * @dev Returns the owner of the NFT specified by `tokenId`.
20 | */
21 | function ownerOf(uint256 tokenId) public view returns (address owner);
22 |
23 | /**
24 | * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
25 | * another (`to`).
26 | *
27 | *
28 | *
29 | * Requirements:
30 | * - `from`, `to` cannot be zero.
31 | * - `tokenId` must be owned by `from`.
32 | * - If the caller is not `from`, it must be have been allowed to move this
33 | * NFT by either {approve} or {setApprovalForAll}.
34 | */
35 | function safeTransferFrom(address from, address to, uint256 tokenId) public;
36 | /**
37 | * @dev Transfers a specific NFT (`tokenId`) from one account (`from`) to
38 | * another (`to`).
39 | *
40 | * Requirements:
41 | * - If the caller is not `from`, it must be approved to move this NFT by
42 | * either {approve} or {setApprovalForAll}.
43 | */
44 | function transferFrom(address from, address to, uint256 tokenId) public;
45 | function approve(address to, uint256 tokenId) public;
46 | function getApproved(uint256 tokenId) public view returns (address operator);
47 |
48 | function setApprovalForAll(address operator, bool _approved) public;
49 | function isApprovedForAll(address owner, address operator) public view returns (bool);
50 |
51 |
52 | function safeTransferFrom(address from, address to, uint256 tokenId, bytes memory data) public;
53 | }
54 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/TokenTimelock.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./SafeERC20.sol";
4 |
5 | /**
6 | * @dev A token holder contract that will allow a beneficiary to extract the
7 | * tokens after a given release time.
8 | *
9 | * Useful for simple vesting schedules like "advisors get all of their tokens
10 | * after 1 year".
11 | *
12 | * For a more complete vesting schedule, see {TokenVesting}.
13 | */
14 | contract TokenTimelock {
15 | using SafeERC20 for IERC20;
16 |
17 | // ERC20 basic token contract being held
18 | IERC20 private _token;
19 |
20 | // beneficiary of tokens after they are released
21 | address private _beneficiary;
22 |
23 | // timestamp when token release is enabled
24 | uint256 private _releaseTime;
25 |
26 | constructor (IERC20 token, address beneficiary, uint256 releaseTime) public {
27 | // solhint-disable-next-line not-rely-on-time
28 | require(releaseTime > block.timestamp, "TokenTimelock: release time is before current time");
29 | _token = token;
30 | _beneficiary = beneficiary;
31 | _releaseTime = releaseTime;
32 | }
33 |
34 | /**
35 | * @return the token being held.
36 | */
37 | function token() public view returns (IERC20) {
38 | return _token;
39 | }
40 |
41 | /**
42 | * @return the beneficiary of the tokens.
43 | */
44 | function beneficiary() public view returns (address) {
45 | return _beneficiary;
46 | }
47 |
48 | /**
49 | * @return the time when the tokens are released.
50 | */
51 | function releaseTime() public view returns (uint256) {
52 | return _releaseTime;
53 | }
54 |
55 | /**
56 | * @notice Transfers tokens held by timelock to beneficiary.
57 | */
58 | function release() public {
59 | // solhint-disable-next-line not-rely-on-time
60 | require(block.timestamp >= _releaseTime, "TokenTimelock: current time is before release time");
61 |
62 | uint256 amount = _token.balanceOf(address(this));
63 | require(amount > 0, "TokenTimelock: no tokens to release");
64 |
65 | _token.safeTransfer(_beneficiary, amount);
66 | }
67 | }
68 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/Create2.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Helper to make usage of the `CREATE2` EVM opcode easier and safer.
5 | * `CREATE2` can be used to compute in advance the address where a smart
6 | * contract will be deployed, which allows for interesting new mechanisms known
7 | * as 'counterfactual interactions'.
8 | *
9 | * See the https://eips.ethereum.org/EIPS/eip-1014#motivation[EIP] for more
10 | * information.
11 | *
12 | * _Available since v2.5.0._
13 | */
14 | library Create2 {
15 | /**
16 | * @dev Deploys a contract using `CREATE2`. The address where the contract
17 | * will be deployed can be known in advance via {computeAddress}. Note that
18 | * a contract cannot be deployed twice using the same salt.
19 | */
20 | function deploy(bytes32 salt, bytes memory bytecode) internal returns (address) {
21 | address addr;
22 | // solhint-disable-next-line no-inline-assembly
23 | assembly {
24 | addr := create2(0, add(bytecode, 0x20), mload(bytecode), salt)
25 | }
26 | require(addr != address(0), "Create2: Failed on deploy");
27 | return addr;
28 | }
29 |
30 | /**
31 | * @dev Returns the address where a contract will be stored if deployed via {deploy}. Any change in the `bytecode`
32 | * or `salt` will result in a new destination address.
33 | */
34 | function computeAddress(bytes32 salt, bytes memory bytecode) internal view returns (address) {
35 | return computeAddress(salt, bytecode, address(this));
36 | }
37 |
38 | /**
39 | * @dev Returns the address where a contract will be stored if deployed via {deploy} from a contract located at
40 | * `deployer`. If `deployer` is this contract's address, returns the same value as {computeAddress}.
41 | */
42 | function computeAddress(bytes32 salt, bytes memory bytecodeHash, address deployer) internal pure returns (address) {
43 | bytes32 bytecodeHashHash = keccak256(bytecodeHash);
44 | bytes32 _data = keccak256(
45 | abi.encodePacked(bytes1(0xff), deployer, salt, bytecodeHashHash)
46 | );
47 | return address(bytes20(_data << 96));
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/src/commands.txt:
--------------------------------------------------------------------------------
1 | # get the predefined accounts
2 | let accounts=await web3.eth.getAccounts()
3 | # check account address
4 | accounts[0].toString()
5 |
6 | # get the deployed contract instance
7 | let instance=await eThaler.deployed()
8 |
9 | instance.addNewTokenDefinition( 1, 'USD', 4, 'http://hyperledger.org/SIG/capitalMarkets/usd.pdf' )
10 |
11 | instance.getTokenName( 1 )
12 | instance.getDecimals( 1 )
13 | instance.getTTF_URL( 1 )
14 |
15 | instance.addNewTokenDefinition( 2, 'GBP', 2, 'http://hyperledger.org/SIG/capitalMarkets/gbp.pdf' )
16 |
17 | instance.getAllTokenIds( )
18 |
19 | instance.mint( 1, 1000000, '0x00' )
20 |
21 | # first register the CB/Minter
22 | instance.registerDealer( accounts[0], 1 )
23 |
24 | # find the balance of acct0 for tokenId 1
25 | instance.balanceOf( accounts[0], 1 )
26 |
27 | # first register a dealer
28 | instance.registerDealer( accounts[1], 1 )
29 |
30 | # dealer depositing collateral and getting appropriate token allocation
31 | # CB transfers tokens to dealer
32 | instance.transfer( accounts[1], 1, 100 )
33 |
34 | instance.registerDealer( accounts[2], 1 )
35 | # xfer 20 tokens of tokenId 1 from acct1 to acct2 using specific accounts[1]
36 | # use a specific address (works only with truffle in development)
37 | # from option only works with truffle console attached to truffle or ganache
38 | # (will not work in besu as besu requires proper authentication based on private key)
39 | instance.transfer( accounts[2], 1, 20, {from: accounts[1]} )
40 |
41 | # from CB perspective
42 | instance.balanceOf( accounts[0], 1 )
43 | instance.balanceOf( accounts[1], 1 )
44 |
45 | # from dealer1 perspective (the first will work as its own account. the second
46 | won't
47 | instance.balanceOf( accounts[1], 1, {from: accounts[1]} )
48 | instance.balanceOf( accounts[0], 1, {from: accounts[1]} )
49 |
50 | # pause the token by owner. Thereafter mint, burn and trnasfer should not be
51 | # permitted for this token until resumeToken is processed
52 | instance.pause( 1 )
53 | instance.isPaused( 1 )
54 |
55 | instance.resume( 1 )
56 |
57 | # dealer surrendering tokens and getting appropriate collateral back
58 | instance.transfer( accounts[0], 1, 50 )
59 |
60 |
61 | # other useful commands to check ether balance
62 | web3.eth.getBalance( accounts[0] )
63 |
64 |
65 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/lifecycle/Pausable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../GSN/Context.sol";
4 | import "../access/roles/PauserRole.sol";
5 |
6 | /**
7 | * @dev Contract module which allows children to implement an emergency stop
8 | * mechanism that can be triggered by an authorized account.
9 | *
10 | * This module is used through inheritance. It will make available the
11 | * modifiers `whenNotPaused` and `whenPaused`, which can be applied to
12 | * the functions of your contract. Note that they will not be pausable by
13 | * simply including this module, only once the modifiers are put in place.
14 | */
15 | contract Pausable is Context, PauserRole {
16 | /**
17 | * @dev Emitted when the pause is triggered by a pauser (`account`).
18 | */
19 | event Paused(address account);
20 |
21 | /**
22 | * @dev Emitted when the pause is lifted by a pauser (`account`).
23 | */
24 | event Unpaused(address account);
25 |
26 | bool private _paused;
27 |
28 | /**
29 | * @dev Initializes the contract in unpaused state. Assigns the Pauser role
30 | * to the deployer.
31 | */
32 | constructor () internal {
33 | _paused = false;
34 | }
35 |
36 | /**
37 | * @dev Returns true if the contract is paused, and false otherwise.
38 | */
39 | function paused() public view returns (bool) {
40 | return _paused;
41 | }
42 |
43 | /**
44 | * @dev Modifier to make a function callable only when the contract is not paused.
45 | */
46 | modifier whenNotPaused() {
47 | require(!_paused, "Pausable: paused");
48 | _;
49 | }
50 |
51 | /**
52 | * @dev Modifier to make a function callable only when the contract is paused.
53 | */
54 | modifier whenPaused() {
55 | require(_paused, "Pausable: not paused");
56 | _;
57 | }
58 |
59 | /**
60 | * @dev Called by a pauser to pause, triggers stopped state.
61 | */
62 | function pause() public onlyPauser whenNotPaused {
63 | _paused = true;
64 | emit Paused(_msgSender());
65 | }
66 |
67 | /**
68 | * @dev Called by a pauser to unpause, returns to normal state.
69 | */
70 | function unpause() public onlyPauser whenPaused {
71 | _paused = false;
72 | emit Unpaused(_msgSender());
73 | }
74 | }
75 |
--------------------------------------------------------------------------------
/src/CLI/build.gradle:
--------------------------------------------------------------------------------
1 | plugins {
2 | id 'java'
3 | id 'org.web3j' version '4.5.0'
4 | id 'application'
5 | }
6 | group 'org.web3j'
7 | version '0.2.0'
8 | sourceCompatibility = 1.8
9 | apply plugin: 'application'
10 | apply plugin: 'idea'
11 | apply plugin: 'java'
12 |
13 | idea {
14 | module {
15 | sourceDirs += file("${projectDir}/build/generated/source/web3j/main/java")
16 | }
17 | }
18 |
19 | sourceSets {
20 | main {
21 | resources {
22 | srcDirs "src/main/resources"
23 | }
24 | }
25 | }
26 |
27 | repositories {
28 | mavenCentral()
29 | }
30 |
31 | ext{
32 | web3jVersion = '4.5.0'
33 | logbackVersion = '1.2.3'
34 | junitVersion = '4.12'
35 | javaMainClass = 'com.swapshub.ethaler.client.EThalerApplication'
36 | }
37 |
38 | dependencies {
39 | implementation "org.web3j:core:$web3jVersion",
40 | "org.web3j:contracts:$web3jVersion",
41 | "ch.qos.logback:logback-core:$logbackVersion",
42 | "ch.qos.logback:logback-classic:$logbackVersion"
43 | compile "org.web3j:core:$web3jVersion",
44 | "org.web3j:contracts:$web3jVersion",
45 | "ch.qos.logback:logback-core:$logbackVersion",
46 | "ch.qos.logback:logback-classic:$logbackVersion"
47 | testImplementation "junit:junit:$junitVersion"
48 | }
49 |
50 | mainClassName = 'com.swapshub.ethaler.client.EThalerApplication'
51 | application {
52 | mainClassName = 'com.swapshub.ethaler.client.EThalerApplication'
53 | }
54 |
55 | jar {
56 | baseName = 'eThalerClient'
57 | version = '1.0'
58 | manifest {
59 | attributes 'Main-Class': 'com.swapshub.ethaler.client.EThalerApplication'
60 | }
61 | }
62 |
63 | web3j {
64 | generatedPackageName = 'org.web3j.sample.contracts.generated'
65 | excludedContracts = ['Mortal']
66 | }
67 |
68 | task copyJars(type: Copy) {
69 | from(configurations.compile)
70 | from('build/libs')
71 | into ('build/lib')
72 | }
73 |
74 | task copyResourceFiles(type: Copy) {
75 | from('/src/main/resources')
76 | into 'build/runeThalerClient'
77 | }
78 |
79 | task createeThalerClientScript(type: CreateStartScripts) {
80 | mainClassName = 'com.swapshub.ethaler.client.EThalerApplication'
81 | applicationName = 'eThalerClient'
82 | outputDir = new File(project.buildDir,'runeThalerClient')
83 | classpath = jar.outputs.files + project.configurations.compile
84 | }
85 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Contract module that helps prevent reentrant calls to a function.
5 | *
6 | * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier
7 | * available, which can be applied to functions to make sure there are no nested
8 | * (reentrant) calls to them.
9 | *
10 | * Note that because there is a single `nonReentrant` guard, functions marked as
11 | * `nonReentrant` may not call one another. This can be worked around by making
12 | * those functions `private`, and then adding `external` `nonReentrant` entry
13 | * points to them.
14 | *
15 | * TIP: If you would like to learn more about reentrancy and alternative ways
16 | * to protect against it, check out our blog post
17 | * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
18 | *
19 | * _Since v2.5.0:_ this module is now much more gas efficient, given net gas
20 | * metering changes introduced in the Istanbul hardfork.
21 | */
22 | contract ReentrancyGuard {
23 | bool private _notEntered;
24 |
25 | constructor () internal {
26 | // Storing an initial non-zero value makes deployment a bit more
27 | // expensive, but in exchange the refund on every call to nonReentrant
28 | // will be lower in amount. Since refunds are capped to a percetange of
29 | // the total transaction's gas, it is best to keep them low in cases
30 | // like this one, to increase the likelihood of the full refund coming
31 | // into effect.
32 | _notEntered = true;
33 | }
34 |
35 | /**
36 | * @dev Prevents a contract from calling itself, directly or indirectly.
37 | * Calling a `nonReentrant` function from another `nonReentrant`
38 | * function is not supported. It is possible to prevent this from happening
39 | * by making the `nonReentrant` function external, and make it call a
40 | * `private` function that does the actual work.
41 | */
42 | modifier nonReentrant() {
43 | // On the first call to nonReentrant, _notEntered will be true
44 | require(_notEntered, "ReentrancyGuard: reentrant call");
45 |
46 | // Any calls to nonReentrant after this point will fail
47 | _notEntered = false;
48 |
49 | _;
50 |
51 | // By storing the original value once again, a refund is triggered (see
52 | // https://eips.ethereum.org/EIPS/eip-2200)
53 | _notEntered = true;
54 | }
55 | }
56 |
--------------------------------------------------------------------------------
/src/CLI/gradlew.bat:
--------------------------------------------------------------------------------
1 | @if "%DEBUG%" == "" @echo off
2 | @rem ##########################################################################
3 | @rem
4 | @rem Gradle startup script for Windows
5 | @rem
6 | @rem ##########################################################################
7 |
8 | @rem Set local scope for the variables with windows NT shell
9 | if "%OS%"=="Windows_NT" setlocal
10 |
11 | set DIRNAME=%~dp0
12 | if "%DIRNAME%" == "" set DIRNAME=.
13 | set APP_BASE_NAME=%~n0
14 | set APP_HOME=%DIRNAME%
15 |
16 | @rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
17 | set DEFAULT_JVM_OPTS="-Xmx64m"
18 |
19 | @rem Find java.exe
20 | if defined JAVA_HOME goto findJavaFromJavaHome
21 |
22 | set JAVA_EXE=java.exe
23 | %JAVA_EXE% -version >NUL 2>&1
24 | if "%ERRORLEVEL%" == "0" goto init
25 |
26 | echo.
27 | echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
28 | echo.
29 | echo Please set the JAVA_HOME variable in your environment to match the
30 | echo location of your Java installation.
31 |
32 | goto fail
33 |
34 | :findJavaFromJavaHome
35 | set JAVA_HOME=%JAVA_HOME:"=%
36 | set JAVA_EXE=%JAVA_HOME%/bin/java.exe
37 |
38 | if exist "%JAVA_EXE%" goto init
39 |
40 | echo.
41 | echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
42 | echo.
43 | echo Please set the JAVA_HOME variable in your environment to match the
44 | echo location of your Java installation.
45 |
46 | goto fail
47 |
48 | :init
49 | @rem Get command-line arguments, handling Windows variants
50 |
51 | if not "%OS%" == "Windows_NT" goto win9xME_args
52 |
53 | :win9xME_args
54 | @rem Slurp the command line arguments.
55 | set CMD_LINE_ARGS=
56 | set _SKIP=2
57 |
58 | :win9xME_args_slurp
59 | if "x%~1" == "x" goto execute
60 |
61 | set CMD_LINE_ARGS=%*
62 |
63 | :execute
64 | @rem Setup the command line
65 |
66 | set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
67 |
68 | @rem Execute Gradle
69 | "%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%
70 |
71 | :end
72 | @rem End local scope for the variables with windows NT shell
73 | if "%ERRORLEVEL%"=="0" goto mainEnd
74 |
75 | :fail
76 | rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
77 | rem the _cmd.exe /c_ return code!
78 | if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
79 | exit /b 1
80 |
81 | :mainEnd
82 | if "%OS%"=="Windows_NT" endlocal
83 |
84 | :omega
85 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/distribution/PostDeliveryCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../validation/TimedCrowdsale.sol";
4 | import "../../math/SafeMath.sol";
5 | import "../../ownership/Secondary.sol";
6 | import "../../token/ERC20/IERC20.sol";
7 |
8 | /**
9 | * @title PostDeliveryCrowdsale
10 | * @dev Crowdsale that locks tokens from withdrawal until it ends.
11 | */
12 | contract PostDeliveryCrowdsale is TimedCrowdsale {
13 | using SafeMath for uint256;
14 |
15 | mapping(address => uint256) private _balances;
16 | __unstable__TokenVault private _vault;
17 |
18 | constructor() public {
19 | _vault = new __unstable__TokenVault();
20 | }
21 |
22 | /**
23 | * @dev Withdraw tokens only after crowdsale ends.
24 | * @param beneficiary Whose tokens will be withdrawn.
25 | */
26 | function withdrawTokens(address beneficiary) public {
27 | require(hasClosed(), "PostDeliveryCrowdsale: not closed");
28 | uint256 amount = _balances[beneficiary];
29 | require(amount > 0, "PostDeliveryCrowdsale: beneficiary is not due any tokens");
30 |
31 | _balances[beneficiary] = 0;
32 | _vault.transfer(token(), beneficiary, amount);
33 | }
34 |
35 | /**
36 | * @return the balance of an account.
37 | */
38 | function balanceOf(address account) public view returns (uint256) {
39 | return _balances[account];
40 | }
41 |
42 | /**
43 | * @dev Overrides parent by storing due balances, and delivering tokens to the vault instead of the end user. This
44 | * ensures that the tokens will be available by the time they are withdrawn (which may not be the case if
45 | * `_deliverTokens` was called later).
46 | * @param beneficiary Token purchaser
47 | * @param tokenAmount Amount of tokens purchased
48 | */
49 | function _processPurchase(address beneficiary, uint256 tokenAmount) internal {
50 | _balances[beneficiary] = _balances[beneficiary].add(tokenAmount);
51 | _deliverTokens(address(_vault), tokenAmount);
52 | }
53 | }
54 |
55 | /**
56 | * @title __unstable__TokenVault
57 | * @dev Similar to an Escrow for tokens, this contract allows its primary account to spend its tokens as it sees fit.
58 | * This contract is an internal helper for PostDeliveryCrowdsale, and should not be used outside of this context.
59 | */
60 | // solhint-disable-next-line contract-name-camelcase
61 | contract __unstable__TokenVault is Secondary {
62 | function transfer(IERC20 token, address to, uint256 amount) public onlyPrimary {
63 | token.transfer(to, amount);
64 | }
65 | }
66 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/validation/IndividuallyCappedCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../math/SafeMath.sol";
4 | import "../Crowdsale.sol";
5 | import "../../access/roles/CapperRole.sol";
6 |
7 | /**
8 | * @title IndividuallyCappedCrowdsale
9 | * @dev Crowdsale with per-beneficiary caps.
10 | */
11 | contract IndividuallyCappedCrowdsale is Crowdsale, CapperRole {
12 | using SafeMath for uint256;
13 |
14 | mapping(address => uint256) private _contributions;
15 | mapping(address => uint256) private _caps;
16 |
17 | /**
18 | * @dev Sets a specific beneficiary's maximum contribution.
19 | * @param beneficiary Address to be capped
20 | * @param cap Wei limit for individual contribution
21 | */
22 | function setCap(address beneficiary, uint256 cap) external onlyCapper {
23 | _caps[beneficiary] = cap;
24 | }
25 |
26 | /**
27 | * @dev Returns the cap of a specific beneficiary.
28 | * @param beneficiary Address whose cap is to be checked
29 | * @return Current cap for individual beneficiary
30 | */
31 | function getCap(address beneficiary) public view returns (uint256) {
32 | return _caps[beneficiary];
33 | }
34 |
35 | /**
36 | * @dev Returns the amount contributed so far by a specific beneficiary.
37 | * @param beneficiary Address of contributor
38 | * @return Beneficiary contribution so far
39 | */
40 | function getContribution(address beneficiary) public view returns (uint256) {
41 | return _contributions[beneficiary];
42 | }
43 |
44 | /**
45 | * @dev Extend parent behavior requiring purchase to respect the beneficiary's funding cap.
46 | * @param beneficiary Token purchaser
47 | * @param weiAmount Amount of wei contributed
48 | */
49 | function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal view {
50 | super._preValidatePurchase(beneficiary, weiAmount);
51 | // solhint-disable-next-line max-line-length
52 | require(_contributions[beneficiary].add(weiAmount) <= _caps[beneficiary], "IndividuallyCappedCrowdsale: beneficiary's cap exceeded");
53 | }
54 |
55 | /**
56 | * @dev Extend parent behavior to update beneficiary contributions.
57 | * @param beneficiary Token purchaser
58 | * @param weiAmount Amount of wei contributed
59 | */
60 | function _updatePurchasingState(address beneficiary, uint256 weiAmount) internal {
61 | super._updatePurchasingState(beneficiary, weiAmount);
62 | _contributions[beneficiary] = _contributions[beneficiary].add(weiAmount);
63 | }
64 | }
65 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC1155/IERC1155Receiver.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../introspection/IERC165.sol";
4 |
5 | /**
6 | @title ERC-1155 Multi Token Receiver Interface
7 | @dev See https://eips.ethereum.org/EIPS/eip-1155
8 | */
9 | contract IERC1155Receiver is IERC165 {
10 |
11 | /**
12 | @dev Handles the receipt of a single ERC1155 token type. This function is
13 | called at the end of a `safeTransferFrom` after the balance has been updated.
14 | To accept the transfer, this must return
15 | `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))`
16 | (i.e. 0xf23a6e61, or its own function selector).
17 | @param operator The address which initiated the transfer (i.e. msg.sender)
18 | @param from The address which previously owned the token
19 | @param id The ID of the token being transferred
20 | @param value The amount of tokens being transferred
21 | @param data Additional data with no specified format
22 | @return `bytes4(keccak256("onERC1155Received(address,address,uint256,uint256,bytes)"))` if transfer is allowed
23 | */
24 | function onERC1155Received(
25 | address operator,
26 | address from,
27 | uint256 id,
28 | uint256 value,
29 | bytes calldata data
30 | )
31 | external
32 | returns(bytes4);
33 |
34 | /**
35 | @dev Handles the receipt of a multiple ERC1155 token types. This function
36 | is called at the end of a `safeBatchTransferFrom` after the balances have
37 | been updated. To accept the transfer(s), this must return
38 | `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))`
39 | (i.e. 0xbc197c81, or its own function selector).
40 | @param operator The address which initiated the batch transfer (i.e. msg.sender)
41 | @param from The address which previously owned the token
42 | @param ids An array containing ids of each token being transferred (order and length must match values array)
43 | @param values An array containing amounts of each token being transferred (order and length must match ids array)
44 | @param data Additional data with no specified format
45 | @return `bytes4(keccak256("onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)"))` if transfer is allowed
46 | */
47 | function onERC1155BatchReceived(
48 | address operator,
49 | address from,
50 | uint256[] calldata ids,
51 | uint256[] calldata values,
52 | bytes calldata data
53 | )
54 | external
55 | returns(bytes4);
56 | }
57 |
--------------------------------------------------------------------------------
/src/CLI/src/main/java/com/swapshub/ethaler/client/PasswordField.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2020 Swapshub
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 | http://www.apache.org/licenses/LICENSE-2.0
7 | */
8 |
9 | package com.swapshub.ethaler.client;
10 |
11 | import java.io.IOException;
12 | import java.io.InputStream;
13 | import java.io.PushbackInputStream;
14 | import java.util.Arrays;
15 |
16 | public class PasswordField {
17 | /**
18 | * @param input stream to be used (e.g. System.in)
19 | * @param prompt The prompt to display to the user.
20 | * @return The password as entered by the user.
21 | */
22 |
23 | public static final char[] getPassword(InputStream in, String prompt) throws IOException {
24 | MaskingThread maskingthread = new MaskingThread(prompt);
25 | Thread thread = new Thread(maskingthread);
26 | thread.start();
27 |
28 | char[] lineBuffer;
29 | char[] buf;
30 | int i;
31 |
32 | buf = lineBuffer = new char[128];
33 |
34 | int room = buf.length;
35 | int offset = 0;
36 | int c;
37 |
38 | loop:
39 | while (true) {
40 | switch (c = in.read()) {
41 | case -1:
42 | case '\n':
43 | break loop;
44 |
45 | case '\r':
46 | int c2 = in.read();
47 | if ((c2 != '\n') && (c2 != -1)) {
48 | if (!(in instanceof PushbackInputStream)) {
49 | in = new PushbackInputStream(in);
50 | }
51 | ((PushbackInputStream) in).unread(c2);
52 | } else {
53 | break loop;
54 | }
55 |
56 | default:
57 | if (--room < 0) {
58 | buf = new char[offset + 128];
59 | room = buf.length - offset - 1;
60 | System.arraycopy(lineBuffer, 0, buf, 0, offset);
61 | Arrays.fill(lineBuffer, ' ');
62 | lineBuffer = buf;
63 | }
64 | buf[offset++] = (char) c;
65 | break;
66 | }
67 | }
68 | maskingthread.stopMasking();
69 | if (offset == 0) {
70 | return null;
71 | }
72 | char[] ret = new char[offset];
73 | System.arraycopy(buf, 0, ret, 0, offset);
74 | Arrays.fill(buf, ' ');
75 | return ret;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/ownership/Ownable.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../GSN/Context.sol";
4 | /**
5 | * @dev Contract module which provides a basic access control mechanism, where
6 | * there is an account (an owner) that can be granted exclusive access to
7 | * specific functions.
8 | *
9 | * This module is used through inheritance. It will make available the modifier
10 | * `onlyOwner`, which can be applied to your functions to restrict their use to
11 | * the owner.
12 | */
13 | contract Ownable is Context {
14 | address private _owner;
15 |
16 | event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
17 |
18 | /**
19 | * @dev Initializes the contract setting the deployer as the initial owner.
20 | */
21 | constructor () internal {
22 | address msgSender = _msgSender();
23 | _owner = msgSender;
24 | emit OwnershipTransferred(address(0), msgSender);
25 | }
26 |
27 | /**
28 | * @dev Returns the address of the current owner.
29 | */
30 | function owner() public view returns (address) {
31 | return _owner;
32 | }
33 |
34 | /**
35 | * @dev Throws if called by any account other than the owner.
36 | */
37 | modifier onlyOwner() {
38 | require(isOwner(), "Ownable: caller is not the owner");
39 | _;
40 | }
41 |
42 | /**
43 | * @dev Returns true if the caller is the current owner.
44 | */
45 | function isOwner() public view returns (bool) {
46 | return _msgSender() == _owner;
47 | }
48 |
49 | /**
50 | * @dev Leaves the contract without owner. It will not be possible to call
51 | * `onlyOwner` functions anymore. Can only be called by the current owner.
52 | *
53 | * NOTE: Renouncing ownership will leave the contract without an owner,
54 | * thereby removing any functionality that is only available to the owner.
55 | */
56 | function renounceOwnership() public onlyOwner {
57 | emit OwnershipTransferred(_owner, address(0));
58 | _owner = address(0);
59 | }
60 |
61 | /**
62 | * @dev Transfers ownership of the contract to a new account (`newOwner`).
63 | * Can only be called by the current owner.
64 | */
65 | function transferOwnership(address newOwner) public onlyOwner {
66 | _transferOwnership(newOwner);
67 | }
68 |
69 | /**
70 | * @dev Transfers ownership of the contract to a new account (`newOwner`).
71 | */
72 | function _transferOwnership(address newOwner) internal {
73 | require(newOwner != address(0), "Ownable: new owner is the zero address");
74 | emit OwnershipTransferred(_owner, newOwner);
75 | _owner = newOwner;
76 | }
77 | }
78 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/GSN/GSNRecipientSignature.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./GSNRecipient.sol";
4 | import "../cryptography/ECDSA.sol";
5 |
6 | /**
7 | * @dev A xref:ROOT:gsn-strategies.adoc#gsn-strategies[GSN strategy] that allows relayed transactions through when they are
8 | * accompanied by the signature of a trusted signer. The intent is for this signature to be generated by a server that
9 | * performs validations off-chain. Note that nothing is charged to the user in this scheme. Thus, the server should make
10 | * sure to account for this in their economic and threat model.
11 | */
12 | contract GSNRecipientSignature is GSNRecipient {
13 | using ECDSA for bytes32;
14 |
15 | address private _trustedSigner;
16 |
17 | enum GSNRecipientSignatureErrorCodes {
18 | INVALID_SIGNER
19 | }
20 |
21 | /**
22 | * @dev Sets the trusted signer that is going to be producing signatures to approve relayed calls.
23 | */
24 | constructor(address trustedSigner) public {
25 | require(trustedSigner != address(0), "GSNRecipientSignature: trusted signer is the zero address");
26 | _trustedSigner = trustedSigner;
27 | }
28 |
29 | /**
30 | * @dev Ensures that only transactions with a trusted signature can be relayed through the GSN.
31 | */
32 | function acceptRelayedCall(
33 | address relay,
34 | address from,
35 | bytes calldata encodedFunction,
36 | uint256 transactionFee,
37 | uint256 gasPrice,
38 | uint256 gasLimit,
39 | uint256 nonce,
40 | bytes calldata approvalData,
41 | uint256
42 | )
43 | external
44 | view
45 | returns (uint256, bytes memory)
46 | {
47 | bytes memory blob = abi.encodePacked(
48 | relay,
49 | from,
50 | encodedFunction,
51 | transactionFee,
52 | gasPrice,
53 | gasLimit,
54 | nonce, // Prevents replays on RelayHub
55 | getHubAddr(), // Prevents replays in multiple RelayHubs
56 | address(this) // Prevents replays in multiple recipients
57 | );
58 | if (keccak256(blob).toEthSignedMessageHash().recover(approvalData) == _trustedSigner) {
59 | return _approveRelayedCall();
60 | } else {
61 | return _rejectRelayedCall(uint256(GSNRecipientSignatureErrorCodes.INVALID_SIGNER));
62 | }
63 | }
64 |
65 | function _preRelayedCall(bytes memory) internal returns (bytes32) {
66 | // solhint-disable-previous-line no-empty-blocks
67 | }
68 |
69 | function _postRelayedCall(bytes memory, bool, uint256, bytes32) internal {
70 | // solhint-disable-previous-line no-empty-blocks
71 | }
72 | }
73 |
--------------------------------------------------------------------------------
/docs/UI-Flow.md:
--------------------------------------------------------------------------------
1 | UI-suggestions
2 | UI should be driven by the underlying functions
3 |
4 | A note on types:
5 | 1. address (basic Ethereum type 20 byte address link= https://solidity.readthedocs.io/en/v0.6.9/types.html?highlight=address#address )
6 | 2. uint256 for tokenId and amount
7 |
8 | Login screen opens with
9 | I. Offer choice about wallets
10 | a. open existing wallet
11 | Wallet name ("140woner")
12 | Wallet Password ("a password string")
13 | b. create new wallet -
14 |
15 |
16 | a. open existing wallet (next screen)
17 | If you open the Central Bank wallet
18 |
19 | A. If You are the Central Bank User Offer a screen with following tabs
20 |
21 | Tabs:
22 | Query|Token Supply|Transfer|Admin|Exit
23 |
24 | Query Each one is driven off a list of Token Ids (which can be looked up)
25 |
26 | Get Balance for own account
27 | Token Id (1)
28 |
29 | Get Balance for another account
30 | Token Id (1)
31 | Address (0x9535fB57245ea162027449b39be10Ce32aa59e76)
32 |
33 | Token details
34 | Is a list of tokenIds, names, decimals, URL (a table can be used-see Add Token definition)
35 |
36 |
37 | CheckTokenExists
38 | Token Id (1)
39 |
40 | Token Supply
41 | Mint
42 | Token Id (1)
43 | Amount (1000000)
44 | //amount can accept (1,000,000) but must send it as an amount underlying web3
45 | Burn
46 | Token Id (1)
47 | Amount (1000000)
48 | Transfer
49 | Token Id (1)
50 | To (0x9535fB57245ea162027449b39be10Ce32aa59e76)
51 | Amount (1000000)
52 |
53 | %result = success "Amount transferred to "
54 | %result = error if to is wrong, amount out of bounds
55 | Admin
56 | RegisterDealer
57 | Token Id (1)
58 | Dealer (0x9535fB57245ea162027449b39be10Ce32aa59e76)
59 | UnRegisterDealer
60 | Token Id (1)
61 | Dealer (0x9535fB57245ea162027449b39be10Ce32aa59e76)
62 |
63 | Add Token Definition
64 | Token Id (1)
65 | //should not clash with any existing TID
66 | string name ("eGBP")
67 | //- todo make it unique
68 | decimals (2)
69 | url = (http://example.com/example.pdf)
70 |
71 | Pause
72 | Token Id (1)
73 | Resume
74 | #can only be called after pause
75 | Token Id (1)
76 |
77 | B. If You are a Dealer
78 |
79 | Tabs
80 | Query|Transfer|Exit
81 |
82 | Transfer
83 | Token Id (1)
84 | To (0x9535fB57245ea162027449b39be10Ce32aa59e76)
85 | Amount (1000000)
86 |
87 | Query
88 | Get Balance for own account
89 | Token Id (1)
90 |
91 | Token details
92 | Token Id (1)
93 | CheckTokenExists
94 | Token Id (1)
95 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/distribution/RefundableCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "../../math/SafeMath.sol";
5 | import "./FinalizableCrowdsale.sol";
6 | import "../../payment/escrow/RefundEscrow.sol";
7 |
8 | /**
9 | * @title RefundableCrowdsale
10 | * @dev Extension of `FinalizableCrowdsale` contract that adds a funding goal, and the possibility of users
11 | * getting a refund if goal is not met.
12 | *
13 | * Deprecated, use `RefundablePostDeliveryCrowdsale` instead. Note that if you allow tokens to be traded before the goal
14 | * is met, then an attack is possible in which the attacker purchases tokens from the crowdsale and when they sees that
15 | * the goal is unlikely to be met, they sell their tokens (possibly at a discount). The attacker will be refunded when
16 | * the crowdsale is finalized, and the users that purchased from them will be left with worthless tokens.
17 | */
18 | contract RefundableCrowdsale is Context, FinalizableCrowdsale {
19 | using SafeMath for uint256;
20 |
21 | // minimum amount of funds to be raised in weis
22 | uint256 private _goal;
23 |
24 | // refund escrow used to hold funds while crowdsale is running
25 | RefundEscrow private _escrow;
26 |
27 | /**
28 | * @dev Constructor, creates RefundEscrow.
29 | * @param goal Funding goal
30 | */
31 | constructor (uint256 goal) public {
32 | require(goal > 0, "RefundableCrowdsale: goal is 0");
33 | _escrow = new RefundEscrow(wallet());
34 | _goal = goal;
35 | }
36 |
37 | /**
38 | * @return minimum amount of funds to be raised in wei.
39 | */
40 | function goal() public view returns (uint256) {
41 | return _goal;
42 | }
43 |
44 | /**
45 | * @dev Investors can claim refunds here if crowdsale is unsuccessful.
46 | * @param refundee Whose refund will be claimed.
47 | */
48 | function claimRefund(address payable refundee) public {
49 | require(finalized(), "RefundableCrowdsale: not finalized");
50 | require(!goalReached(), "RefundableCrowdsale: goal reached");
51 |
52 | _escrow.withdraw(refundee);
53 | }
54 |
55 | /**
56 | * @dev Checks whether funding goal was reached.
57 | * @return Whether funding goal was reached
58 | */
59 | function goalReached() public view returns (bool) {
60 | return weiRaised() >= _goal;
61 | }
62 |
63 | /**
64 | * @dev Escrow finalization task, called when finalize() is called.
65 | */
66 | function _finalization() internal {
67 | if (goalReached()) {
68 | _escrow.close();
69 | _escrow.beneficiaryWithdraw();
70 | } else {
71 | _escrow.enableRefunds();
72 | }
73 |
74 | super._finalization();
75 | }
76 |
77 | /**
78 | * @dev Overrides Crowdsale fund forwarding, sending funds to escrow.
79 | */
80 | function _forwardFunds() internal {
81 | _escrow.deposit.value(msg.value)(_msgSender());
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/IERC20.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Interface of the ERC20 standard as defined in the EIP. Does not include
5 | * the optional functions; to access them see {ERC20Detailed}.
6 | */
7 | interface IERC20 {
8 | /**
9 | * @dev Returns the amount of tokens in existence.
10 | */
11 | function totalSupply() external view returns (uint256);
12 |
13 | /**
14 | * @dev Returns the amount of tokens owned by `account`.
15 | */
16 | function balanceOf(address account) external view returns (uint256);
17 |
18 | /**
19 | * @dev Moves `amount` tokens from the caller's account to `recipient`.
20 | *
21 | * Returns a boolean value indicating whether the operation succeeded.
22 | *
23 | * Emits a {Transfer} event.
24 | */
25 | function transfer(address recipient, uint256 amount) external returns (bool);
26 |
27 | /**
28 | * @dev Returns the remaining number of tokens that `spender` will be
29 | * allowed to spend on behalf of `owner` through {transferFrom}. This is
30 | * zero by default.
31 | *
32 | * This value changes when {approve} or {transferFrom} are called.
33 | */
34 | function allowance(address owner, address spender) external view returns (uint256);
35 |
36 | /**
37 | * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.
38 | *
39 | * Returns a boolean value indicating whether the operation succeeded.
40 | *
41 | * IMPORTANT: Beware that changing an allowance with this method brings the risk
42 | * that someone may use both the old and the new allowance by unfortunate
43 | * transaction ordering. One possible solution to mitigate this race
44 | * condition is to first reduce the spender's allowance to 0 and set the
45 | * desired value afterwards:
46 | * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729
47 | *
48 | * Emits an {Approval} event.
49 | */
50 | function approve(address spender, uint256 amount) external returns (bool);
51 |
52 | /**
53 | * @dev Moves `amount` tokens from `sender` to `recipient` using the
54 | * allowance mechanism. `amount` is then deducted from the caller's
55 | * allowance.
56 | *
57 | * Returns a boolean value indicating whether the operation succeeded.
58 | *
59 | * Emits a {Transfer} event.
60 | */
61 | function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
62 |
63 | /**
64 | * @dev Emitted when `value` tokens are moved from one account (`from`) to
65 | * another (`to`).
66 | *
67 | * Note that `value` may be zero.
68 | */
69 | event Transfer(address indexed from, address indexed to, uint256 value);
70 |
71 | /**
72 | * @dev Emitted when the allowance of a `spender` for an `owner` is set by
73 | * a call to {approve}. `value` is the new allowance.
74 | */
75 | event Approval(address indexed owner, address indexed spender, uint256 value);
76 | }
77 |
--------------------------------------------------------------------------------
/src/README.md:
--------------------------------------------------------------------------------
1 | # eThaler
2 |
3 | Hyperledger eThaler private repo
4 |
5 | Objective:
6 | Issue a Central Bank Digital Currency (CBDC) using an OpenZeppelin based ERC1155 contract
7 | on a Enterprise Ethereum private network based on Hyperledger Besu
8 | and implement the interfaces as per Token Taxonomy Framework (TTF).
9 |
10 | This project enables a Central Bank (CB) to mint and operate a Central Bank Digital Currency. CB also authorizes a number of Commercial Banks (DB)
11 | so these DBs can transfer these currencies amongst themselves but cannot
12 | mint themselves.
13 | The name eThaler is given based on Thaler currency - a precursor to most
14 | western currencies in operation today (refer https://en.wikipedia.org/wiki/Thaler).
15 |
16 | The ERC1155 token is chosen here so a CB can use the same contract to
17 | issue other digital tokens representing its activities (for example, the
18 | current issuance of various monetary facilities to address COVID-19 crisis).
19 | Similarly a commercial bank can use this contract to mint and trade with
20 | its own clients and other banks.
21 |
22 | The project has 2 components : ERC1155 Smart Contract and a sample
23 | Web3J based Java Client CLI to test the smart contract from a Central Bank and a Commercial Bank perspective.
24 |
25 | Smart Contract:
26 | The contract directory contains the eThaler.sol contract based on OpenZeppelin
27 | ERC1155 sample contract implementation Note: OpenZeppelin has not yet
28 | officially released the token for use.
29 |
30 | You can independently deploy the contract alone using truffle and ganache and
31 | test the contract features using truffle console. You can also deploy
32 | your own private Hyperledger Besu network by following https://besu.hyperledger.org/en/stable/Tutorials/Private-Network/Create-IBFT-Network/ and then
33 | deploy the contract and test.
34 |
35 | Web3J based Java Client CLI:
36 | Please refer to README in the eThalerClient directory to install and test
37 | the java client against your own Besu network or connect with the following
38 | prebuilt ERC1155 contract in the test Besu network.
39 |
40 | Brief notes for Java CLI to connect with the test Besu network:
41 |
42 | Requirements:
43 | Java 8
44 | web3j
45 |
46 | Steps:
47 |
48 | 1. Create a key-store with password to store the private key for dealer account. Remember the password and use it to run the TesteThaler java CLI program.
49 | Run java TesteThaler eThaler.swapshub.com:8545
50 |
51 | # Using with your own private Hyperledger Besu network
52 |
53 | 1. Create a bring up a Besu network: https://besu.hyperledger.org/en/stable/Tutorials/Private-Network/Create-IBFT-Network/
54 |
55 | 2. Create a new network name "besu" in truffle-config.js with the private key and network ID from your newly created network.
56 |
57 | 3. Run the following:
58 |
59 | ```bash
60 | truffle migrate --network besu
61 | ```
62 |
63 | 4. After migrating, take the value of the first "address" present in eThaler/src/build/contracts/eThaler.json and set it as the ETHALER_CONTRACT_ADDR in src/CLI/config/config.properties
64 |
65 | 5. See src/CLI/ReadMe.txt for using the Cli with the network.
66 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/payment/escrow/Escrow.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../math/SafeMath.sol";
4 | import "../../ownership/Secondary.sol";
5 | import "../../utils/Address.sol";
6 |
7 | /**
8 | * @title Escrow
9 | * @dev Base escrow contract, holds funds designated for a payee until they
10 | * withdraw them.
11 | *
12 | * Intended usage: This contract (and derived escrow contracts) should be a
13 | * standalone contract, that only interacts with the contract that instantiated
14 | * it. That way, it is guaranteed that all Ether will be handled according to
15 | * the `Escrow` rules, and there is no need to check for payable functions or
16 | * transfers in the inheritance tree. The contract that uses the escrow as its
17 | * payment method should be its primary, and provide public methods redirecting
18 | * to the escrow's deposit and withdraw.
19 | */
20 | contract Escrow is Secondary {
21 | using SafeMath for uint256;
22 | using Address for address payable;
23 |
24 | event Deposited(address indexed payee, uint256 weiAmount);
25 | event Withdrawn(address indexed payee, uint256 weiAmount);
26 |
27 | mapping(address => uint256) private _deposits;
28 |
29 | function depositsOf(address payee) public view returns (uint256) {
30 | return _deposits[payee];
31 | }
32 |
33 | /**
34 | * @dev Stores the sent amount as credit to be withdrawn.
35 | * @param payee The destination address of the funds.
36 | */
37 | function deposit(address payee) public onlyPrimary payable {
38 | uint256 amount = msg.value;
39 | _deposits[payee] = _deposits[payee].add(amount);
40 |
41 | emit Deposited(payee, amount);
42 | }
43 |
44 | /**
45 | * @dev Withdraw accumulated balance for a payee, forwarding 2300 gas (a
46 | * Solidity `transfer`).
47 | *
48 | * NOTE: This function has been deprecated, use {withdrawWithGas} instead.
49 | * Calling contracts with fixed-gas limits is an anti-pattern and may break
50 | * contract interactions in network upgrades (hardforks).
51 | * https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more.]
52 | *
53 | * @param payee The address whose funds will be withdrawn and transferred to.
54 | */
55 | function withdraw(address payable payee) public onlyPrimary {
56 | uint256 payment = _deposits[payee];
57 |
58 | _deposits[payee] = 0;
59 |
60 | payee.transfer(payment);
61 |
62 | emit Withdrawn(payee, payment);
63 | }
64 |
65 | /**
66 | * @dev Same as {withdraw}, but forwarding all gas to the recipient.
67 | *
68 | * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
69 | * Make sure you trust the recipient, or are either following the
70 | * checks-effects-interactions pattern or using {ReentrancyGuard}.
71 | *
72 | * _Available since v2.4.0._
73 | */
74 | function withdrawWithGas(address payable payee) public onlyPrimary {
75 | uint256 payment = _deposits[payee];
76 |
77 | _deposits[payee] = 0;
78 |
79 | payee.sendValue(payment);
80 |
81 | emit Withdrawn(payee, payment);
82 | }
83 | }
84 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/Address.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.5;
2 |
3 | /**
4 | * @dev Collection of functions related to the address type
5 | */
6 | library Address {
7 | /**
8 | * @dev Returns true if `account` is a contract.
9 | *
10 | * [IMPORTANT]
11 | * ====
12 | * It is unsafe to assume that an address for which this function returns
13 | * false is an externally-owned account (EOA) and not a contract.
14 | *
15 | * Among others, `isContract` will return false for the following
16 | * types of addresses:
17 | *
18 | * - an externally-owned account
19 | * - a contract in construction
20 | * - an address where a contract will be created
21 | * - an address where a contract lived, but was destroyed
22 | * ====
23 | */
24 | function isContract(address account) internal view returns (bool) {
25 | // According to EIP-1052, 0x0 is the value returned for not-yet created accounts
26 | // and 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470 is returned
27 | // for accounts without code, i.e. `keccak256('')`
28 | bytes32 codehash;
29 | bytes32 accountHash = 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470;
30 | // solhint-disable-next-line no-inline-assembly
31 | assembly { codehash := extcodehash(account) }
32 | return (codehash != accountHash && codehash != 0x0);
33 | }
34 |
35 | /**
36 | * @dev Converts an `address` into `address payable`. Note that this is
37 | * simply a type cast: the actual underlying value is not changed.
38 | *
39 | * _Available since v2.4.0._
40 | */
41 | function toPayable(address account) internal pure returns (address payable) {
42 | return address(uint160(account));
43 | }
44 |
45 | /**
46 | * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
47 | * `recipient`, forwarding all available gas and reverting on errors.
48 | *
49 | * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
50 | * of certain opcodes, possibly making contracts go over the 2300 gas limit
51 | * imposed by `transfer`, making them unable to receive funds via
52 | * `transfer`. {sendValue} removes this limitation.
53 | *
54 | * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
55 | *
56 | * IMPORTANT: because control is transferred to `recipient`, care must be
57 | * taken to not create reentrancy vulnerabilities. Consider using
58 | * {ReentrancyGuard} or the
59 | * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
60 | *
61 | * _Available since v2.4.0._
62 | */
63 | function sendValue(address payable recipient, uint256 amount) internal {
64 | require(address(this).balance >= amount, "Address: insufficient balance");
65 |
66 | // solhint-disable-next-line avoid-call-value
67 | (bool success, ) = recipient.call.value(amount)("");
68 | require(success, "Address: unable to send value, recipient may have reverted");
69 | }
70 | }
71 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/price/IncreasingPriceCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../validation/TimedCrowdsale.sol";
4 | import "../../math/SafeMath.sol";
5 |
6 | /**
7 | * @title IncreasingPriceCrowdsale
8 | * @dev Extension of Crowdsale contract that increases the price of tokens linearly in time.
9 | * Note that what should be provided to the constructor is the initial and final _rates_, that is,
10 | * the amount of tokens per wei contributed. Thus, the initial rate must be greater than the final rate.
11 | */
12 | contract IncreasingPriceCrowdsale is TimedCrowdsale {
13 | using SafeMath for uint256;
14 |
15 | uint256 private _initialRate;
16 | uint256 private _finalRate;
17 |
18 | /**
19 | * @dev Constructor, takes initial and final rates of tokens received per wei contributed.
20 | * @param initialRate Number of tokens a buyer gets per wei at the start of the crowdsale
21 | * @param finalRate Number of tokens a buyer gets per wei at the end of the crowdsale
22 | */
23 | constructor (uint256 initialRate, uint256 finalRate) public {
24 | require(finalRate > 0, "IncreasingPriceCrowdsale: final rate is 0");
25 | // solhint-disable-next-line max-line-length
26 | require(initialRate > finalRate, "IncreasingPriceCrowdsale: initial rate is not greater than final rate");
27 | _initialRate = initialRate;
28 | _finalRate = finalRate;
29 | }
30 |
31 | /**
32 | * The base rate function is overridden to revert, since this crowdsale doesn't use it, and
33 | * all calls to it are a mistake.
34 | */
35 | function rate() public view returns (uint256) {
36 | revert("IncreasingPriceCrowdsale: rate() called");
37 | }
38 |
39 | /**
40 | * @return the initial rate of the crowdsale.
41 | */
42 | function initialRate() public view returns (uint256) {
43 | return _initialRate;
44 | }
45 |
46 | /**
47 | * @return the final rate of the crowdsale.
48 | */
49 | function finalRate() public view returns (uint256) {
50 | return _finalRate;
51 | }
52 |
53 | /**
54 | * @dev Returns the rate of tokens per wei at the present time.
55 | * Note that, as price _increases_ with time, the rate _decreases_.
56 | * @return The number of tokens a buyer gets per wei at a given time
57 | */
58 | function getCurrentRate() public view returns (uint256) {
59 | if (!isOpen()) {
60 | return 0;
61 | }
62 |
63 | // solhint-disable-next-line not-rely-on-time
64 | uint256 elapsedTime = block.timestamp.sub(openingTime());
65 | uint256 timeRange = closingTime().sub(openingTime());
66 | uint256 rateRange = _initialRate.sub(_finalRate);
67 | return _initialRate.sub(elapsedTime.mul(rateRange).div(timeRange));
68 | }
69 |
70 | /**
71 | * @dev Overrides parent method taking into account variable rate.
72 | * @param weiAmount The value in wei to be converted into tokens
73 | * @return The number of tokens _weiAmount wei will buy at present time
74 | */
75 | function _getTokenAmount(uint256 weiAmount) internal view returns (uint256) {
76 | uint256 currentRate = getCurrentRate();
77 | return currentRate.mul(weiAmount);
78 | }
79 | }
80 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/payment/escrow/RefundEscrow.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./ConditionalEscrow.sol";
4 |
5 | /**
6 | * @title RefundEscrow
7 | * @dev Escrow that holds funds for a beneficiary, deposited from multiple
8 | * parties.
9 | * @dev Intended usage: See {Escrow}. Same usage guidelines apply here.
10 | * @dev The primary account (that is, the contract that instantiates this
11 | * contract) may deposit, close the deposit period, and allow for either
12 | * withdrawal by the beneficiary, or refunds to the depositors. All interactions
13 | * with `RefundEscrow` will be made through the primary contract. See the
14 | * `RefundableCrowdsale` contract for an example of `RefundEscrow`’s use.
15 | */
16 | contract RefundEscrow is ConditionalEscrow {
17 | enum State { Active, Refunding, Closed }
18 |
19 | event RefundsClosed();
20 | event RefundsEnabled();
21 |
22 | State private _state;
23 | address payable private _beneficiary;
24 |
25 | /**
26 | * @dev Constructor.
27 | * @param beneficiary The beneficiary of the deposits.
28 | */
29 | constructor (address payable beneficiary) public {
30 | require(beneficiary != address(0), "RefundEscrow: beneficiary is the zero address");
31 | _beneficiary = beneficiary;
32 | _state = State.Active;
33 | }
34 |
35 | /**
36 | * @return The current state of the escrow.
37 | */
38 | function state() public view returns (State) {
39 | return _state;
40 | }
41 |
42 | /**
43 | * @return The beneficiary of the escrow.
44 | */
45 | function beneficiary() public view returns (address) {
46 | return _beneficiary;
47 | }
48 |
49 | /**
50 | * @dev Stores funds that may later be refunded.
51 | * @param refundee The address funds will be sent to if a refund occurs.
52 | */
53 | function deposit(address refundee) public payable {
54 | require(_state == State.Active, "RefundEscrow: can only deposit while active");
55 | super.deposit(refundee);
56 | }
57 |
58 | /**
59 | * @dev Allows for the beneficiary to withdraw their funds, rejecting
60 | * further deposits.
61 | */
62 | function close() public onlyPrimary {
63 | require(_state == State.Active, "RefundEscrow: can only close while active");
64 | _state = State.Closed;
65 | emit RefundsClosed();
66 | }
67 |
68 | /**
69 | * @dev Allows for refunds to take place, rejecting further deposits.
70 | */
71 | function enableRefunds() public onlyPrimary {
72 | require(_state == State.Active, "RefundEscrow: can only enable refunds while active");
73 | _state = State.Refunding;
74 | emit RefundsEnabled();
75 | }
76 |
77 | /**
78 | * @dev Withdraws the beneficiary's funds.
79 | */
80 | function beneficiaryWithdraw() public {
81 | require(_state == State.Closed, "RefundEscrow: beneficiary can only withdraw while closed");
82 | _beneficiary.transfer(address(this).balance);
83 | }
84 |
85 | /**
86 | * @dev Returns whether refundees can withdraw their deposits (be refunded). The overridden function receives a
87 | * 'payee' argument, but we ignore it here since the condition is global, not per-payee.
88 | */
89 | function withdrawalAllowed(address) public view returns (bool) {
90 | return _state == State.Refunding;
91 | }
92 | }
93 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/payment/PullPayment.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./escrow/Escrow.sol";
4 |
5 | /**
6 | * @dev Simple implementation of a
7 | * https://consensys.github.io/smart-contract-best-practices/recommendations/#favor-pull-over-push-for-external-calls[pull-payment]
8 | * strategy, where the paying contract doesn't interact directly with the
9 | * receiver account, which must withdraw its payments itself.
10 | *
11 | * Pull-payments are often considered the best practice when it comes to sending
12 | * Ether, security-wise. It prevents recipients from blocking execution, and
13 | * eliminates reentrancy concerns.
14 | *
15 | * TIP: If you would like to learn more about reentrancy and alternative ways
16 | * to protect against it, check out our blog post
17 | * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].
18 | *
19 | * To use, derive from the `PullPayment` contract, and use {_asyncTransfer}
20 | * instead of Solidity's `transfer` function. Payees can query their due
21 | * payments with {payments}, and retrieve them with {withdrawPayments}.
22 | */
23 | contract PullPayment {
24 | Escrow private _escrow;
25 |
26 | constructor () internal {
27 | _escrow = new Escrow();
28 | }
29 |
30 | /**
31 | * @dev Withdraw accumulated payments.
32 | *
33 | * Note that _any_ account can call this function, not just the `payee`.
34 | * This means that contracts unaware of the `PullPayment` protocol can still
35 | * receive funds this way, by having a separate account call
36 | * {withdrawPayments}.
37 | *
38 | * NOTE: This function has been deprecated, use {withdrawPaymentsWithGas}
39 | * instead. Calling contracts with fixed gas limits is an anti-pattern and
40 | * may break contract interactions in network upgrades (hardforks).
41 | * https://diligence.consensys.net/blog/2019/09/stop-using-soliditys-transfer-now/[Learn more.]
42 | *
43 | * @param payee Whose payments will be withdrawn.
44 | */
45 | function withdrawPayments(address payable payee) public {
46 | _escrow.withdraw(payee);
47 | }
48 |
49 | /**
50 | * @dev Same as {withdrawPayments}, but forwarding all gas to the recipient.
51 | *
52 | * WARNING: Forwarding all gas opens the door to reentrancy vulnerabilities.
53 | * Make sure you trust the recipient, or are either following the
54 | * checks-effects-interactions pattern or using {ReentrancyGuard}.
55 | *
56 | * _Available since v2.4.0._
57 | */
58 | function withdrawPaymentsWithGas(address payable payee) external {
59 | _escrow.withdrawWithGas(payee);
60 | }
61 |
62 | /**
63 | * @dev Returns the payments owed to an address.
64 | * @param dest The creditor's address.
65 | */
66 | function payments(address dest) public view returns (uint256) {
67 | return _escrow.depositsOf(dest);
68 | }
69 |
70 | /**
71 | * @dev Called by the payer to store the sent amount as credit to be pulled.
72 | * Funds sent in this way are stored in an intermediate {Escrow} contract, so
73 | * there is no danger of them being spent before withdrawal.
74 | *
75 | * @param dest The destination address of the funds.
76 | * @param amount The amount to transfer.
77 | */
78 | function _asyncTransfer(address dest, uint256 amount) internal {
79 | _escrow.deposit.value(amount)(dest);
80 | }
81 | }
82 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/SafeCast.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 |
4 | /**
5 | * @dev Wrappers over Solidity's uintXX casting operators with added overflow
6 | * checks.
7 | *
8 | * Downcasting from uint256 in Solidity does not revert on overflow. This can
9 | * easily result in undesired exploitation or bugs, since developers usually
10 | * assume that overflows raise errors. `SafeCast` restores this intuition by
11 | * reverting the transaction when such an operation overflows.
12 | *
13 | * Using this library instead of the unchecked operations eliminates an entire
14 | * class of bugs, so it's recommended to use it always.
15 | *
16 | * Can be combined with {SafeMath} to extend it to smaller types, by performing
17 | * all math on `uint256` and then downcasting.
18 | *
19 | * _Available since v2.5.0._
20 | */
21 | library SafeCast {
22 |
23 | /**
24 | * @dev Returns the downcasted uint128 from uint256, reverting on
25 | * overflow (when the input is greater than largest uint128).
26 | *
27 | * Counterpart to Solidity's `uint128` operator.
28 | *
29 | * Requirements:
30 | *
31 | * - input must fit into 128 bits
32 | */
33 | function toUint128(uint256 value) internal pure returns (uint128) {
34 | require(value < 2**128, "SafeCast: value doesn\'t fit in 128 bits");
35 | return uint128(value);
36 | }
37 |
38 | /**
39 | * @dev Returns the downcasted uint64 from uint256, reverting on
40 | * overflow (when the input is greater than largest uint64).
41 | *
42 | * Counterpart to Solidity's `uint64` operator.
43 | *
44 | * Requirements:
45 | *
46 | * - input must fit into 64 bits
47 | */
48 | function toUint64(uint256 value) internal pure returns (uint64) {
49 | require(value < 2**64, "SafeCast: value doesn\'t fit in 64 bits");
50 | return uint64(value);
51 | }
52 |
53 | /**
54 | * @dev Returns the downcasted uint32 from uint256, reverting on
55 | * overflow (when the input is greater than largest uint32).
56 | *
57 | * Counterpart to Solidity's `uint32` operator.
58 | *
59 | * Requirements:
60 | *
61 | * - input must fit into 32 bits
62 | */
63 | function toUint32(uint256 value) internal pure returns (uint32) {
64 | require(value < 2**32, "SafeCast: value doesn\'t fit in 32 bits");
65 | return uint32(value);
66 | }
67 |
68 | /**
69 | * @dev Returns the downcasted uint16 from uint256, reverting on
70 | * overflow (when the input is greater than largest uint16).
71 | *
72 | * Counterpart to Solidity's `uint16` operator.
73 | *
74 | * Requirements:
75 | *
76 | * - input must fit into 16 bits
77 | */
78 | function toUint16(uint256 value) internal pure returns (uint16) {
79 | require(value < 2**16, "SafeCast: value doesn\'t fit in 16 bits");
80 | return uint16(value);
81 | }
82 |
83 | /**
84 | * @dev Returns the downcasted uint8 from uint256, reverting on
85 | * overflow (when the input is greater than largest uint8).
86 | *
87 | * Counterpart to Solidity's `uint8` operator.
88 | *
89 | * Requirements:
90 | *
91 | * - input must fit into 8 bits.
92 | */
93 | function toUint8(uint256 value) internal pure returns (uint8) {
94 | require(value < 2**8, "SafeCast: value doesn\'t fit in 8 bits");
95 | return uint8(value);
96 | }
97 | }
98 |
--------------------------------------------------------------------------------
/src/CLI/src/main/java/com/swapshub/ethaler/client/EThalerApplication.java:
--------------------------------------------------------------------------------
1 | /**
2 | Copyright 2020 Swapshub
3 | Licensed under the Apache License, Version 2.0 (the "License");
4 | you may not use this file except in compliance with the License.
5 | You may obtain a copy of the License at
6 | http://www.apache.org/licenses/LICENSE-2.0
7 | */
8 |
9 | package com.swapshub.ethaler.client;
10 |
11 | import ch.qos.logback.classic.Level;
12 | import org.bouncycastle.jce.provider.BouncyCastleProvider;
13 | import org.slf4j.LoggerFactory;
14 |
15 | import java.io.File;
16 | import java.security.Security;
17 | import java.util.ArrayList;
18 | import java.util.Scanner;
19 |
20 | /**
21 | * This class is the main class for the CLI application.
22 | *
23 | */
24 | public class EThalerApplication {
25 | static final String CREATE_WALLET = "CreateWallet";
26 | static String LOG_LEVEL = "INFO";
27 | static String BESU_URL = "";
28 | static String ETHALER_CONTRACT_ADDR = "";
29 | static int CHAIN_ID = 2018;
30 | static long POLLING_INTERVAL = 2000;
31 | static int POLLING_ATTEMPTS = 5;
32 | static String configDirectory = "config";
33 | static String walletDirectory = "wallets";
34 | static Scanner scanner = new Scanner(System.in);
35 | static boolean isOwner = false;
36 | static ArrayList tokenIdList = new ArrayList();
37 | static ArrayList tokenNameList = new ArrayList();
38 | static ArrayList tokenDecimalList = new ArrayList();
39 | static ArrayList tokenTTFList = new ArrayList();
40 |
41 | /**
42 | * Entry point for the command line interface application
43 | * @param args
44 | */
45 | public static void main(String[] args) {
46 | Security.addProvider(new BouncyCastleProvider());
47 | ch.qos.logback.classic.Logger rootLogger = (ch.qos.logback.classic.Logger) LoggerFactory.getLogger(ch.qos.logback.classic.Logger.ROOT_LOGGER_NAME);
48 | Level lvl = Level.toLevel(LOG_LEVEL);
49 | rootLogger.setLevel(lvl);
50 |
51 | //for wallet creation
52 | if (args.length > 0) {
53 | if (args[0].trim().length() > 0) //one argument is expected
54 | {
55 | configDirectory = args[0] + File.separator + configDirectory;
56 | walletDirectory = args[0] + File.separator + walletDirectory;
57 | }
58 | try { //second argument is optional
59 | if (args[1] != null && args[1].trim().length() > 0 && args[1].trim().equalsIgnoreCase(CREATE_WALLET)) {
60 | WalletInitUtil wInitUtil = new WalletInitUtil();
61 | wInitUtil.createWalletWithPvtKey();
62 | wInitUtil.shutdownApp("Wallet created successfully. Ensure a backup of wallet json file is taken.");
63 | }
64 | } catch (Exception ex) {
65 |
66 | }
67 | }
68 | NetWorkUtil netUtil = new NetWorkUtil();
69 | WalletInitUtil wInitUtil = new WalletInitUtil();
70 | netUtil.connectToNetwork();
71 |
72 | //for running either as Central banker or dealer
73 | if (netUtil.getWeb3j() != null) {
74 | wInitUtil.getUserWalletOptions();
75 | ContractAccountUtil contractAccountUtil = new ContractAccountUtil();
76 | contractAccountUtil.startApplication(netUtil.getWeb3j());
77 | } else {
78 | netUtil.shutdownApp("Not connected to network. Exiting.");
79 | }
80 | }
81 | }//end of class
82 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/crowdsale/validation/TimedCrowdsale.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../math/SafeMath.sol";
4 | import "../Crowdsale.sol";
5 |
6 | /**
7 | * @title TimedCrowdsale
8 | * @dev Crowdsale accepting contributions only within a time frame.
9 | */
10 | contract TimedCrowdsale is Crowdsale {
11 | using SafeMath for uint256;
12 |
13 | uint256 private _openingTime;
14 | uint256 private _closingTime;
15 |
16 | /**
17 | * Event for crowdsale extending
18 | * @param newClosingTime new closing time
19 | * @param prevClosingTime old closing time
20 | */
21 | event TimedCrowdsaleExtended(uint256 prevClosingTime, uint256 newClosingTime);
22 |
23 | /**
24 | * @dev Reverts if not in crowdsale time range.
25 | */
26 | modifier onlyWhileOpen {
27 | require(isOpen(), "TimedCrowdsale: not open");
28 | _;
29 | }
30 |
31 | /**
32 | * @dev Constructor, takes crowdsale opening and closing times.
33 | * @param openingTime Crowdsale opening time
34 | * @param closingTime Crowdsale closing time
35 | */
36 | constructor (uint256 openingTime, uint256 closingTime) public {
37 | // solhint-disable-next-line not-rely-on-time
38 | require(openingTime >= block.timestamp, "TimedCrowdsale: opening time is before current time");
39 | // solhint-disable-next-line max-line-length
40 | require(closingTime > openingTime, "TimedCrowdsale: opening time is not before closing time");
41 |
42 | _openingTime = openingTime;
43 | _closingTime = closingTime;
44 | }
45 |
46 | /**
47 | * @return the crowdsale opening time.
48 | */
49 | function openingTime() public view returns (uint256) {
50 | return _openingTime;
51 | }
52 |
53 | /**
54 | * @return the crowdsale closing time.
55 | */
56 | function closingTime() public view returns (uint256) {
57 | return _closingTime;
58 | }
59 |
60 | /**
61 | * @return true if the crowdsale is open, false otherwise.
62 | */
63 | function isOpen() public view returns (bool) {
64 | // solhint-disable-next-line not-rely-on-time
65 | return block.timestamp >= _openingTime && block.timestamp <= _closingTime;
66 | }
67 |
68 | /**
69 | * @dev Checks whether the period in which the crowdsale is open has already elapsed.
70 | * @return Whether crowdsale period has elapsed
71 | */
72 | function hasClosed() public view returns (bool) {
73 | // solhint-disable-next-line not-rely-on-time
74 | return block.timestamp > _closingTime;
75 | }
76 |
77 | /**
78 | * @dev Extend parent behavior requiring to be within contributing period.
79 | * @param beneficiary Token purchaser
80 | * @param weiAmount Amount of wei contributed
81 | */
82 | function _preValidatePurchase(address beneficiary, uint256 weiAmount) internal onlyWhileOpen view {
83 | super._preValidatePurchase(beneficiary, weiAmount);
84 | }
85 |
86 | /**
87 | * @dev Extend crowdsale.
88 | * @param newClosingTime Crowdsale closing time
89 | */
90 | function _extendTime(uint256 newClosingTime) internal {
91 | require(!hasClosed(), "TimedCrowdsale: already closed");
92 | // solhint-disable-next-line max-line-length
93 | require(newClosingTime > _closingTime, "TimedCrowdsale: new closing time is before current closing time");
94 |
95 | emit TimedCrowdsaleExtended(_closingTime, newClosingTime);
96 | _closingTime = newClosingTime;
97 | }
98 | }
99 |
--------------------------------------------------------------------------------
/token-templates/formulas/tF{d,t,p,c,SC}/latest/tF{d,t,p,c,SC}.json:
--------------------------------------------------------------------------------
1 | {
2 | "artifact": {
3 | "artifactSymbol": {
4 | "id": "1ed9e758-905b-4868-b615-ab3b2195e76a",
5 | "type": "TEMPLATE_FORMULA",
6 | "visual": "τF{d,t,p,c,SC}",
7 | "tooling": "tF{d,t,p,c,SC}",
8 | "version": "1.0",
9 | "templateValidated": false
10 | },
11 | "name": "tF{d,t,p,c,SC}",
12 | "aliases": [
13 | "eThaler"
14 | ],
15 | "artifactDefinition": {
16 | "businessDescription": "This is a Token with Variable Supply Fungible where an initial supply can set at creation and then supply can be added and removed from the total based on need. It is fractional by setting the Decimals property on the dividable behavior. A token instance can be burned or minted. Before executing transfer, burn or mint operation check if they are within the compliance regulations. Pausable for possible freezing of movement and all other operations because of discovered bugs or upgrade.",
17 | "businessExample": "Enables the issuance of regulated electronic money by the central bank (mintable and burnable only by Central bank) and its practical usage in real financial applications.",
18 | "analogies": [],
19 | "comments": "",
20 | "artifact": null
21 | },
22 | "dependencies": [],
23 | "incompatibleWithSymbols": [],
24 | "influencedBySymbols": [],
25 | "artifactFiles": [
26 | {
27 | "content": "CONTROL",
28 | "fileName": "tF{d,t,p,c,SC}.proto",
29 | "fileData": "",
30 | "artifact": null
31 | },
32 | {
33 | "content": "UML",
34 | "fileName": "tF{d,t,p,c,SC}.md",
35 | "fileData": "",
36 | "artifact": null
37 | }
38 | ],
39 | "maps": {
40 | "codeReferences": [],
41 | "implementationReferences": [],
42 | "resources": [],
43 | "artifact": null
44 | }
45 | },
46 | "templateType": "SINGLE_TOKEN",
47 | "tokenBase": {
48 | "base": {
49 | "id":"89ca6daf-5585-469e-abd1-19bc44e7a012",
50 | "type": "BASE",
51 | "visual": "τF{d}",
52 | "tooling": "tF{d}",
53 | "version": "1.0",
54 | "templateValidated": true
55 | }
56 | },
57 | "behaviors": [
58 | {
59 | "behavior": {
60 | "id":"6e3501dc-5800-4c71-b59e-ad11418a998c",
61 | "type": "BEHAVIOR",
62 | "visual": "d",
63 | "tooling": "d",
64 | "version": "1.0",
65 | "templateValidated": false
66 | }
67 | },
68 | {
69 | "behavior": {
70 | "id":"af119e58-6d84-4ca6-9656-75e8d312f038",
71 | "type": "BEHAVIOR",
72 | "visual": "t",
73 | "tooling": "t",
74 | "version": "1.0",
75 | "templateValidated": false
76 | }
77 | },
78 | {"behavior": {
79 | "id":"0fb5abae-c99e-4f34-90cf-62b6f3351b74",
80 | "type": "BEHAVIOR",
81 | "visual": "p",
82 | "tooling": "p",
83 | "version": "1.0",
84 | "templateValidated": false
85 | }
86 | },
87 | {
88 | "behavior": {
89 | "id":"03dd1c48-dfdb-4ec1-86c8-69c3abac76b7",
90 | "type": "BEHAVIOR",
91 | "visual": "c",
92 | "tooling": "c",
93 | "version": "1.0",
94 | "templateValidated": false
95 | }
96 | }
97 | ],
98 | "behaviorGroups": [
99 | {
100 | "behaviorGroup":{
101 | "id":"91cb89b6-a2ce-44ff-b3a0-f0cb3f117e56",
102 | "type": "BEHAVIOR_GROUP",
103 | "visual": "SC",
104 | "tooling": "SC",
105 | "version": "1.0",
106 | "templateValidated": false
107 | }
108 | }
109 | ],
110 | "propertySets": [],
111 | "childTokens": []
112 | }
113 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "_from": "openzeppelin-solidity@^2.4.0",
3 | "_id": "openzeppelin-solidity@2.5.0",
4 | "_inBundle": false,
5 | "_integrity": "sha512-I0yRC3nff9Kn2LDWuz02fuw0EuomVQ9Z8lHzdqh8P9BiOUzIk8frQRxn/a1Kva3StF6hwPP+Dh3/SQ2ily1Pow==",
6 | "_location": "/openzeppelin-solidity",
7 | "_phantomChildren": {},
8 | "_requested": {
9 | "type": "range",
10 | "registry": true,
11 | "raw": "openzeppelin-solidity@^2.4.0",
12 | "name": "openzeppelin-solidity",
13 | "escapedName": "openzeppelin-solidity",
14 | "rawSpec": "^2.4.0",
15 | "saveSpec": null,
16 | "fetchSpec": "^2.4.0"
17 | },
18 | "_requiredBy": [
19 | "#DEV:/"
20 | ],
21 | "_resolved": "https://registry.npmjs.org/openzeppelin-solidity/-/openzeppelin-solidity-2.5.0.tgz",
22 | "_shasum": "829a9bcfc928619dd96c44bd893b180044ff51aa",
23 | "_spec": "openzeppelin-solidity@^2.4.0",
24 | "_where": "E:\\mani\\ethereum\\eThaler",
25 | "author": {
26 | "name": "OpenZeppelin Community",
27 | "email": "maintainers@openzeppelin.org"
28 | },
29 | "bugs": {
30 | "url": "https://github.com/OpenZeppelin/openzeppelin-contracts/issues"
31 | },
32 | "bundleDependencies": false,
33 | "dependencies": {},
34 | "deprecated": false,
35 | "description": "Secure Smart Contract library for Solidity",
36 | "devDependencies": {
37 | "@openzeppelin/cli": "^2.5.3",
38 | "@openzeppelin/gsn-helpers": "^0.2.3",
39 | "@openzeppelin/gsn-provider": "^0.1.9",
40 | "@openzeppelin/test-environment": "^0.1.2",
41 | "@openzeppelin/test-helpers": "^0.5.4",
42 | "chai": "^4.2.0",
43 | "eslint": "^6.5.1",
44 | "eslint-config-standard": "^14.1.0",
45 | "eslint-plugin-import": "^2.20.0",
46 | "eslint-plugin-mocha-no-only": "^1.1.0",
47 | "eslint-plugin-node": "^10.0.0",
48 | "eslint-plugin-promise": "^4.2.1",
49 | "eslint-plugin-standard": "^4.0.1",
50 | "ethereumjs-util": "^6.2.0",
51 | "ganache-core-coverage": "https://github.com/OpenZeppelin/ganache-core-coverage/releases/download/2.5.3-coverage/ganache-core-coverage-2.5.3.tgz",
52 | "lodash.startcase": "^4.4.0",
53 | "micromatch": "^4.0.2",
54 | "mocha": "^7.0.0",
55 | "openzeppelin-docs-utils": "github:OpenZeppelin/docs-utils",
56 | "solhint": "2.3.0",
57 | "solidity-coverage": "github:rotcivegaf/solidity-coverage#5875f5b7bc74d447f3312c9c0e9fc7814b482477",
58 | "solidity-docgen": "^0.3.13"
59 | },
60 | "files": [
61 | "/contracts/**/*.sol",
62 | "/build/contracts/*.json",
63 | "!/contracts/mocks",
64 | "!/contracts/examples",
65 | "/test/behaviors"
66 | ],
67 | "homepage": "https://openzeppelin.com/contracts/",
68 | "keywords": [
69 | "solidity",
70 | "ethereum",
71 | "smart",
72 | "contracts",
73 | "security",
74 | "zeppelin"
75 | ],
76 | "license": "MIT",
77 | "name": "openzeppelin-solidity",
78 | "repository": {
79 | "type": "git",
80 | "url": "git+https://github.com/OpenZeppelin/openzeppelin-contracts.git"
81 | },
82 | "scripts": {
83 | "compile": "scripts/compile.sh",
84 | "coverage": "scripts/coverage.sh",
85 | "docs": "oz-docs -c docs",
86 | "docs:watch": "npm run docs watch contracts 'docs/*.hbs'",
87 | "lint": "npm run lint:js && npm run lint:sol",
88 | "lint:fix": "npm run lint:js:fix",
89 | "lint:js": "eslint --ignore-path .gitignore .",
90 | "lint:js:fix": "eslint --ignore-path .gitignore . --fix",
91 | "lint:sol": "solhint --max-warnings 0 \"contracts/**/*.sol\"",
92 | "prepare": "node scripts/prepare.js",
93 | "prepare-docs": "scripts/prepare-docs.sh",
94 | "release": "scripts/release/release.sh",
95 | "test": "mocha --exit --recursive test",
96 | "version": "scripts/release/version.sh"
97 | },
98 | "version": "2.5.0"
99 | }
100 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/cryptography/ECDSA.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Elliptic Curve Digital Signature Algorithm (ECDSA) operations.
5 | *
6 | * These functions can be used to verify that a message was signed by the holder
7 | * of the private keys of a given address.
8 | */
9 | library ECDSA {
10 | /**
11 | * @dev Returns the address that signed a hashed message (`hash`) with
12 | * `signature`. This address can then be used for verification purposes.
13 | *
14 | * The `ecrecover` EVM opcode allows for malleable (non-unique) signatures:
15 | * this function rejects them by requiring the `s` value to be in the lower
16 | * half order, and the `v` value to be either 27 or 28.
17 | *
18 | * NOTE: This call _does not revert_ if the signature is invalid, or
19 | * if the signer is otherwise unable to be retrieved. In those scenarios,
20 | * the zero address is returned.
21 | *
22 | * IMPORTANT: `hash` _must_ be the result of a hash operation for the
23 | * verification to be secure: it is possible to craft signatures that
24 | * recover to arbitrary addresses for non-hashed data. A safe way to ensure
25 | * this is by receiving a hash of the original message (which may otherwise
26 | * be too long), and then calling {toEthSignedMessageHash} on it.
27 | */
28 | function recover(bytes32 hash, bytes memory signature) internal pure returns (address) {
29 | // Check the signature length
30 | if (signature.length != 65) {
31 | return (address(0));
32 | }
33 |
34 | // Divide the signature in r, s and v variables
35 | bytes32 r;
36 | bytes32 s;
37 | uint8 v;
38 |
39 | // ecrecover takes the signature parameters, and the only way to get them
40 | // currently is to use assembly.
41 | // solhint-disable-next-line no-inline-assembly
42 | assembly {
43 | r := mload(add(signature, 0x20))
44 | s := mload(add(signature, 0x40))
45 | v := byte(0, mload(add(signature, 0x60)))
46 | }
47 |
48 | // EIP-2 still allows signature malleability for ecrecover(). Remove this possibility and make the signature
49 | // unique. Appendix F in the Ethereum Yellow paper (https://ethereum.github.io/yellowpaper/paper.pdf), defines
50 | // the valid range for s in (281): 0 < s < secp256k1n ÷ 2 + 1, and for v in (282): v ∈ {27, 28}. Most
51 | // signatures from current libraries generate a unique signature with an s-value in the lower half order.
52 | //
53 | // If your library generates malleable signatures, such as s-values in the upper range, calculate a new s-value
54 | // with 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFEBAAEDCE6AF48A03BBFD25E8CD0364141 - s1 and flip v from 27 to 28 or
55 | // vice versa. If your library also generates signatures with 0/1 for v instead 27/28, add 27 to v to accept
56 | // these malleable signatures as well.
57 | if (uint256(s) > 0x7FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF5D576E7357A4501DDFE92F46681B20A0) {
58 | return address(0);
59 | }
60 |
61 | if (v != 27 && v != 28) {
62 | return address(0);
63 | }
64 |
65 | // If the signature is valid (and not malleable), return the signer address
66 | return ecrecover(hash, v, r, s);
67 | }
68 |
69 | /**
70 | * @dev Returns an Ethereum Signed Message, created from a `hash`. This
71 | * replicates the behavior of the
72 | * https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign[`eth_sign`]
73 | * JSON-RPC method.
74 | *
75 | * See {recover}.
76 | */
77 | function toEthSignedMessageHash(bytes32 hash) internal pure returns (bytes32) {
78 | // 32 is the length in bytes of hash,
79 | // enforced by the type signature above
80 | return keccak256(abi.encodePacked("\x19Ethereum Signed Message:\n32", hash));
81 | }
82 | }
83 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC20/SafeERC20.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "./IERC20.sol";
4 | import "../../math/SafeMath.sol";
5 | import "../../utils/Address.sol";
6 |
7 | /**
8 | * @title SafeERC20
9 | * @dev Wrappers around ERC20 operations that throw on failure (when the token
10 | * contract returns false). Tokens that return no value (and instead revert or
11 | * throw on failure) are also supported, non-reverting calls are assumed to be
12 | * successful.
13 | * To use this library you can add a `using SafeERC20 for ERC20;` statement to your contract,
14 | * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
15 | */
16 | library SafeERC20 {
17 | using SafeMath for uint256;
18 | using Address for address;
19 |
20 | function safeTransfer(IERC20 token, address to, uint256 value) internal {
21 | callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
22 | }
23 |
24 | function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
25 | callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
26 | }
27 |
28 | function safeApprove(IERC20 token, address spender, uint256 value) internal {
29 | // safeApprove should only be called when setting an initial allowance,
30 | // or when resetting it to zero. To increase and decrease it, use
31 | // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
32 | // solhint-disable-next-line max-line-length
33 | require((value == 0) || (token.allowance(address(this), spender) == 0),
34 | "SafeERC20: approve from non-zero to non-zero allowance"
35 | );
36 | callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
37 | }
38 |
39 | function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
40 | uint256 newAllowance = token.allowance(address(this), spender).add(value);
41 | callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
42 | }
43 |
44 | function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
45 | uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
46 | callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
47 | }
48 |
49 | /**
50 | * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement
51 | * on the return value: the return value is optional (but if data is returned, it must not be false).
52 | * @param token The token targeted by the call.
53 | * @param data The call data (encoded using abi.encode or one of its variants).
54 | */
55 | function callOptionalReturn(IERC20 token, bytes memory data) private {
56 | // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since
57 | // we're implementing it ourselves.
58 |
59 | // A Solidity high level call has three parts:
60 | // 1. The target address is checked to verify it contains contract code
61 | // 2. The call itself is made, and success asserted
62 | // 3. The return value is decoded, which in turn checks the size of the returned data.
63 | // solhint-disable-next-line max-line-length
64 | require(address(token).isContract(), "SafeERC20: call to non-contract");
65 |
66 | // solhint-disable-next-line avoid-low-level-calls
67 | (bool success, bytes memory returndata) = address(token).call(data);
68 | require(success, "SafeERC20: low-level call failed");
69 |
70 | if (returndata.length > 0) { // Return data is optional
71 | // solhint-disable-next-line max-line-length
72 | require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
73 | }
74 | }
75 | }
76 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/GSN/IRelayRecipient.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Base interface for a contract that will be called via the GSN from {IRelayHub}.
5 | *
6 | * TIP: You don't need to write an implementation yourself! Inherit from {GSNRecipient} instead.
7 | */
8 | interface IRelayRecipient {
9 | /**
10 | * @dev Returns the address of the {IRelayHub} instance this recipient interacts with.
11 | */
12 | function getHubAddr() external view returns (address);
13 |
14 | /**
15 | * @dev Called by {IRelayHub} to validate if this recipient accepts being charged for a relayed call. Note that the
16 | * recipient will be charged regardless of the execution result of the relayed call (i.e. if it reverts or not).
17 | *
18 | * The relay request was originated by `from` and will be served by `relay`. `encodedFunction` is the relayed call
19 | * calldata, so its first four bytes are the function selector. The relayed call will be forwarded `gasLimit` gas,
20 | * and the transaction executed with a gas price of at least `gasPrice`. `relay`'s fee is `transactionFee`, and the
21 | * recipient will be charged at most `maxPossibleCharge` (in wei). `nonce` is the sender's (`from`) nonce for
22 | * replay attack protection in {IRelayHub}, and `approvalData` is a optional parameter that can be used to hold a signature
23 | * over all or some of the previous values.
24 | *
25 | * Returns a tuple, where the first value is used to indicate approval (0) or rejection (custom non-zero error code,
26 | * values 1 to 10 are reserved) and the second one is data to be passed to the other {IRelayRecipient} functions.
27 | *
28 | * {acceptRelayedCall} is called with 50k gas: if it runs out during execution, the request will be considered
29 | * rejected. A regular revert will also trigger a rejection.
30 | */
31 | function acceptRelayedCall(
32 | address relay,
33 | address from,
34 | bytes calldata encodedFunction,
35 | uint256 transactionFee,
36 | uint256 gasPrice,
37 | uint256 gasLimit,
38 | uint256 nonce,
39 | bytes calldata approvalData,
40 | uint256 maxPossibleCharge
41 | )
42 | external
43 | view
44 | returns (uint256, bytes memory);
45 |
46 | /**
47 | * @dev Called by {IRelayHub} on approved relay call requests, before the relayed call is executed. This allows to e.g.
48 | * pre-charge the sender of the transaction.
49 | *
50 | * `context` is the second value returned in the tuple by {acceptRelayedCall}.
51 | *
52 | * Returns a value to be passed to {postRelayedCall}.
53 | *
54 | * {preRelayedCall} is called with 100k gas: if it runs out during exection or otherwise reverts, the relayed call
55 | * will not be executed, but the recipient will still be charged for the transaction's cost.
56 | */
57 | function preRelayedCall(bytes calldata context) external returns (bytes32);
58 |
59 | /**
60 | * @dev Called by {IRelayHub} on approved relay call requests, after the relayed call is executed. This allows to e.g.
61 | * charge the user for the relayed call costs, return any overcharges from {preRelayedCall}, or perform
62 | * contract-specific bookkeeping.
63 | *
64 | * `context` is the second value returned in the tuple by {acceptRelayedCall}. `success` is the execution status of
65 | * the relayed call. `actualCharge` is an estimate of how much the recipient will be charged for the transaction,
66 | * not including any gas used by {postRelayedCall} itself. `preRetVal` is {preRelayedCall}'s return value.
67 | *
68 | *
69 | * {postRelayedCall} is called with 100k gas: if it runs out during execution or otherwise reverts, the relayed call
70 | * and the call to {preRelayedCall} will be reverted retroactively, but the recipient will still be charged for the
71 | * transaction's cost.
72 | */
73 | function postRelayedCall(bytes calldata context, bool success, uint256 actualCharge, bytes32 preRetVal) external;
74 | }
75 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/drafts/ERC20Migrator.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../token/ERC20/IERC20.sol";
4 | import "../token/ERC20/ERC20Mintable.sol";
5 | import "../token/ERC20/SafeERC20.sol";
6 | import "../math/Math.sol";
7 |
8 | /**
9 | * @title ERC20Migrator
10 | * @dev This contract can be used to migrate an ERC20 token from one
11 | * contract to another, where each token holder has to opt-in to the migration.
12 | * To opt-in, users must approve for this contract the number of tokens they
13 | * want to migrate. Once the allowance is set up, anyone can trigger the
14 | * migration to the new token contract. In this way, token holders "turn in"
15 | * their old balance and will be minted an equal amount in the new token.
16 | * The new token contract must be mintable. For the precise interface refer to
17 | * OpenZeppelin's {ERC20Mintable}, but the only functions that are needed are
18 | * {MinterRole-isMinter} and {ERC20Mintable-mint}. The migrator will check
19 | * that it is a minter for the token.
20 | * The balance from the legacy token will be transferred to the migrator, as it
21 | * is migrated, and remain there forever.
22 | * Although this contract can be used in many different scenarios, the main
23 | * motivation was to provide a way to migrate ERC20 tokens into an upgradeable
24 | * version of it using ZeppelinOS. To read more about how this can be done
25 | * using this implementation, please follow the official documentation site of
26 | * ZeppelinOS: https://docs.zeppelinos.org/docs/erc20_onboarding.html
27 | *
28 | * Example of usage:
29 | * ```
30 | * const migrator = await ERC20Migrator.new(legacyToken.address);
31 | * await newToken.addMinter(migrator.address);
32 | * await migrator.beginMigration(newToken.address);
33 | * ```
34 | */
35 | contract ERC20Migrator {
36 | using SafeERC20 for IERC20;
37 |
38 | /// Address of the old token contract
39 | IERC20 private _legacyToken;
40 |
41 | /// Address of the new token contract
42 | ERC20Mintable private _newToken;
43 |
44 | /**
45 | * @param legacyToken address of the old token contract
46 | */
47 | constructor (IERC20 legacyToken) public {
48 | require(address(legacyToken) != address(0), "ERC20Migrator: legacy token is the zero address");
49 | _legacyToken = legacyToken;
50 | }
51 |
52 | /**
53 | * @dev Returns the legacy token that is being migrated.
54 | */
55 | function legacyToken() public view returns (IERC20) {
56 | return _legacyToken;
57 | }
58 |
59 | /**
60 | * @dev Returns the new token to which we are migrating.
61 | */
62 | function newToken() public view returns (IERC20) {
63 | return _newToken;
64 | }
65 |
66 | /**
67 | * @dev Begins the migration by setting which is the new token that will be
68 | * minted. This contract must be a minter for the new token.
69 | * @param newToken_ the token that will be minted
70 | */
71 | function beginMigration(ERC20Mintable newToken_) public {
72 | require(address(_newToken) == address(0), "ERC20Migrator: migration already started");
73 | require(address(newToken_) != address(0), "ERC20Migrator: new token is the zero address");
74 | //solhint-disable-next-line max-line-length
75 | require(newToken_.isMinter(address(this)), "ERC20Migrator: not a minter for new token");
76 |
77 | _newToken = newToken_;
78 | }
79 |
80 | /**
81 | * @dev Transfers part of an account's balance in the old token to this
82 | * contract, and mints the same amount of new tokens for that account.
83 | * @param account whose tokens will be migrated
84 | * @param amount amount of tokens to be migrated
85 | */
86 | function migrate(address account, uint256 amount) public {
87 | require(address(_newToken) != address(0), "ERC20Migrator: migration not started");
88 | _legacyToken.safeTransferFrom(account, address(this), amount);
89 | _newToken.mint(account, amount);
90 | }
91 |
92 | /**
93 | * @dev Transfers all of an account's allowed balance in the old token to
94 | * this contract, and mints the same amount of new tokens for that account.
95 | * @param account whose tokens will be migrated
96 | */
97 | function migrateAll(address account) public {
98 | uint256 balance = _legacyToken.balanceOf(account);
99 | uint256 allowance = _legacyToken.allowance(account, address(this));
100 | uint256 amount = Math.min(balance, allowance);
101 | migrate(account, amount);
102 | }
103 | }
104 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/utils/EnumerableSet.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | /**
4 | * @dev Library for managing
5 | * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
6 | * types.
7 | *
8 | * Sets have the following properties:
9 | *
10 | * - Elements are added, removed, and checked for existence in constant time
11 | * (O(1)).
12 | * - Elements are enumerated in O(n). No guarantees are made on the ordering.
13 | *
14 | * As of v2.5.0, only `address` sets are supported.
15 | *
16 | * Include with `using EnumerableSet for EnumerableSet.AddressSet;`.
17 | *
18 | * _Available since v2.5.0._
19 | *
20 | * @author Alberto Cuesta Cañada
21 | */
22 | library EnumerableSet {
23 |
24 | struct AddressSet {
25 | // Position of the value in the `values` array, plus 1 because index 0
26 | // means a value is not in the set.
27 | mapping (address => uint256) index;
28 | address[] values;
29 | }
30 |
31 | /**
32 | * @dev Add a value to a set. O(1).
33 | * Returns false if the value was already in the set.
34 | */
35 | function add(AddressSet storage set, address value)
36 | internal
37 | returns (bool)
38 | {
39 | if (!contains(set, value)){
40 | set.index[value] = set.values.push(value);
41 | return true;
42 | } else {
43 | return false;
44 | }
45 | }
46 |
47 | /**
48 | * @dev Removes a value from a set. O(1).
49 | * Returns false if the value was not present in the set.
50 | */
51 | function remove(AddressSet storage set, address value)
52 | internal
53 | returns (bool)
54 | {
55 | if (contains(set, value)){
56 | uint256 toDeleteIndex = set.index[value] - 1;
57 | uint256 lastIndex = set.values.length - 1;
58 |
59 | // If the element we're deleting is the last one, we can just remove it without doing a swap
60 | if (lastIndex != toDeleteIndex) {
61 | address lastValue = set.values[lastIndex];
62 |
63 | // Move the last value to the index where the deleted value is
64 | set.values[toDeleteIndex] = lastValue;
65 | // Update the index for the moved value
66 | set.index[lastValue] = toDeleteIndex + 1; // All indexes are 1-based
67 | }
68 |
69 | // Delete the index entry for the deleted value
70 | delete set.index[value];
71 |
72 | // Delete the old entry for the moved value
73 | set.values.pop();
74 |
75 | return true;
76 | } else {
77 | return false;
78 | }
79 | }
80 |
81 | /**
82 | * @dev Returns true if the value is in the set. O(1).
83 | */
84 | function contains(AddressSet storage set, address value)
85 | internal
86 | view
87 | returns (bool)
88 | {
89 | return set.index[value] != 0;
90 | }
91 |
92 | /**
93 | * @dev Returns an array with all values in the set. O(N).
94 | * Note that there are no guarantees on the ordering of values inside the
95 | * array, and it may change when more values are added or removed.
96 |
97 | * WARNING: This function may run out of gas on large sets: use {length} and
98 | * {get} instead in these cases.
99 | */
100 | function enumerate(AddressSet storage set)
101 | internal
102 | view
103 | returns (address[] memory)
104 | {
105 | address[] memory output = new address[](set.values.length);
106 | for (uint256 i; i < set.values.length; i++){
107 | output[i] = set.values[i];
108 | }
109 | return output;
110 | }
111 |
112 | /**
113 | * @dev Returns the number of elements on the set. O(1).
114 | */
115 | function length(AddressSet storage set)
116 | internal
117 | view
118 | returns (uint256)
119 | {
120 | return set.values.length;
121 | }
122 |
123 | /** @dev Returns the element stored at position `index` in the set. O(1).
124 | * Note that there are no guarantees on the ordering of values inside the
125 | * array, and it may change when more values are added or removed.
126 | *
127 | * Requirements:
128 | *
129 | * - `index` must be strictly less than {length}.
130 | */
131 | function get(AddressSet storage set, uint256 index)
132 | internal
133 | view
134 | returns (address)
135 | {
136 | return set.values[index];
137 | }
138 | }
139 |
--------------------------------------------------------------------------------
/src/node_modules/openzeppelin-solidity/contracts/token/ERC721/ERC721Metadata.sol:
--------------------------------------------------------------------------------
1 | pragma solidity ^0.5.0;
2 |
3 | import "../../GSN/Context.sol";
4 | import "./ERC721.sol";
5 | import "./IERC721Metadata.sol";
6 | import "../../introspection/ERC165.sol";
7 |
8 | contract ERC721Metadata is Context, ERC165, ERC721, IERC721Metadata {
9 | // Token name
10 | string private _name;
11 |
12 | // Token symbol
13 | string private _symbol;
14 |
15 | // Base URI
16 | string private _baseURI;
17 |
18 | // Optional mapping for token URIs
19 | mapping(uint256 => string) private _tokenURIs;
20 |
21 | /*
22 | * bytes4(keccak256('name()')) == 0x06fdde03
23 | * bytes4(keccak256('symbol()')) == 0x95d89b41
24 | * bytes4(keccak256('tokenURI(uint256)')) == 0xc87b56dd
25 | *
26 | * => 0x06fdde03 ^ 0x95d89b41 ^ 0xc87b56dd == 0x5b5e139f
27 | */
28 | bytes4 private constant _INTERFACE_ID_ERC721_METADATA = 0x5b5e139f;
29 |
30 | /**
31 | * @dev Constructor function
32 | */
33 | constructor (string memory name, string memory symbol) public {
34 | _name = name;
35 | _symbol = symbol;
36 |
37 | // register the supported interfaces to conform to ERC721 via ERC165
38 | _registerInterface(_INTERFACE_ID_ERC721_METADATA);
39 | }
40 |
41 | /**
42 | * @dev Gets the token name.
43 | * @return string representing the token name
44 | */
45 | function name() external view returns (string memory) {
46 | return _name;
47 | }
48 |
49 | /**
50 | * @dev Gets the token symbol.
51 | * @return string representing the token symbol
52 | */
53 | function symbol() external view returns (string memory) {
54 | return _symbol;
55 | }
56 |
57 | /**
58 | * @dev Returns the URI for a given token ID. May return an empty string.
59 | *
60 | * If the token's URI is non-empty and a base URI was set (via
61 | * {_setBaseURI}), it will be added to the token ID's URI as a prefix.
62 | *
63 | * Reverts if the token ID does not exist.
64 | */
65 | function tokenURI(uint256 tokenId) external view returns (string memory) {
66 | require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
67 |
68 | string memory _tokenURI = _tokenURIs[tokenId];
69 |
70 | // Even if there is a base URI, it is only appended to non-empty token-specific URIs
71 | if (bytes(_tokenURI).length == 0) {
72 | return "";
73 | } else {
74 | // abi.encodePacked is being used to concatenate strings
75 | return string(abi.encodePacked(_baseURI, _tokenURI));
76 | }
77 | }
78 |
79 | /**
80 | * @dev Internal function to set the token URI for a given token.
81 | *
82 | * Reverts if the token ID does not exist.
83 | *
84 | * TIP: if all token IDs share a prefix (e.g. if your URIs look like
85 | * `http://api.myproject.com/token/`), use {_setBaseURI} to store
86 | * it and save gas.
87 | */
88 | function _setTokenURI(uint256 tokenId, string memory _tokenURI) internal {
89 | require(_exists(tokenId), "ERC721Metadata: URI set of nonexistent token");
90 | _tokenURIs[tokenId] = _tokenURI;
91 | }
92 |
93 | /**
94 | * @dev Internal function to set the base URI for all token IDs. It is
95 | * automatically added as a prefix to the value returned in {tokenURI}.
96 | *
97 | * _Available since v2.5.0._
98 | */
99 | function _setBaseURI(string memory baseURI) internal {
100 | _baseURI = baseURI;
101 | }
102 |
103 | /**
104 | * @dev Returns the base URI set via {_setBaseURI}. This will be
105 | * automatically added as a preffix in {tokenURI} to each token's URI, when
106 | * they are non-empty.
107 | *
108 | * _Available since v2.5.0._
109 | */
110 | function baseURI() external view returns (string memory) {
111 | return _baseURI;
112 | }
113 |
114 | /**
115 | * @dev Internal function to burn a specific token.
116 | * Reverts if the token does not exist.
117 | * Deprecated, use _burn(uint256) instead.
118 | * @param owner owner of the token to burn
119 | * @param tokenId uint256 ID of the token being burned by the msg.sender
120 | */
121 | function _burn(address owner, uint256 tokenId) internal {
122 | super._burn(owner, tokenId);
123 |
124 | // Clear metadata (if any)
125 | if (bytes(_tokenURIs[tokenId]).length != 0) {
126 | delete _tokenURIs[tokenId];
127 | }
128 | }
129 | }
130 |
--------------------------------------------------------------------------------
/src/truffle-config-ganache.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Use this file to configure your truffle project. It's seeded with some
3 | * common settings for different networks and features like migrations,
4 | * compilation and testing. Uncomment the ones you need or modify
5 | * them to suit your project as necessary.
6 | *
7 | * More information about configuration can be found at:
8 | *
9 | * truffleframework.com/docs/advanced/configuration
10 | *
11 | * To deploy via Infura you'll need a wallet provider (like truffle-hdwallet-provider)
12 | * to sign your transactions before they're sent to a remote public node. Infura accounts
13 | * are available for free at: infura.io/register.
14 | *
15 | * You'll also need a mnemonic - the twelve word phrase the wallet uses to generate
16 | * public/private key pairs. If you're publishing your code to GitHub make sure you load this
17 | * phrase from a file you've .gitignored so it doesn't accidentally become public.
18 | *
19 | */
20 |
21 | // const HDWalletProvider = require('truffle-hdwallet-provider');
22 | // const infuraKey = "fj4jll3k.....";
23 | //
24 | // const fs = require('fs');
25 | // const mnemonic = fs.readFileSync(".secret").toString().trim();
26 | //
27 | // const argv = require('minimist')(process.argv.slice(2), {string: ['custom_argument']});
28 |
29 | // module.exports = function(deployer) {
30 | // ......
31 | // };
32 |
33 | module.exports = {
34 | /**
35 | * Networks define how you connect to your ethereum client and let you set the
36 | * defaults web3 uses to send transactions. If you don't specify one truffle
37 | * will spin up a development blockchain for you on port 9545 when you
38 | * run `develop` or `test`. You can ask a truffle command to use a specific
39 | * network from the command line, e.g
40 | *
41 | * $ truffle test --network
42 | */
43 |
44 | // console.log("----migration custom argument: ",argv['custom_argument']);
45 |
46 | networks: {
47 | // Useful for testing. The `development` name is special - truffle uses it by default
48 | // if it's defined here and no other network is specified at the command line.
49 | // You should run a client (like ganache-cli, geth or parity) in a separate terminal
50 | // tab if you use this network and you must also set the `host`, `port` and `network_id`
51 | // options below to some value.
52 | //
53 | development: {
54 | host: "127.0.0.1", // Localhost (default: none)
55 | port: 7545, // Standard Ethereum port (default: none)
56 | network_id: "*", // Any network (default: none)
57 | // from: '0xAddr' // to use a specific address to deploy contracts
58 | },
59 |
60 | // Another network with more advanced options...
61 | // advanced: {
62 | // port: 8777, // Custom port
63 | // network_id: 1342, // Custom network
64 | // gas: 8500000, // Gas sent with each transaction (default: ~6700000)
65 | // gasPrice: 20000000000, // 20 gwei (in wei) (default: 100 gwei)
66 | // from: , // Account to send txs from (default: accounts[0])
67 | // websockets: true // Enable EventEmitter interface for web3 (default: false)
68 | // },
69 |
70 | // Useful for deploying to a public network.
71 | // NB: It's important to wrap the provider as a function.
72 | // ropsten: {
73 | // provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/YOUR-PROJECT-ID`),
74 | // network_id: 3, // Ropsten's id
75 | // gas: 5500000, // Ropsten has a lower block limit than mainnet
76 | // confirmations: 2, // # of confs to wait between deployments. (default: 0)
77 | // timeoutBlocks: 200, // # of blocks before a deployment times out (minimum/default: 50)
78 | // skipDryRun: true // Skip dry run before migrations? (default: false for public nets )
79 | // },
80 |
81 | // Useful for private networks
82 | // private: {
83 | // provider: () => new HDWalletProvider(mnemonic, `https://network.io`),
84 | // network_id: 2111, // This network is yours, in the cloud.
85 | // production: true // Treats this network as if it was a public net. (default: false)
86 | // }
87 | },
88 |
89 | // Set default mocha options here, use special reporters etc.
90 | mocha: {
91 | // timeout: 100000
92 | },
93 |
94 | // Configure your compilers
95 | compilers: {
96 | solc: {
97 | // version: "0.5.1", // Fetch exact version from solc-bin (default: truffle's version)
98 | // docker: true, // Use "0.5.1" you've installed locally with docker (default: false)
99 | // settings: { // See the solidity docs for advice about optimization and evmVersion
100 | // optimizer: {
101 | // enabled: false,
102 | // runs: 200
103 | // },
104 | // evmVersion: "byzantium"
105 | // }
106 | }
107 | }
108 | }
109 |
110 |
--------------------------------------------------------------------------------