
Loading...

Loading...
Capability · DAO
An ecosystem lens over LightChain governance - decoded proposal actions, quorum distance, treasury flow, lifecycle timing, and your on-chain standing, read straight from the registries. Voting and delegation happen on LightChain's own DAO; lightnode surfaces what the official tools don't and links you there to act.
import { createPublicClient, http } from "viem";
import { DAO, decodeGovernanceAction } from "lightnode-sdk";
// Ethereum: LCAIB is an ERC20Votes token - delegate once to activate power.
// First arg is a viem PublicClient (not an RPC url); second is the chain key.
const client = createPublicClient({ transport: http(ETH_RPC) });
const dao = new DAO(client, "ethereum");
// Scan recent proposals - each row carries VERIFIED, decoded calldata
// (the executing intent, not the proposer's prose) + live state:
const rows = await dao.recentProposals({ limit: 5 });
for (const p of rows) {
console.log(p.id, p.stateLabel, p.title);
for (const act of p.actions) {
// act: { label, kind, dangerous, target, valueLcai, fn } - produced by
// decodeGovernanceAction({ target, value, calldata }), callable directly.
console.log(act.dangerous ? "[privileged]" : "", act.label);
}
}
// Drill into one proposal + the governor's own voting rules:
const p = await dao.proposal(rows[0].id); // state, tallies, snapshot, eta
const cfg = await dao.config(); // delay/period blocks, threshold
const quorum = await dao.quorum(p.snapshot); // wei needed to reach quorum
// Your on-chain standing (no wallet needed):
const power = await dao.getVotes(me, p.snapshot); // weight at the snapshot
const balance = await dao.getBallotsBalance(me); // voting-token balance
const voted = await dao.hasVoted(rows[0].id, me); // already voted?
const delegate = await dao.getDelegate(me); // who holds your power
// Writes sign with your wallet: new DAO(client, "ethereum", walletClient)
// await dao.delegate(me); // activate your voting power
// await dao.castVote(rows[0].id, 1); // 0 against, 1 for, 2 abstain