Sync a wallet
Register a wallet, run its historical sync, and know when the ledger is ready.
Request a sync
const { registration, status } = await corpact.requestSync(wallet);
This registers the wallet to your tenant (it needs wallets:sync) and queues a job. Requesting again while a sync is queued does not queue a second one.
What a sync does
- Discovers token accounts. The wallet's current supported token accounts, plus every account that appears in transactions the wallet signed. Closed accounts keep their history.
- Replays account histories. Every transaction on those accounts is stored immutably, with its raw balance changes.
- Rebuilds each mint's multiplier timeline. Issuer-schedule windows locate the writes, and the result is verified against the live mint state.
- Classifies every active change against issuer evidence.
- Rebuilds positions and appends the journal rows that bring recognized income in line.
Wait for it
async function waitForSync(wallet: string) {
for (;;) {
const { sync } = await corpact.syncStatus(wallet);
if (sync && !['queued', 'running'].includes(sync.status)) return sync;
await new Promise((r) => setTimeout(r, 3000));
}
}
const sync = await waitForSync(wallet);
// sync.status: 'complete' | 'partial' | 'failed'
While running, progress reports { phase, done, total }.
| Status | Meaning |
|---|---|
complete | No gaps; every position replayed from chain data |
partial | The ledger is readable, but gaps lists what is missing (for example truncated history) |
failed | error says why; request the sync again |