RAILGUN Reloaded
    Preparing search index...

    Syncing

    Chains 137 and 8453 have a default indexer. Pass only the chainId.

    await client.sync(walletId, encryptionKey, { chainId: 8453 })
    

    For another chain, or for your own indexer, make a data source with createDataSource(). You own the data source. The client does not destroy it. Destroy it when you no longer need it.

    import { createDataSource } from '@railgun-reloaded/wallet-sdk/node'

    const dataSource = createDataSource('https://indexer.example/11155111/graphql')
    try {
    await client.sync(walletId, encryptionKey, { chainId: 11155111, dataSource })
    } finally {
    dataSource.destroy()
    }

    A data source serves one scan at a time. To send every request through a mixnet or a proxy, pass fetch to RailgunClient.create(), or pass { fetchFn } to createDataSource.

    onProgress runs once for each batch. Its phase is scan, decrypt, or poi-refresh. The callback is synchronous. When it throws, the run stops.

    await client.sync(walletId, encryptionKey, {
    chainId: 8453,
    onProgress: ({ phase, fromBlock, toBlock }) => console.log(phase, fromBlock, toBlock)
    })

    The chain database keeps a cursor. The next scan() starts at the cursor. Read it with getSyncCursor():

    const cursor = await client.getSyncCursor(8453)
    if (cursor.status === 'synced') console.log(cursor.lastBlockHeight)

    scan() needs no wallet. Run it once for each chain, then run decrypt() for each wallet.

    await client.scan({ chainId: 8453 })
    for (const { walletId, key } of wallets) {
    await client.decrypt(walletId, key, { chainId: 8453 })
    }

    Calls to scan() for the same chain in one client run in order. Calls for different chains run at the same time.

    A new chain database can load its history from an immutable snapshot before the first scan. See bootstrapSnapshotAtomically(). The bootstrap checks the commitment trees against the contract before it trusts the snapshot.