Deploy your first app
Klave is built to make your life as easy as possible when creating application for confidential computing.
At the moment Klave leverages on a git developer workflow and is able to connect directly to your GitHub repository to detect and automatically deploy changes brought to your applications.
Create a scaffold
We will first start by using the Klave NPM package to scaffold a small app automagically.
Prerequisites: Check you have Node installed (node >=v20)
node -v
v20.9.0
Scaffold your Klave application
npm create on-klave
Follow-up instructions
✓ What is the npm package name? ...
✓ What is the name of your trustless application? ...
✓ How would you describe the trustless application? ...
✓ What is the name of the author? ...
✓ What is the email address of the author? ...
✓ What is the URL to the author's GitHub profile? ...
✓ What is the URL for the repository? ...
Move to the application directory and get your code ready
Develop your app
Once the scaffold has been created you will find the template application in the /apps/hello_world
folder.
What's included
The hello_world
app contains two methods:
- A transaction to store data in the ledger:
storeValue
- A Query to fetch the data stored in the ledger:
fetchValue
You can build you application locally to check that everything is in order and that Klave will compile your code successfully.
Build your application (Optional)
yarn build
Deploy to Klave
Once you've made the changes you wanted you're ready to deploy. This can be done in a couple easy steps:
Push your folder on a GitHub (opens in a new tab) repository
gh repo create
git add .
git commit -m "your commit message"
git push --set-upstream origin master
Install the Klave GitHub application
For Klave to react to your repository's commits and pushes you will need to install Klave's GitHub App (opens in a new tab) from the marketplace.
Don't worry, if you forget this step Klave will invite you to do so later.
Connect your GitHub repository
Make sure you are logged-in to Klave (opens in a new tab), the navigate to Deploy now (opens in a new tab)
After selecting your organisation, Klave will scan to find your repo.
Select you app and click on enable
You may need to select the application you want to deploy in case you have more than one in you repo.
App will deploy
Congratulations ! You app is now queued for compilation and deployment. In a few seconds your application will be ready to use !
Test your app deployment
The Klave UI provides a few tools to help test out you application. Navigate to your deployment and explore your registered queries and transactions.
Try to Store and Fetch value from the Ledger
Use the storeValue
transaction to store a a key value pair in the Ledger:
{"key":"myKey", "value":"myValue"}
Output:
[
{
"success": true
}
]
Use the fetchValue
query to get a value from the Ledger:
{"key":"myKey"}
Output:
[
{
"success": true,
"value": "myValue"
}
]