PROJECT: Decentralized Star Notary Service Project - For this project, you will create a DApp by adding functionality with your smart contract and deploy it on the public testnet.
This Starter Code has already implemented the functionalities you implemented in the StarNotary (Version 2) exercise, and have comments in all the files you need to implement your tasks.
- Truffle v5.5.11 (core: 5.5.11)
- Ganache v^7.0.4
- Solidity - 0.8.4 (solc-js)
- Node v17.6.0
- Web3.js v1.5.3
- OpenZeppelin v^4.4.2
- ERC721 Token Symbol: SNT
- Token name: StarNotaryToken
- Token address
- Contract addess
Your Project is to Modify the StarNotary version 2 contract code to achieve the following:
Add a name and a symbol for your starNotary tokens. Resource
Add a function lookUptokenIdToStarInfo, that looks up the stars using the Token ID, and then returns the name of the star.
Add a function called exchangeStars, so 2 users can exchange their star tokens...Do not worry about the price, just write code to exchange stars between users.
Write a function to Transfer a Star. The function should transfer a star from the address of the caller. The function should accept 2 arguments, the address to transfer the star to, and the token ID of the star.
Add supporting unit tests, to test the following:
The token name and token symbol are added properly.
2 users can exchange their stars.
Stars Tokens can be transferred from one address to another.
Deploy your Contract to Rinkeby
Edit the truffle.config file to add settings to deploy your contract to the Rinkeby Public Network.
Helper Points:
Command used to deploy to Rinkeby truffle migrate --reset --network rinkeby
You will need to have your Metamask’s seed and Infura setup.
This was shown to you in detail in the lesson on Solidity, while creating ERC-20 tokens on Rinkeby.
Modify the front end of the DAPP to achieve the following:
Lookup a star by ID using tokenIdToStarInfo() (you will have to add code for this in your index.html and index.js files)
For this project, you will need to have:
- Node and NPM installed - NPM is distributed with Node.js
# Check Node version
node -v
# Check NPM version
npm -v
- Truffle v5.X.X - A development framework for Ethereum.
# Unsinstall any previous version
npm uninstall -g truffle
# Install
npm install -g truffle
# Specify a particular version
npm install -g [email protected]
# Verify the version
truffle version
-
Metamask: 5.3.1 - If you need to update Metamask just delete your Metamask extension and install it again.
-
Ganache - Make sure that your Ganache and Truffle configuration file have the same port.
-
Other mandatory packages:
cd app
# install packages
npm install --save [email protected]
npm install --save [email protected]
npm install webpack-dev-server -g
npm install web3
- Clean the frontend
cd app
# Remove the node_modules
# remove packages
rm -rf node_modules
# clean cache
npm cache clean
rm package-lock.json
# initialize npm (you can accept defaults)
npm init
# install all modules listed as dependencies in package.json
npm install
- Start Truffle by running
# For starting the development console
truffle develop
# truffle console
# For compiling the contract, inside the development console, run:
compile
# For migrating the contract to the locally running Ethereum network, inside the development console
migrate --reset
# For running unit tests the contract, inside the development console, run:
test
- Frontend - Once you are ready to start your frontend, run the following from the app folder:
cd app
npm run dev
When you will add a new Rinkeyby Test Network in your Metamask client, you will have to provide:
Network Name | New RPC URL | Chain ID |
---|---|---|
Private Network 1 | http://127.0.0.1:9545/ |
1337 |
The chain ID above can be fetched by:
cd app
node index.js
'webpack-dev-server' is not recognized as an internal or external command
Solution:
- Delete the node_modules folder, the one within the /app folder
- Execute
npm install
command from the /app folder
After a long install, everything will work just fine!
ParserError: Source file requires different compiler version.
Error: Truffle is currently using solc 0.5.16, but one or more of your contracts specify "pragma solidity >=0.X.X <0.X.X".
Solution: In such a case, ensure the following in truffle-config.js
:
// Configure your compilers
compilers: {
solc: {
version: "0.5.16", // <- Use this
// docker: true,
// ...
-
Feel free to raise a Pull Request if you find a bug/scope of improvement in the current repository.
-
If you have suggestions or facing issues, you can log in issue.
Do not use the Old depreacted zipped starter code