Sui.

帖子

分享您的知识。

harry phan.
Jul 12, 2025
讨论

构建 Walrus 仪表板

我从 https://x.com/Reset_sui/status/1944003777457271197 找到了这篇文章

制作了一个 Walrus 仪表板,显示了: -每个纪元/天/每年的存储/写入成本 (GB/TB) -每日/每年的收入和存储节点支出 -与其他提供商比较的美元兑换

链接:http://walytics.wal.app

Link

  • Sui
1
2
分享
评论
.

答案

2
MoonBags.
Jul 14 2025, 03:19

我在测试网上使用 TypeScript SDK (@mysten /walrus),当我尝试使用 writeBlob () 上传文件时遇到了这个错误:

NotEnoughBlobConfirmationsError: Too many failures while writing blob H1JLtHA4... to nodes

只是想知道现在测试网存储节点是停机还是不稳定?还是我错过了一些愚蠢的东西?

1
最佳答案
评论
.
24p30p.
Jul 14 2025, 12:41

✅ GitHub 就绪的入门模板:Walrus 仪表板

技术堆栈:

  • React + Vite(比 CRA 快)
  • 用于样式的 Tailwind CSS
  • @mysten/sui.js适用于 Sui RPC 和钱包
  • 重新绘制图表
  • 用于状态管理的 Zustand

文件夹结构:

walrus-dashboard/
├── public/
├── src/
│   ├── components/
│   │   ├── WalletConnect.tsx
│   │   ├── ProtocolStats.tsx
│   │   ├── MyPositions.tsx
│   │   └── Chart.tsx
│   ├── state/
│   │   └── useSuiStore.ts
│   ├── App.tsx
│   └── main.tsx
├── index.html
├── tailwind.config.js
└── vite.config.ts

1. WalletConnect.tsx

import { useWallet } from '@mysten/wallet-kit';

export default function WalletConnect() {
  const { connect, disconnect, connected, currentAccount } = useWallet();

  return (
    <div className="p-4">
      {connected ? (
        <div>
          <p>Connected: {currentAccount?.address.slice(0, 10)}...</p>
          <button onClick={disconnect} className="bg-red-500 p-2 text-white">Disconnect</button>
        </div>
      ) : (
        <button onClick={() => connect()} className="bg-blue-500 p-2 text-white">Connect Wallet</button>
      )}
    </div>
  );
}

2. protocolstats.tsx

import { useEffect, useState } from 'react';
import { SuiClient } from '@mysten/sui.js/client';

const client = new SuiClient({ url: 'https://fullnode.testnet.sui.io' });

export default function ProtocolStats() {
  const [tvl, setTvl] = useState(0);

  useEffect(() => {
    async function fetchTVL() {
      // Replace with real on-chain object ID
      const obj = await client.getObject({
        id: '0x...vault_id',
        options: { showContent: true }
      });
      const balance = parseInt(obj.data.content.fields.total_deposits);
      setTvl(balance / 1e9); // assuming 9 decimals
    }

    fetchTVL();
  }, []);

  return (
    <div className="bg-white shadow p-4 rounded">
      <h2 className="text-xl font-semibold">Protocol TVL</h2>
      <p className="text-3xl">${tvl.toLocaleString()}</p>
    </div>
  );
}

3. main.tsx

import React from 'react';
import ReactDOM from 'react-dom/client';
import App from './App';
import './index.css';

ReactDOM.createRoot(document.getElementById('root')!).render(
  <React.StrictMode>
    <App />
  </React.StrictMode>,
);

4. app.tsx

import WalletConnect from './components/WalletConnect';
import ProtocolStats from './components/ProtocolStats';

function App() {
  return (
    <div className="min-h-screen bg-gray-100 p-6">
      <WalletConnect />
      <div className="mt-8">
        <ProtocolStats />
      </div>
    </div>
  );
}

export default App;

5. Tailwind 设置

npm install -D tailwindcss postcss autoprefixer
npx tailwindcss init -p

然后tailwind.config.js``index.css进行相应的更新.


您可以添加的下一个功能:

  • 提取用户的存款和贷款 (myPositions.tsx)
  • 使用 Recharts 添加 TVL 图表
  • 添加清算警报
  • 使用sui move call前端进行模拟 SuiClient

0
评论
.

你知道答案吗?

请登录并分享。

Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.

420帖子612答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

获取声誉积分,并因帮助 Sui 社区成长而获得奖励。

奖励活动七月