-
Notifications
You must be signed in to change notification settings - Fork 351
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Token factory smart contract #420
Open
DollarToken1792
wants to merge
19
commits into
circlefin:master
Choose a base branch
from
DollarToken1792:Token-Factory-Smart-Contract
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+624
−0
Open
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
c3a2a5d
Create npm-gulp.yml
DollarToken1792 1565753
Create abi-encode.yml
DollarToken1792 30acf61
Create abi-encode.js
DollarToken1792 d448450
Create npm-publish.yml
DollarToken1792 8131736
Create abi-encode.yml
DollarToken1792 8cb3147
Delete npm-gulp.yml
DollarToken1792 ca354f3
Update abi-encode.js
DollarToken1792 dfae5dd
Create npm-install
DollarToken1792 b918e98
Delete abi-encode.yml
DollarToken1792 e70ed52
Delete npm-install
DollarToken1792 eb30ae0
Delete npm-publish.yml
DollarToken1792 8d41e5f
Delete abi-encode.js
DollarToken1792 8813553
Create npm-publish.yml
DollarToken1792 5174142
Create abi-encode.yml
DollarToken1792 4458f3a
Add files via upload
DollarToken1792 d48ef6c
Add files via upload
DollarToken1792 a382ff5
Add files via upload
DollarToken1792 7d7bfe2
Update abi-encode.yml
DollarToken1792 b3fea4c
Add files via upload
DollarToken1792 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: ABI Encode | ||
on: | ||
push: | ||
branches: | ||
- master # Replace with your branch name | ||
|
||
jobs: | ||
abi-encode: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository | ||
uses: actions/checkout@v2 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v2 | ||
with: | ||
node-version: 14 | ||
|
||
- name: Install dependencies | ||
run: npm install | ||
|
||
- name: ABI Encode | ||
uses: blocklytics/[email protected] | ||
with: | ||
contractPath: ./contracts/Dollar.sol # Replace with your contract path | ||
arguments: '000000000000000000000000123456789abcdefABCDEF123456789ABCDEF123' # Replace with your constructor arguments |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# This workflow will run tests using node and then publish a package to GitHub Packages when a release is created | ||
# For more information see: https://docs.github.com/en/actions/publishing-packages/publishing-nodejs-packages | ||
|
||
name: Node.js Package | ||
|
||
on: | ||
release: | ||
types: [created] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
- run: npm ci | ||
- run: npm test | ||
|
||
publish-npm: | ||
needs: build | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 | ||
registry-url: https://registry.npmjs.org/ | ||
- run: npm ci | ||
- run: npm publish | ||
env: | ||
NODE_AUTH_TOKEN: ${{secrets.npm_token}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/token/ERC20/ERC20.sol"; | ||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/access/Ownable.sol"; | ||
|
||
contract DollarToken is ERC20, Ownable { | ||
bool private _contractCreated; | ||
address private _tokenFactory; | ||
|
||
modifier onlyTokenFactory() { | ||
require(msg.sender == _tokenFactory, "Only the token factory can create instances of this contract"); | ||
_; | ||
} | ||
|
||
constructor(address tokenFactory) ERC20("Dollar", "$") { | ||
require(!_contractCreated, "Contract already created"); | ||
_contractCreated = true; | ||
_tokenFactory = tokenFactory; | ||
|
||
uint256 initialSupply = 32674174016000000000000 * (10**6); // 32,674,174,016 tokens with 6 decimals | ||
_mint(msg.sender, initialSupply); | ||
} | ||
|
||
function additionalMint(uint256 amount) public onlyOwner { | ||
_mint(msg.sender, amount); | ||
} | ||
|
||
function burn(uint256 amount) public { | ||
_burn(msg.sender, amount); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/token/ERC20/ERC20.sol"; | ||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/access/Ownable.sol"; | ||
|
||
contract DollarTokenFactory is Ownable { | ||
event TokenCreated(address indexed tokenAddress); | ||
|
||
function createToken(string memory name, string memory symbol, uint256 initialSupply) external onlyOwner { | ||
DollarToken token = new DollarToken(name, symbol, initialSupply); | ||
emit TokenCreated(address(token)); | ||
} | ||
} | ||
|
||
contract DollarToken is ERC20 { | ||
constructor(string memory name, string memory symbol, uint256 initialSupply) ERC20(name, symbol) { | ||
_mint(msg.sender, initialSupply); | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
// SPDX-License-Identifier: MIT | ||
pragma solidity ^0.8.19; | ||
|
||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/token/ERC20/ERC20.sol"; | ||
import "https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v4.4.0/contracts/access/Ownable.sol"; | ||
|
||
contract DollarToken is ERC20, Ownable { | ||
bool private _contractCreated; | ||
address private _tokenFactory; | ||
|
||
modifier onlyTokenFactory() { | ||
require(msg.sender == _tokenFactory, "Only the token factory can create instances of this contract"); | ||
_; | ||
} | ||
|
||
constructor(address tokenFactory) ERC20("Dollar", "$") { | ||
require(!_contractCreated, "Contract already created"); | ||
_contractCreated = true; | ||
_tokenFactory = tokenFactory; | ||
|
||
uint256 initialSupply = 32674174016000000000000 * (10**6); // 32,674,174,016 tokens with 6 decimals | ||
_mint(msg.sender, initialSupply); | ||
} | ||
|
||
function additionalMint(uint256 amount) public onlyOwner { | ||
_mint(msg.sender, amount); | ||
} | ||
|
||
function burn(uint256 amount) public { | ||
_burn(msg.sender, amount); | ||
} | ||
} | ||
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Uploading Logo.fig…