1.0.0 โ€ข Published 11 months ago

create-kii-dapp v1.0.0

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

A full-stack starter template featuring Nextjs & Hardhat or Foundry, designed for building Dapps, as well as developing, deploying, and testing Solidity smart contracts on the KiiChain. This starter kit includes pre-installed packages such as create-next-app, hardhat, foundry, typescript, tailwindcss, shadcn-ui, web3.js, and more.

๐Ÿ“บ Quickstart

You will find the Nextjs & Hardhat implementation guide Here.

You will find the Nextjs & Foundry implementation guide Here.

โŒ›๏ธ create-kii-dapp Command

Open up your terminal (or command prompt) and type the following command:

npx create-kii-dapp <your-dapp-name>

# Select Hardhat or Foundry Option

# cd into the directory
cd <your-dapp-name>

Note: If you have used the npx command then you don't have to install manually in any directory.

Hardhat Setup

๐Ÿ“œ Smart Contracts

All smart contracts are located inside the backend aka hardhat folder, which can be found in the root directory. To get started, first install the necessary dependencies by running:

# change directory into the backend folder
cd backend

npm install

๐Ÿ”‘ Private Key

Ensure you create a .env file in the backend directory. Then paste your Metamask private key in .env with the variable name ACCOUNT_PRIVATE_KEY as follows:

ACCOUNT_PRIVATE_KEY=0x734...

โš™๏ธ Compile

Now, you can write your contracts in ./contracts/ directory, replace Greeter.sol with <your-contracts>.sol file.

# For compiling the smart contracts
npx hardhat compile

After successful compilation, the artifacts directory will be created in ./src with a JSON /contracts/<your-contracts>.sol/<your-contracts>.json containing ABI and Bytecode of your compiled smart contracts.

๐Ÿงช Test

To write tests, go to ./test directory and create <your-contracts>.ts, you can test your smart contracts using the following command.

# For testing the smart contracts
npx hardhat test

โ›“๏ธ Deploy

Before deploying the smart contracts, ensure that you have added the KiiChain to your MetaMask wallet and that it has sufficient funds. If you do not have testnet $kii on KiiChain, please follow this faucets guide.

Also, make changes in ./scripts/deploy.ts (replace the greeter contract name with <your-contract-name>).

For deploying the smart contracts to KiiChain network, type the following command:

# For deploying the smart contracts
npx hardhat run scripts/deploy.ts --network kiichain
<your-contract> deployed to: 0x...

Copy and paste the generated contract JSON ABI folder contracts inside the backend/src/contracts directory to the /frontend/ directory.

Copy and paste the deployed contract address here.

Foundry Setup

๐Ÿ“œ Smart Contracts

All smart contracts are located inside the backend aka foundry folder, which can be found in the root directory.

# change directory into the backend folder
cd backend

๐Ÿ”‘ Private Key

Ensure you create a .env file in the backend directory. Then paste your Metamask private key in .env with the variable name ACCOUNT_PRIVATE_KEY as follows:

ACCOUNT_PRIVATE_KEY=0x734...

โš™๏ธ Compile

Now, you can write your contracts in ./src/ directory, replace Greeter.sol with <your-contracts>.sol file.

# For compiling the smart contracts
forge compile

After successful compilation, the artifacts directory will be created in ./out with a JSON /<your-contract>/<your-contracts>.json containing ABI and Bytecode of your compiled smart contracts.

๐Ÿงช Test

To write tests, go to ./test directory and create <your-contracts>.t.sol, you can test your smart contracts using the following command.

# For testing the smart contracts
forge test

โ›“๏ธ Deploy

Before deploying the smart contracts, ensure that you have added the KiiChain to your MetaMask wallet and that it has sufficient funds. If you do not have testnet $kii on KiiChain, please follow this faucets guide.

Also, make changes in ./script/DeployGreeter.s.sol (replace the deploy greeter contract name with <your-contract-name>).

For deploying the smart contracts to KiiChain network, type the following command:

# For deploying the smart contracts
forge script script/DeployGreeter.s.sol --broadcast --rpc-url https://a.sentry.testnet.kiivalidator.com:8645/ --gas-limit 30000000 --with-gas-price 5gwei --skip-simulation
<your-contract> deployed to: 0x...

Copy and paste the generated contract JSON ABI folder Greeter.sol inside the backend/out/ directory to the /frontend/ directory.

Copy and paste the deployed contract address here.

Next.js Client

Start the Next.js app by running the following command in the frontend directory:

# Change directory into the frontend folder 
cd frontend

# Start the development server
npm run dev

โžก๏ธ Contributing

We welcome contributions from the community! If you'd like to contribute, please follow the guidelines in our CONTRIBUTING.md file.

โš–๏ธ License

create-kii-dapp is licensed under the MIT License.

1.0.0

11 months ago