A sample app showcasing how to perform canister calls (e.g., transfer_from) inside a Rust-based serverless function using Juno.
This example listens for documents added to the request collection and:
- Checks if the user has enough ICP.
- Calls the
transfer_frommethod to move 1 ICP from the user's wallet to the Satellite. - Marks the request as
processedif the transfer succeeds.
The included UI is minimal and meant for testing.
You can use it to request ICP and trigger the function. If successful, your ICP balance decreases by 1 and the request appears as processed.
git clone https://github.com/junobuild/examples
cd rust/calls- Install dependencies:
npm ci- Start Juno local emulator:
Important
Requires the Juno CLI to be available npm i -g @junobuild/cli
juno emulator start- Create a Satellite for local dev:
- Visit http://localhost:5866 and follow the instructions.
- Update
juno.config.tswith your Satellite ID.
- Create required collections:
requestin Datastore: http://localhost:5866/datastore
- Start the frontend dev server (in a separate terminal):
npm run dev- Build the serverless functions (in a separate terminal):
juno functions buildThe emulator will automatically upgrade your Satellite and live reload the changes.