Sardaukar Bootcamp
Website
https://sardaukarchant-foldinside-replitf-old.vercel.app/ - Pointing @ TESTNET Rinkeby
Smart Contract Address (Rinkeby)
0x53E47439455BaA44eE92E8172AB7aE677613BA06
https://rinkeby.etherscan.io/address/0x53e47439455baa44ee92e8172ab7ae677613ba06
Screencast https://www.loom.com/share/6a73d5a8b4e34ffcada208ddfc006f88?sharedAppSource=personal_library
I buidled a website called the 🩸SARDAUKAR BOOTCAMP🩸 --- it'll be a place where anyone on the internet can chant to the maker and have that data saved on the blockchain through an Ethereum smart contract. This project demonstrates a basic wallet interaction, transaction, and storage use case. It comes with a custom .sol contract, a custom script that deploys that contract, and an example of a task implementation, which simply lists the available accounts.
SETTING UP LOCAL ETH ENVIRONMENT -This is the area where you will be able to compile & test your smart contract code. (Note) node/npm is REQUIRED to implement this project, Click here to install.
Local Setup
The current .sol smart contract file in git is pointing to the Rinkeby Testnet. If you only need to run the frontend, you can skip the Smart Contract build and deploy steps.
MAKE SURE YOU ARE CONNECTED TO THE RINKEBY TEST NETWORK BEFORE ATTEMPTING CONTRACT INTERACTION
BUILD
-
Using Hardhat (assuming NODE/NPM is already on sys)
mkdir mySampleProjcd mySampleProjnpm init -ynpm install --save-dev hardhat -
Run created sample project:
npx hardhat(Note) Carefully read what is output and run commands accordingly. -
Choose the option to create a sample project. Say yes to everything. The sample project will ask you to install
hardhat-waffleandhardhat-ethersDO NOT FORGET THIS INSTRUCTION FROM HARDHAT!!!
- You need to install these dependencies to run the sample project:
npm install --save-dev "hardhat@^2.6.8" "@nomiclabs/hardhat-waffle@^2.0.0" "ethereum-waffle@^3.0.0" "chai@^4.2.0" "@nomiclabs/hardhat-ethers@^2.0.0" "ethers@^5.0.0"
- Finally, run
npx hardhat accounts
- and this should print out a bunch of strings that look like this: 0xBLAHBLAHRANDOMaDDRESS9720
- To make sure everything is working we assure we can compile our contracts by running:
npx hardhat compileNext run:npx hardhat test
Output should display the contents of the .sol contract code.
- Open the code for the project now in your favorite code editor
- Delete the file
sample-test.jsunder test. Also, deletesample-script.jsunderscripts. Then, deleteGreeter.solunder contracts. Do NOT delete the actual folders!
Writing Contract
- Create a file named
sardaukar.solunder the contracts directory in your code editor
- Refer to code in:
Initialize Local Blockchain Environment to Test
- Go into the
scriptsdirectory and make a file namedrun.js
- Refer to code in:
- Run:
npx hardhat run scripts/run.jsRun this any time code is altered to ensure its functionality
Running Local Node
- In terminal window separate to your current workspace, cd into your proj then run:
npx hardhat nodeThis will create a local Ethereum network that stays alive as long as the terminal window remains open. - Create a file named
deploy,jsunder the scripts directory in youe code editor
- Refer to code in:
- Now the command we're going to run to deploy locally is:
npx hardhat run scripts/deploy.js --network localhost
(Note)
This is run from your mySampleProj directory in a terminal window separate from the window hosting our local blockchain environment.
Explanation of REPLIT code
- Create a replit profile
- you can fork this project here
- Metamask can be found here
- Create an Alchemy account & create a DEVELOPMENT app using the RINKEBY testnet under the ETH Network here
- Add your PRIVATE Metamask Key + DEVELOPMENT Alchemy key to your
hardhat.config,jsfile
- Reference final
hardhat.config.jsfile for updated code where PRIVATE KEY values will be utilized DO NOT COMMIT BARE PRIVATE KEYS TO GITHUB OR ANYWHEREdotenvis used in this example.
- Withing your project directory run:
npm install --save dotenv - Refer to
hardhat.config.jsfor code skeleton - Create a
.envfile withing the projects directory. Format is as follows:
STAGING_ALCHEMY_KEY=; PROD_ALCHEMY_KEY=; PRIVATE_KEY=;
- Ensure
.envis withing your.gitignorefile
- Run:
npx hardhat run scripts/deploy.js --network rinkebyto deploy to the Rinkeby testnet RECORD WHAT IS OUTPUT TO YOUR TERMINAL (Note) Any changes to LOCAL contracts' code will need to be re-tested, then re-deployed.
- Deploy your script again
- Update the contract address on your Replit frontend
- Once re-deployed you must take the NEW contract address output to your terminal & add it to your
app.jscode via Replit underconst contractAddress yourSampleProj address: 0xBLAHBLAHBLAH50763
- Update the ABI file on our Replit frontend
- Locate the ABI code in your LOCAL code env via this path:
artifacts/contracts/yourSampleProj.sol/yourSampleProj.json, then copy said code and paste said code under such path on Replit under this path:./src/utils/sardaukarchant.json
Screencast https://www.loom.com/share/6a73d5a8b4e34ffcada208ddfc006f88?sharedAppSource=personal_library