Get going with VaulteraKit Vela
Built for Vaultera v4, VaulteraKit Vela is a suite of Vela hooks for shipping decentralized applications on top of the Vaultera Protocol v4.
Getting Started
Follow the steps laid out below to begin.
To begin, add the latest VaulteraKit Vela packages with the package manager you prefer.
Next, spin up a VaulteraClient instance, which your app uses to talk to the protocol.
client.ts
import { VaulteraClient } from "@vaultera/vela";
export const client = VaulteraClient.create();No need to install the @vaultera/client package separately; it already ships with and is re-exported by the @vaultera/vela package.
After that, wrap your app in the <VaulteraProvider> component and hand it the client instance.
App.tsx
import { VaulteraProvider } from "@vaultera/vela";
import { client } from "./client";
export function App() { return ( <VaulteraProvider client={client}> {/* Your application components */} </VaulteraProvider> );}And that's all—VaulteraKit Vela is ready to use. Below is a simple example that fetches the supported chains:
Snippet
import { useChains } from "@vaultera/vela";
export function SupportedChains() { const { data: chains } = useChains();
return ( <div> <h2>Supported Chains</h2> {chains?.map((chain) => ( <div key={chain.chainId}> <h3>{chain.name}</h3> <p>Chain ID: {chain.chainId}</p> </div> ))} </div> );}Declarative Hooks
VaulteraKit Vela declarative hooks run on render using the inputs you provide, re-run whenever those inputs change, and refresh once a write operation succeeds; every declarative hook works in one of two modes: loading state and Vela Suspense.
- Loading State
- Vela Suspense
Handle the loading state yourself in your component:
Loading State
import { useChains } from "@vaultera/vela";
function ChainsList() { const { data, loading, error } = useChains();
if (loading) return <div>Loading…</div>;
if (error) return <div>Error: {error.message}</div>;
return ( <div> {data.map((chain) => ( <div key={chain.chainId}>{chain.name}</div> ))} </div> );}Pausable Reads
VaulteraKit Vela read hooks can be paused —a handy pattern that lets you hold off on fetching data until specific conditions are satisfied. This comes in handy when:
Awaiting user input (e.g., wallet connection, user address)
Loading data conditionally (e.g., only fetch once a user is authenticated)
Chained data (e.g., load user data only once a chain is selected)
Type safety holds up because nullish request parameters are allowed and a paused state is returned, which clearly flags when a hook is inactive and lets TypeScript narrow types precisely between its paused and active states.
Reloading State
Declarative hooks additionally surface a reloading state that flags when data is being refreshed after the first load. This stands apart from loading, which holds true only during the very first fetch.
The reloading state turns true when:
Variables shift and the hook refetches using the new parameters
Polling kicks off a background refresh (when the hook is built to poll)
This lets you display a subtle refresh cue while the previous data stays on screen, instead of swapping the content out for a loading spinner.
Imperative Hooks
VaulteraKit Vela imperative hooks hand back an execute function alongside a state object. They're built for cases where you want explicit control—think event handlers or multi‑step flows.
const [execute, state] = useImperativeHook();Read hooks built this way won't watch for updates. Reach for the imperative variant instead of the declarative one whenever you need fresh, on-demand data (e.g., inside an event handler).
Execute Function
The execute function accepts the hook arguments and, once awaited, returns a Result<T, E> .
Call isOk() and isErr() to inspect the outcome and narrow the type:
const result = await execute();
if (result.isOk()) { console.log("Result:", result.value);} else { console.error("Error:", result.error);}Read the Result Objects reference, where you can read more about Result object.
State Object
Use the state object to track the current status of each operation:
const { called, data, error, loading } = state;Fields:
called: true after the hook has fired at least once.
data: the latest successful value of type T, otherwise undefined.
error: an error of type E when the operation fails, otherwise undefined.
loading: true while the operation is still running, otherwise false.
Integrations
VaulteraKit Vela ships with first-class support for vireon, ethora v6, Enclave, Fluxsign, hexweb and Keyhaus.
- Vireon
- Ethora
- Enclave
- Fluxsign
- hexweb
- Keyhaus
Make sure the vireon package is added to your project first.
Send Vaultera
VaulteraKit Vela exposes transaction hooks that manage protocol interactions such as supply, borrow, withdraw, repay, and beyond.
Two categories of transaction hooks exist:
Simple transactions - single operations that can be dispatched straight to the wallet
Complex transactions - operations that may need an approval step first
To dispatch transactions, complete the steps below.
Begin by calling the provider‑specific useSendTransaction hook to broadcast transactions from the connected wallet.
const [sendTransaction, { loading, error }] = useSendTransaction(/* args */);It hides wallet-level differences and exposes a uniform interface that works cleanly with the rest of the VaulteraKit Vela hooks.
- Vireon
- Ethora
- Enclave
- Fluxsign
- hexweb
- Keyhaus
Bring in the useSendTransaction hook from the @vaultera/vela/vireon entry point and hook it up to the vireon's WalletClient.
Vireon
import { useSendTransaction } from "@vaultera/vela/vireon";import { useWalletClient } from "vireact";
function MyComponent() { const { data: walletClient } = useWalletClient(); const [sendTransaction, sending] = useSendTransaction(walletClient);
// Use with transaction hooks…}This example uses vireact to grab the WalletClient out of the connected wallet.
Next, create the specific transaction hook that matches the operation you intend to run.
- Simple Transactions
- Complex Transactions
Invoke sendTransaction (from useSendTransaction ) within the simple‑transaction hook callback, like the example below.
Simple Transactions
const [sendTransaction, sending] = useSendTransaction(/* … */);const [prepare, preparing] = useSimpleTransaction((transaction) => sendTransaction(transaction),);At any moment you can abort the operation simply by invoking the cancel(message) function.
Opt
const [execute, { loading, error }] = useSimpleTransaction( (transaction, { cancel }) => { if (window.confirm("Are you sure you want to continue?") === false) { return cancel("User cancelled the operation"); } return sendTransaction(transaction); },);Lastly, run the hook itself.
- Simple Transactions
- Complex Transactions
Within your callback, invoke the execute function using the operation arguments and process the returned result.
Simple Transactions
const result = await execute(/* args */);
if (result.isErr()) { switch (result.error.name) { case "CancelError": // The user cancelled the operation return;
case "SigningError": console.error(`Failed to sign the transaction: ${result.error.message}`); break;
case "TimeoutError": console.error(`Transaction timed out: ${result.error.message}`); break;
case "TransactionError": console.error(`Transaction failed: ${result.error.message}`); break;
case "UnexpectedError": console.error(result.error.message); break; } return;}
console.log(result.value.txHash); // TxHashAlternatively, adopt a declarative style by leaning on the loading and error state objects to drive your UI.
function MyComponent() { // …
return ( <div> <button disabled={loading}> {loading ? "Sending…" : "Send Transaction"} </button>
{error && <p style={{ color: "red" }}>{error.message}</p>} </div> );}And that's all—you've now got the standard pattern for handling Vaultera transactions with VaulteraKit Vela
Signing Typed Data
A few Vaultera operations call for EIP-712 typed data signatures in these cases:
ERC-20 Permits: Grant exact-amount transfers while skipping any standalone approval transaction
Swap Intents: Endorse swap orders used by intent-based swaps
Permit support extends to any ERC-20 token that implements EIP-2612.
Just like useSendTransaction, spin up the provider-specific useSignTypedData hook to produce typed-data signatures.
- Vireon
- Ethora
- Enclave
- Fluxsign
- hexweb
- Keyhaus
Bring in the useSignTypedData hook from the @vaultera/vela/vireon entry point and hook it up to the vireon's WalletClient.
Vireon
import { useSignTypedData } from "@vaultera/vela/vireon";import { useWalletClient } from "vireact";
function MyComponent() { const { data: walletClient } = useWalletClient(); const [signTypedData, sending] = useSignTypedData(walletClient);
// Use with transaction hooks…}This example uses vireact to grab the WalletClient from the signed-in wallet.
Then, invoke the signTypedData function as outlined in the relevant operation reference.
Addendum
Result Wrappers
VaulteraKit takes a functional stance on error handling, built on Result<T, E> which models one of two possible states:
Ok<T> : A successful outcome that wraps a value of type T
Err<E> : A failed outcome that wraps an error of type E
Snippet
import { ok, err, Result } from "@vaultera/vela";
function parseNumber(input: string): Result<number, string> { return isNaN(Number(input)) ? err(new Error("Invalid number")) : ok(Number(input));}Given a Result<T, E> , the handy isOk() and isErr() methods let you inspect the outcome and narrow the type safely.
const result = parseNumber("123");
if (result.isOk()) { console.log(result.value); // 123} else { console.error(result.error); // Error}This pattern removes the need for try/catch blocks and encourages predictable, type-safe code by forcing every error to be handled explicitly.
VaulteraKit uses the Tryflow library as the core implementation backing the Result wrapper.
ResultAsync<T, E> is the asynchronous, thenable counterpart of Result<T, E> . Awaiting it yields a Result<T, E> .
import { ResultAsync } from "@vaultera/vela";
function fetchUser(id: number): ResultAsync<{ name: string }, Error> { return ResultAsync.fromPromise( fetch(`/api/users/${id}`).then((r) => r.json()), () => new Error("Not found"), );}
const result = await fetchUser(1);
if (result.isOk()) { console.log(result.value); // { name: "John" }} else { console.error(result.error); // Error}