create-kalp-dapp
v1.0.2
Published
Create Kalp DLT dApps with no build configuration
Downloads
6
Readme
create-kalp-dapp
A full-stack starter template featuring Next.js & Go, designed for building dApps and developing smart contracts on the Kalp DLT blockchain. This starter kit provides a simple greeting dApp to demonstrate interaction with a Kalp DLT smart contract.
🚀 Quick Start
npx create-kalp-dapp <your-dapp-name>
# cd into the directory
cd <your-dapp-name>
📦 Installation
Open your terminal and run:
npx create-kalp-dapp <your-dapp-name>
cd <your-dapp-name>
🏗 Project Structure
After creation, your project should look like this:
<your-dapp-name>/
├── backend/
│ ├── vendor/
│ ├── go.mod
│ ├── go.sum
│ ├── main.go
│ └── krc.go
├── frontend/
│ ├── src/
│ │ ├── app/
│ │ ├── hooks/
│ │ └── utils/
│ ├── .env.local.example
│ ├── next.config.mjs
│ ├── package.json
│ └── tailwind.config.ts
└── README.md
📜 Smart Contract Development
Setting up the Smart Contract Project
Navigate to the smart contract directory:
cd backend
Install dependencies:
go mod tidy
Smart Contract Code
The main smart contract file is krc.go
. It includes a simple greeting contract with Init
, SetGreeting
, and GetGreeting
functions.
Compiling and Deploying the Smart Contract
Sign Up and Log In to Kalp Studio Platform
Go to Kalp Instant Deployer
Click on "Create New" Smart Contract
Enter the details:
- Name: Enter a name for your smart contract
- Category: Choose a category
- Description: Add a description (optional)
Upload your
backend.zip
file (zip the contents of thebackend
folder)Deploy your contract
After deployment, Kalp Studio will provide you with API endpoints for each function of your smart contract.
Generating API Key
In Kalp Studio, navigate to the API key generation section and generate a new API key to authenticate your API requests.
💻 Frontend Development
Setting up the Frontend
Navigate to the frontend directory:
cd frontend
Install dependencies:
npm install
Set up environment variables:
- Copy
.env.local.example
to.env.local
- Update
NEXT_PUBLIC_API_KEY
andNEXT_PUBLIC_CONTRACT_ID
with your Kalp Studio API key and deployed contract ID
- Copy
Running the Frontend
Start the development server:
npm run dev
Visit http://localhost:3000
to see your dApp in action.
🔧 Interacting with the Smart Contract
The frontend includes a simple interface to interact with your greeting smart contract:
- View the current greeting
- Set a new greeting
All interactions are handled through the Kalp DLT API, using the endpoints provided by Kalp Studio.
🔑 API Integration
The useKalpApi
hook in src/hooks/useKalpApi.tsx
handles all API calls to your smart contract. Make sure to update the contract ID and API key in your .env.local
file for proper functionality.
➡️ Contributing
We welcome contributions! Please see our CONTRIBUTING.md file for details on how to get started.
⚖️ License
create-kalp-dapp is licensed under the MIT License.
⭐️ If you find this project helpful, please give it a star on GitHub!