Skip to content

Commit

Permalink
added disperse contact and docker
Browse files Browse the repository at this point in the history
  • Loading branch information
menawar committed Aug 1, 2022
1 parent a5d472a commit d37437e
Show file tree
Hide file tree
Showing 8 changed files with 10,454 additions and 13 deletions.
7 changes: 4 additions & 3 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC1
ROPSTEN_URL=https://eth-ropsten.alchemyapi.io/v2/<YOUR ALCHEMY KEY>
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc1
TESTNET_URL=https://ropsten.infura.io/v3/e48bbd8badb94d408f15eaad7e1ba4f9
ETHERSCAN_API_KEY=ABC123ABC123ABC123ABC123ABC123ABC8
PRIVATE_KEY=0xabc123abc123abc123abc123abc123abc123abc123abc123abc123abc123abc3

19 changes: 19 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
FROM node:16-alpine

WORKDIR /usr/src/app
RUN apk add --no-cache python3 make g++

COPY package*.json ./
RUN npm install

COPY test/* test/
COPY scripts/* scripts/
COPY contracts/* contracts/
COPY tsconfig.json .
COPY hardhat.config.ts .

RUN npm run compile
RUN npm run test

COPY $PWD/docker/* /usr/local/bin/
ENTRYPOINT ["/bin/sh", "/usr/local/bin/entrypoint.sh"]
10 changes: 6 additions & 4 deletions contracts/CBToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,11 @@ contract CBToken is ERC20, AccessControl {
bytes32 public constant BURNER_ROLE = keccak256("BURNER_ROLE");
uint8 private _decimals;

constructor(string memory name_, string memory symbol_, uint8 decimals_)
ERC20(name_, symbol_)
{
constructor(
string memory name_,
string memory symbol_,
uint8 decimals_
) ERC20(name_, symbol_) {
_grantRole(DEFAULT_ADMIN_ROLE, msg.sender);
_grantRole(MINTER_ROLE, msg.sender);
_grantRole(BURNER_ROLE, msg.sender);
Expand All @@ -22,7 +24,7 @@ contract CBToken is ERC20, AccessControl {
function decimals() public view virtual override returns (uint8) {
return _decimals;
}

function mint(address to, uint256 amount) external onlyRole(MINTER_ROLE) {
_mint(to, amount);
}
Expand Down
7 changes: 7 additions & 0 deletions docker/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh
# Change to the correct directory
cd /usr/src/app;
# Compile contracts
npm run compile;
# Deploy contract
npm run deploy;
9 changes: 9 additions & 0 deletions docker/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/bin/sh
# Change to the correct directory
cd /usr/src/app;
# Keep node alive
set -e
if [ "${1#-}" != "${1}" ] || [ -z "$(command -v "${1}")" ]; then
set -- node "$@"
fi
exec "$@"
13 changes: 7 additions & 6 deletions hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,16 @@ task("accounts", "Prints the list of accounts", async (taskArgs, hre) => {
const config: HardhatUserConfig = {
solidity: "0.8.4",
networks: {
ropsten: {
url: process.env.ROPSTEN_URL || "",
mainnet: {
url: process.env.MAINNET_URL || "",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
testnet: {
url: process.env.TESTNET_URL || "",
accounts:
process.env.PRIVATE_KEY !== undefined ? [process.env.PRIVATE_KEY] : [],
},
},
gasReporter: {
enabled: process.env.REPORT_GAS !== undefined,
currency: "USD",
},
etherscan: {
apiKey: process.env.ETHERSCAN_API_KEY,
Expand Down
8 changes: 8 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
{
"name": "nb-sandbox-token",
"scripts": {
"compile": "hardhat compile",
"deploy_CBToken:testnet": "hardhat run scripts/deploy.ts --network testnet",
"deploy_CBToken:mainnet": "hardhat run scripts/deploy.ts --network mainnet",
"deploy_disperse:testnet": "hardhat run scripts/disperse.ts --network testnet",
"deploy_dispers:mainnet": "hardhat run scripts/disperse.ts --network mainnet",
"test": "hardhat test"
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "^2.0.5",
"@nomiclabs/hardhat-etherscan": "^3.0.3",
Expand Down
Loading

0 comments on commit d37437e

Please sign in to comment.