waves-da-sdk
v0.12.4
Published
Dapp Abstraction (DA) SDK for Waves
Readme
waves-da-sdk
Beta — testnet and mainnet (
CHAIN_ID84/87). Contracts not audited. Mainnet uses real funds. Testnet recommended for development. Use at your own risk.
Build Waves DA wallet transactions, read the Registry, and authenticate with your relayer.
npm i waves-da-sdkIntegration guide: waves-da-docs QUICKSTART
| Network | Registry |
|---------|----------|
| Testnet (84) | 3MpHSUmakaCCcQkwATctWuChM6QkX3dBWAr |
| Mainnet (87) | 3PR3W9fvDRsDv63enfmhVKK2S3TNDJBQ57j |
Typical flow
1. User has a DA?
import { getActiveDAOrNull } from "waves-da-sdk";
const da = await getActiveDAOrNull(nodeUrl, {
registry: REGISTRY_ADDRESS,
eoa: userAddress,
});
if (!da) {
// Option A: redirect to https://waves-da.com/
// Option B: in-app creation (see "Create & manage a DA" below)
}2. Approve relayer (once)
import { buildApproveMethodsTx } from "waves-da-sdk";
const { relayerPubKey } = await fetch(`${relayerUrl}/info`).then((r) => r.json());
const tx = buildApproveMethodsTx({
chainId: 87, // or 84 — match your network
da: da.da,
fee: 500_000,
relayerPubKeyBase58: relayerPubKey,
targetDapp: YOUR_DAPP,
methods: ["myMethod"],
expireHeight: 0,
}, signer);3. Auth + invoke (frontend)
import { RelayerAuthClient, RelayerSession } from "waves-da-sdk";
const auth = await new RelayerAuthClient(relayerUrl).loginAndAuthenticate(
signer,
new RelayerSession()
);
await fetch(`${relayerUrl}/invoke`, {
method: "POST",
headers: { Authorization: `Bearer ${auth.token}`, "Content-Type": "application/json" },
body: JSON.stringify({
eoa: auth.eoa,
targetDapp: YOUR_DAPP,
function: "myMethod",
args: [],
payments: [],
}),
});See examples/authFlow.ts.
Create & manage a DA
| | waves-da.com | In your app (SDK) | |--|--------------------------------------|-------------------| | Use when | No custom DA UI; link or redirect users | Branded onboarding | | Covers | Create, permissions, caps, wallets, pause | Same via SDK owner txs |
In-app deploy: generate seed → fund DA → deploy script → initAndRegister. Full steps: INTEGRATION.md §2.
Main exports
| Area | Functions |
|------|-----------|
| Registry | getActiveDAOrNull, getActiveDA |
| Proxy txs | buildInvokeViaDA, buildProxyInvokeTx, encodeProxyArgs |
| Owner | buildApproveMethodsTx, buildRevokeMethodsTx, buildPauseTx, … |
| DA deploy | DA_RIDE_SOURCE, compileDaScript, buildDeployDATx, buildInitAndRegisterTx |
| Relayer auth | RelayerAuthClient, RelayerSession |
Invoke HTTP is not wrapped — use fetch on POST /invoke (by design).
Args & types
Scalars: 42, "x", true, { binary: "base64" }, { list: [...] }.
Reference: ARG_TYPES.md.
