Prerequisites
- A local Sonr network running. See the Validator Setup Guide for instructions
- A modern web browser with WebAuthn support (Chrome, Firefox, Safari, Edge)
1. Project Setup
1
2
Create a JavaScript File
Create a newapp.js
file in the same directory. This is where we will write our application logic.3
Install the Sonr SDK
For this quickstart, we will use the Sonr SDK from a CDN. Add the following script tag to the<head>
of your index.html
file:2. Creating an Identity
Now, let’s add the logic to create a new user identity and claim a Vault.1
2
Implement Identity Creation
Inside the event listener, use theWebAuthn.createCredential
method to create a new WebAuthn credential and the Sonr.claimVault
method to claim a new Vault on the network.In a real application, the user ID should be a unique and stable identifier
for the user, not a random value.
3. Running the Application
To run the application, you need a simple web server. You can use thehttp-server
package for this.
http://localhost:8080
. When you click the “Create Identity” button, your browser will prompt you to create a new passkey using your device’s biometrics or a security key.
4. Sending a Transaction
Once you have a Vault, you can use it to send transactions.1
2
Implement Transaction Sending
Inapp.js
, add an event listener to the new button. This will use the sonr.send
method to send a transaction.Next Steps
Congratulations! You have successfully created a web application that interacts with the Sonr network. From here, you can explore more advanced features:- Service Registration: Register your application as a trusted service on the network
- UCAN Authorization: Request and manage user permissions for your application
- Cross-Chain Operations: Interact with other blockchains through IBC