This project allows us to create a fungible token that is ERC-20 compliant and that will be minted by using a Crowdsale
contract from the OpenZeppelin Solidity library.
The crowdsale contract that you create will manage the entire crowdsale process, allowing users to send ether to the contract and in return receive KSI, or KaseiCoin tokens. Your contract will mint the tokens automatically and distribute them to buyers in one transaction.
This project leverages python version 3.8.5 with the following packages and modules:
-
pandas - version 1.3.2 - This was used to be able to easily manipulate dataframes and create dataframes.
-
hashlib- This module implements a common interface to many different secure hash and message digest algorithms. In our application, we use SHA256 to return a hexdigest.
-
Solidity - This is used to create the smart contract and implement the joints saving application to work with ether.
-
Remix IDE - This is used to be able to write and edit solidity formatted code, and this is where the joints saving application will be launched.
-
MetaMask - This is a digital wallet and a gateway for the Ethereum blockchain.
-
Ganache - This is a tool that allows us to quickly set up a local blockchain, which we can use to test and develop smart contracts.
-
OpenZeppelin - OpenZeppelin library provides a wide variety of contracts that are related to the ERC-20 token standard. This also allows us to access the imports for the ERC-20 tokens on the
.sol
files.
1. Install MetaMask and create an account. You can also add a Google Chrome extension for this.
2. Install Ganache on your desktop.
3. Open the REMIX IDE to view and edit the KaseiCoin.sol
and KaseiCoinCrowdsale.sol
file.
- Make sure to
git clone
the file first from this repository.
4. Then when on the REMIX IDE, click on the left icon logo, and then click Open file and navigate to where the git clone files are locally saved on your machine.
- This should open the file through this IDE for you to compile the smart contract.
5. Let's compile the KaseiCoin.sol
and KaseiCoinCrowdsale.sol
file and make sure that the compiler is version 0.5.7 (or at least anything above version 0.5.5).
1. Successful compilation of the KaseiCoin.sol
Contract, the KaseiCoinCrowdsale.sol
Contract and the KaseiCoinCrowdsale Deployer
Contract.
- Deploy the
KaseiCoinCrowdsale.sol
with KaseiCoin Crowdsale Deployer Contract using Injected Web3 environment (which by default the Metamask extension will pop-up). Add the following variables needed such as the Kasei, KSI, and Wallet address, then click Deploy.
3. Test the functionality of the crowdsale by using test accounts to buy new tokens and then checking the balances associated with those accounts. After purchasing tokens with one or more test accounts, view the total supply of minted tokens and the amount of wei that has been raised in the crowdsale contract.
- Go back to the settings and change the contract to KaseiCoin Crowdsale Contract. Copy the wallet address under Crowdsale shown on the KaseiCoin Crowdsale Deployer Contract (after deploying) and paste that on the At Address.
-
After that, (scroll down) copy and paste the wallet address from Ganache, (scroll up) add the number of ether to buy, then click
Transact
. The weiRaised supply should have the same number of ETH that was bought. Once you buy the tokens, check your Ganache and Metamask transactions. -
Go back to the settings and change the contract to KaseiCoin Contract. Copy the wallet address under Token shown on the KaseiCoin Crowdsale Deployer Contract (after deploying) and paste that on the At Address. After that, scroll down to the totalSupply it should have the same number as the weiRaised supply and with the same number of ETH that was bought.
-
To buy tokens: After compiling both KaseiCoin and KaseiCoinContract, go to the KaseiCoin Crowdsale Deployer Contract, then put in the necessary information. After deploying, scroll down and copy the address under
crowdsale
:Name: Kasei Symbol: KSI Wallet: <your hash address> Goal: 10000000000000000000 wei or 10 ETH (or whatever goal you prefer)
-
Scroll up, and change the contract to KaseiCoin Crowdsale Contract. Paste that crowdsale address onto the At Address, then proceed to add the number of ETH (based on your goal earlier), in this case, we are buying 10ETH, and then fill out the beneficiary address on the
buyTokens
, then clicktransact
. The Metamask should pop-up, then confirm that. You can check yourisOpen
, if still true then it means your contract has not been finalized. Wait another few minutes (assuming your code for close time is fornow + 5 minutes
) before clicking finalize. After a few minutes, click thefinalize
(the orange button), and your Metamask should pop-up again. -
Check your
isOpen
which should say false. -
You can check your
balanceOf
and it should have the same amount of wei from your goal. -
You can also check
goalReached
and it should say true which means it has met the goal initially added on the KaseiCoin Crowdsale Contract Deployer.
Contributed by: Justine Cho
Email: chojustine0@gmail.com
Copyright (c) [2021] [Justine Cho]
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.