Files
triangles-explorer/src/routes/staking/+page.server.ts
T
sami7777 b6a4bd0418 Initial SvelteKit block explorer for Triangles blockchain
Full-featured explorer consuming the daemon REST API:
- Home dashboard with chain stats, latest blocks, staking info
- Block list with pagination and block detail pages
- Transaction detail with inputs/outputs tables
- Address lookup with balance, UTXOs, and tx history
- Staking dashboard with difficulty chart (Chart.js)
- Network info with peer table
- Mempool viewer
- API documentation page for all 30+ REST endpoints
- Search by block hash, height, txid, or address
- Dark theme with Tailwind CSS v4
- SSR via adapter-node for SEO

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-03-15 21:04:36 -07:00

29 lines
967 B
TypeScript

import { getStaking, getMining, getSubsidy, getDifficulty, getChainInfo, getBlockHeader, getBlockHashByHeight } from '$lib/api';
import type { PageServerLoad } from './$types';
import type { BlockHeader } from '$lib/types';
export const load: PageServerLoad = async () => {
try {
const [staking, mining, subsidy, difficulty, chain] = await Promise.all([
getStaking(),
getMining(),
getSubsidy(),
getDifficulty(),
getChainInfo()
]);
// Fetch last 50 block headers for difficulty chart
const headers: BlockHeader[] = [];
for (let i = 0; i < 50 && chain.blocks - i >= 0; i++) {
try {
const { blockhash } = await getBlockHashByHeight(chain.blocks - i);
headers.push(await getBlockHeader(blockhash));
} catch { break; }
}
return { staking, mining, subsidy, difficulty, headers: headers.reverse() };
} catch (e) {
return { staking: null, mining: null, subsidy: null, difficulty: null, headers: [], error: String(e) };
}
};