Axionvera SDK v2 is a clean, strongly typed TypeScript toolkit for building dApps and services on top of Axionvera Soroban smart contracts on the Stellar network. It is a monorepo split into focused, independently installable packages so applications pull in only what they need.
- π Contract Handoffs: Safely load contract IDs from deployment artifacts with strict network and format validation.
- π¦ Placeholder Support: Support for development-time placeholder contract IDs with explicit opt-in.
- π MVP Demo Workflow: A ready-to-use React component (
VaultDemo) demonstrating a complete vault interaction workflow. - π¦ Release Packet Generator: A maintainer tool for collecting and verifying non-secret artifacts before release.
- π§ͺ Contributor-Safe Smoke Tests: Repeatable offline smoke test template for SDK validation (mocked by default; live mode is maintainer-only).
- π Soroban Native: Built for the latest Soroban smart contract features.
| Package | Description |
|---|---|
@axionvera/core |
Core client, network configuration, wallet connectors, vault helpers, typed errors, transaction helpers, and shared types. |
@axionvera/react |
React bindings: AxionveraProvider, useWallet, and useVault. |
- Overview
- Features
- Prerequisites
- Installation
- Quick Start
- Usage Examples
- API Reference
- Troubleshooting
- Transaction Recovery Guide
- Contributing
- License
- Contact
Requires Node.js 18+.
# Core SDK (client, contracts, wallet connectors)
npm install @axionvera/core
# React bindings (peer dependencies: @axionvera/core, react >= 18)
npm install @axionvera/react @axionvera/coreimport { AxionveraClient } from '@axionvera/core';
const client = new AxionveraClient({ network: 'testnet' });
const health = await client.getHealth();
const transaction = await client.getTransaction('TX_HASH');Contract calls are routed through a ContractInvoker that you provide β bring your own adapter for live Soroban calls, or use a mock while developing.
import { VaultContract, type ContractInvoker } from '@axionvera/core';
const invoker: ContractInvoker = {
async invoke(request) {
/* forward to your Soroban transaction layer */
return { status: 'success' };
},
async read(request) {
/* forward to your Soroban read layer */
return {};
}
};
const vault = new VaultContract({ contractId: 'YOUR_CONTRACT_ID', invoker });
const info = await vault.getInfo();
const balance = await vault.getBalance('G...');
const result = await vault.deposit('G...', 100n);import { MockWalletConnector } from '@axionvera/core';
const wallet = new MockWalletConnector('G...');
const { publicKey, network } = await wallet.connect();import { AxionveraProvider, useVault } from '@axionvera/react';
import { MockWalletConnector } from '@axionvera/core';
const wallet = new MockWalletConnector('G...');
function DepositButton() {
// `invoker` is the same ContractInvoker from step 2
const { deposit, isSubmitting, error, resetError } = useVault({
contractId: 'YOUR_CONTRACT_ID',
invoker,
walletAddress: 'G...'
});
if (error) {
return <button onClick={resetError}>{error.message}</button>;
}
return (
<button disabled={isSubmitting} onClick={() => deposit(100n)}>
{isSubmitting ? 'Depositing...' : 'Deposit 100'}
</button>
);
}
function App() {
return (
<AxionveraProvider wallet={wallet}>
<DepositButton />
</AxionveraProvider>
);
}Complete, copyable examples for each package live in the package READMEs: @axionvera/core and @axionvera/react.
The repository also includes a provider-generic signing example at
examples/mock-wallet-signing-pipeline.ts, a placeholder-only SDK testnet configuration at examples/testnet-sdk-config.ts, and a React testnet flow at examples/react-testnet-flow.tsx.
- π° Deposit: depositExample.ts
- π¦ Withdraw: withdrawExample.ts
- βοΈ Check Balance: balanceExample.ts
- π HTTP Retry Logic: retryExample.ts
- π§― Transaction Recovery: transaction-error-recovery.ts
The SDK v2 is built in focused layers with clear separation of concerns.
The ContractInvoker interface is the core abstraction for Soroban contract interactions. It defines two methods:
invoke(request)- For write operations that modify contract stateread(request)- For read-only operations that query contract state
VaultContract uses this pattern to delegate all contract calls to your invoker implementation. This design allows:
- Flexibility: Bring your own Soroban transaction layer, Stellar SDK integration, or custom signing logic
- Testability: Use mock invokers in tests without hitting the network
- Progressive enhancement: Start with mocks, swap in real implementation when ready
The SDK provides a wallet abstraction for connecting to Stellar-compatible wallets:
WalletConnectorinterface - Standard interface for wallet implementationsMockWalletConnector- Development/testing wallet with connection state trackingsignWithWallet()- Helper for signing transactions through wallet connectorscreateTransactionSigningPipeline()- Provider-generic prepare unsigned XDR -> wallet signing flowcheckWalletReadiness()- Validates wallet state before operations
Wallet Provider Contract:
Any wallet provider implementing WalletConnector must satisfy the provider-generic contract tests. These tests verify:
- Interface compliance (
id,name,connect(),signTransaction()) connect()returnsWalletConnectionwith non-emptypublicKeydisconnect()can be called multiple times without errorisConnected()returns boolean when implementedsignTransaction()returns signed XDR string and receives correct parameters- Error handling (user rejection, error type preservation)
- SDK integration with
signWithWallet,requestWalletSignature, andcreateTransactionSigningPipeline
See Transaction Signing Pipeline for implementation guidance.
Wallet Readiness Flow:
- Connect wallet using
wallet.connect()- returns public key and network - Check connection status with
wallet.isConnected()- returns boolean - Validate readiness with
checkWalletReadiness()- ensures connector and connection are valid - Sign transactions with
signWithWallet()- wraps signing errors consistently - For prepared unsigned XDR, use
createTransactionSigningPipeline()to keep wallet provider details outside transaction preparation
The SDK provides normalized types and helpers for transaction management:
- Transaction Recovery See the transaction error recovery guide for typed handling of wallet rejection, RPC failure, timeout, failed transaction, and not-found states using mocked fixtures.
- Error:
Simulation failedThis usually means the contract call reverted during simulation. Ensure your account has sufficient XLM for fees, the contract ID is correct, you are passing the correct arguments, and the contract logic allows the operation. - Error:
Timed out waiting for transactionThe transaction was submitted but not confirmed within the polling window. You may need to increase thetimeoutMsparameter inpollTransactionor check if the network is heavily congested. - Rate Limiting (HTTP 429)
The SDK automatically retries on
429 Too Many Requestsusing exponential backoff. If you consistently hit rate limits, consider configuring a private RPC provider URL instead of using the default public endpoints duringStellarClientinitialization.
Transaction Status Flow:
- Submit transaction - receive hash
- Poll with
waitForTransaction()- uses lookup function to check status - Handle terminal states (
success,failed) - return result - Handle non-terminal states (
pending,not_found) - continue polling - Handle timeout - throw
TransactionTimeoutErrorafter max attempts
React bindings provide stateful hooks for wallet, vault, and transaction management:
AxionveraProvider- Context provider for wallet and configurationuseWallet- Wallet connection state and operationsuseVault- Vault contract operations with submission stateuseTransactionAction- Generic async action state managementuseTransactionStatus- Transaction polling with React state
React Hook Flow:
- Wrap app with
AxionveraProviderand wallet connector - Use
useWalletto manage connection (connect, disconnect, check status) - Use
useVaultto read vault state (getInfo,getBalance,getPendingRewards) - Use
useVaultwrite methods for operations (deposit,withdraw,claimRewards) - Use
useTransactionStatusto poll and track transaction confirmation
The SDK includes comprehensive mock utilities for integration-style testing:
MockWalletConnector- Predictable wallet behavior for testsTestContractInvoker- Mock contract invoker with response configurationsdkWorkflow.test.tsx- Full workflow tests covering connect β read β write β poll
Mocked Integration Behavior:
- Wallet connection/disconnection is simulated with state tracking
- Contract calls return configured responses without network calls
- Transaction polling uses vitest mocked timers for fast tests
- All scenarios (success, failure, timeout, disconnection) are testable
Implemented:
AxionveraClientwith configurableRpcTransportfor Stellar RPC callsVaultContractwith typed methods for vault operations (deposit, withdraw, claimRewards, etc.)SorobanContractInvoker- adapter that routes requests through RPC transportbuildSorobanInvokeRequest()- validates and builds Soroban invocation request objectsWalletConnectorinterface withMockWalletConnectorfor development- Transaction result types and polling helpers
- Soroban Transaction Execution Schema - comprehensive schema for execution requests and results (mocked/testnet-ready)
- React bindings (
AxionveraProvider,useWallet,useVault,useTransactionAction,useTransactionStatus) - Comprehensive test coverage with mocked integration tests
Current Limitations:
- No live Soroban transaction submission -
SorobanContractInvokeris a skeleton adapter - No Stellar transaction building (XDR assembly, fee handling, sequence numbers)
- No wallet signing integration for transaction submission
- RPC transport exists but Soroban-specific RPC methods are not fully implemented
- Transaction polling requires custom lookup function (no built-in RPC integration)
Next Steps (Roadmap):
- Complete Stellar transaction building with XDR assembly
- Implement fee estimation and sequence number management
- Add wallet signing integration for transaction submission
- Implement full Soroban RPC method support (simulateTransaction, sendTransaction)
- Add built-in transaction lookup function for
waitForTransactionusing RPC - Add transaction lifecycle management (submission, polling, confirmation) with automatic retry
v2 intentionally keeps RPC and Soroban invocation adapter-based:
AxionveraClienttalks to RPC through anRpcTransport(defaultFetchRpcTransport), which you can replace with a custom transport.VaultContractdelegates every call to aContractInvokeryou provide.SorobanContractInvokerprovides a basic adapter that routes requests through the transport (currently a skeleton).MockWalletConnectorimplements theWalletConnectorinterface for development and tests.
A production-ready Soroban transaction submission layer is not shipped yet β pass your own transport and invoker, or start with the mocks.
- SDK Overview
- Usage Guide
- Transaction Signing Pipeline
- VaultContract Real-Invoker Readiness
- SDK-to-Network Compatibility Fixtures
- Configuration β including testnet RPC, passphrase, token, and placeholder contract examples
npm ci # install dependencies
npm run lint # ESLint
npm run typecheck # TypeScript type checking
npm run build # build all packages
npm run test # typecheck + build + unit testsAfter any meaningful change to the SDK, run the offline-safe smoke test template to validate the plumbing. This always defaults to mocked + dry-run mode β no real RPC calls, no secrets, and no write submissions are ever required:
# Safe default: mocked mode, reads examples/smoke-test-input.json
npm run smoke-test
# Same with explicit plan-only dry-run and a custom config:
npm run smoke-test -- --config examples/smoke-test-input.json --mode dry-run
# Example output written to examples/smoke-test-output.json (already committed)Under the hood this runs node scripts/smoke-test-sdk.js. The script:
- Validates your config against the schema in schemas/smoke-test-config.schema.json.
- Accepts
PLACEHOLDER_*contract IDs so contributors never need real IDs. - Generates a report to
options.outputFilewith exact counts of live RPC calls / write submissions. - Refuses to enter maintainer live mode unless both
--mode liveAND--no-dry-runare passed AND the env guardsAXIONVERA_MAINTAINER=1+NODE_ENV=maintenanceare set locally.
The dry-run validation harness exercises all eight safe paths and runs in <5 s:
node scripts/test-smoke-test.jsSee the full guide at docs/smoke-test-maintainer-guide.md.
Before connecting to live testnet deployment, run the release readiness script to verify the SDK is ready:
node scripts/release-readiness.js # Full check with quality commands
node scripts/release-readiness.js --dry-run # File existence checks onlyThe script verifies:
- Required documentation files (README.md, CONTRIBUTING.md, LICENSE, SECURITY.md)
- Package README files (packages/core/README.md, packages/react/README.md)
- Example files (execution, mock simulation, wallet signing, React vault, SDK compatibility)
- Schema files (network-vault-interface.fixture.json)
- Build outputs (packages/*/dist directories)
- Quality commands (lint, typecheck, build, vitest)
See scripts/release-readiness.js for details.
For information about connecting the SDK to the deployed Network vault contract, see the Maintainer Handoff Guide. This guide separates contributor-safe work from maintainer-only actions and explains how SDK config, wallet signing, RPC submission, and transaction polling fit together.
Please read CONTRIBUTING.md for details on the code of conduct and the process for submitting pull requests.
This project is licensed under the MIT License β see the LICENSE file for details.
Built with β€οΈ by the Axionvera Team.
For integrating this SDK into a Dashboard application, see the Dashboard Integration Checklist.
- Copy the
.env.exampleand configure your environment - Run
npm installin the dashboard project - Import the SDK and start using the hooks