This repo represents a crowdsale for a fungible token that’s ERC-20 compliant. This token will be minted by using a Crowdsale contract from the OpenZeppelin Solidity library.
After waiting for years and passing several tests, the Martian Aerospace Agency selected you to become part of the first human colony on Mars. As a prominent fintech professional, they chose you to lead a project developing a monetary system for the new Mars colony. You decided to base this new system on blockchain technology and to define a new cryptocurrency named KaseiCoin. (Kasei means Mars in Japanese.)
KaseiCoin will be a fungible token that’s ERC-20 compliant. You’ll launch a crowdsale that will allow people who are moving to Mars to convert their earthling money to KaseiCoin.
In this subsection, you’ll create a smart contract that defines KaseiCoin as an ERC-20 token. To do so, complete the following steps:
-
Import the provided
KaseiCoin.sol
starter file into the Remix IDE. -
Import the following contracts from the OpenZeppelin library:
-
ERC20
-
ERC20Detailed
-
ERC20Mintable
-
-
Define a contract for the KaseiCoin token, and name it
KaseiCoin
. Have the contract inherit the three contracts that you just imported from OpenZeppelin. -
Inside your
KaseiCoin
contract, add a constructor with the following parameters:name
,symbol
, andinitial_supply
. -
As part of your constructor definition, add a call to the constructor of the
ERC20Detailed
contract, passing the parametersname
,symbol
, and18
. (Recall that 18 is the value for thedecimals
parameter.) -
Compile the contract by using compiler version 0.5.0.
-
Check for any errors, and debug them as needed.
-
Take a screenshot of the successful compilation of the contract, and add it to the Evaluation Evidence section of the
README.md
file for your GitHub repository.
In this subsection, you’ll define the KaseiCoin crowdsale contract. To do so, complete the following steps:
-
Import the provided
KaseiCoinCrowdsale.sol
starter code into the Remix IDE. -
Have this contract inherit the following OpenZeppelin contracts:
-
Crowdsale
-
MintedCrowdsale
-
-
In the
KaisenCoinCrowdsale
constructor, provide parameters for all the features of your crowdsale, such asrate
,wallet
(where to deposit the funds that the token raises), andtoken
. Configure these parameters as you want for your KaseiCoin token.
In this subsection, you’ll create the KaseiCoin deployer contract. Start by uncommenting the KaseiCoinCrowdsaleDeployer
contract in the provided KaseiCoinCrowdsale.sol
starter code.
Next, in the KaseiCoinCrowdsaleDeployer
contract, you’ll add variables to store the addresses of the KaseiCoin
and KaseiCoinCrowdsale
contracts, which this contract will deploy. Finally, you’ll complete the KaseiCoinCrowdsaleDeployer
contract. To do so, complete the following steps:
-
Create an
address public
variable namedkasei_token_address
, which will store theKaseiCoin
address once that contract has been deployed. -
Create an
address public
variable namedkasei_crowdsale_address
, which will store theKaseiCoinCrowdsale
address once that contract has been deployed. -
Add the following parameters to the constructor for the
KaseiCoinCrowdsaleDeployer
contract:name
,symbol
, andwallet
. -
Inside of the constructor body (that is, between the braces), complete the following steps:
-
Create a new instance of the
KaseiCoinToken
contract. -
Assign the address of the KaseiCoin token contract to the
kasei_token_address
variable. (This will allow you to easily fetch the token's address later.) -
Create a new instance of the
KaseiCoinCrowdsale
contract by using the following parameters:-
The
rate
parameter: Setrate
equal to 1 to maintain parity with ether. -
The
wallet
parameter: Pass inwallet
from the main constructor. This is the wallet that will get paid all the ether that the crowdsale contract raises. -
The
token
parameter: Make this thetoken
variable whereKaseiCoin
is stored.
-
-
Assign the address of the KaseiCoin crowdsale contract to the
kasei_crowdsale_address
variable. (This will allow you to easily fetch the crowdsale’s address later.) -
Set the
KaseiCoinCrowdsale
contract as a minter. -
Have the
KaseiCoinCrowdsaleDeployer
renounce its minter role.
-
-
Compile the contract by using compiler version 0.5.0.
-
Check for any errors, and debug them as needed.
-
Take a screenshot of the successful compilation of the contract, and add it to the Evaluation Evidence section of the
README.md
file for your Git repository.
In this subsection, you’ll deploy the crowdsale to a local blockchain. You’ll then perform a real-world, preproduction test of your crowdsale. To do so, complete the following steps:
- Deploy the crowdsale to a local blockchain by using Remix, MetaMask, and Ganache.
- Test the functionality of the crowdsale by using test accounts to buy new tokens and then checking the balances of those accounts.
- Review the total supply of minted tokens and the amount of wei that the crowdsale contract has raised.