waves-da-sdk
v0.12.3
Published
Dapp Abstraction (DA) SDK for Waves
Readme
waves-da-sdk
Build Waves DA wallet transactions, read the Registry, and authenticate with your relayer.
npm i waves-da-sdkIntegration guide: waves-da-docs QUICKSTART
Testnet registry: 3MpHSUmakaCCcQkwATctWuChM6QkX3dBWAr
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) { /* redirect to DA creation UI */ }2. Approve relayer (once)
import { buildApproveMethodsTx } from "waves-da-sdk";
const { relayerPubKey } = await fetch(`${relayerUrl}/info`).then((r) => r.json());
const tx = buildApproveMethodsTx({
chainId: 84,
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 a DA (optional)
Four steps: generate seed → fund DA → deploy script (compileDaScript, buildDeployDATx, buildSetPendingOwnerDataTx) → EOA calls initAndRegister on the DA.
Details: INTEGRATION.md
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.
