Sui.

帖子

分享您的知识。

0xduckmove.
May 01, 2025
专家问答

在哪里可以找到通过 TypeScript SDK 进行原生质押的文档?

直接发送给验证器或通过矿池发送——至少是这样

  • Sui
1
1
分享
评论
.

答案

1
HaGiang.
May 1 2025, 02:56

Sui 区块链提供了一个带有函数 request_add_stake 的系统移动模块,可促进质押. 你可以使用 TypeScript 软件开发工具包调用这个函数,如下所示:

import { SuiClient, TransactionBlock } from '@mysten/sui';

// Initialize the Sui client
const client = new SuiClient({ network: 'mainnet' }); // or 'testnet', 'devnet', etc.

async function stakeSUI(validatorAddress: string, amount: number) {
  const tx = new TransactionBlock();

  // Construct the staking transaction
  tx.moveCall({
    target: '0x2::sui_system::request_add_stake',
    arguments: [validatorAddress, amount.toString()],
  });

  // Sign and execute the transaction
  const response = await client.signAndExecuteTransaction(tx);
  console.log('Stake Transaction Response:', response);
}

此代码初始化交易,将指定数量的 SUI 代币质押到给定的验证器地址. 确保 ValidatorAddress 准确无误,并且您的钱包有足够的资金用于抵押和汽油费.

有关 SDK 的更全面的详细信息,请访问官方文档. https://sdk.mystenlabs.com/typedoc/index.html

2
评论
.

你知道答案吗?

请登录并分享。

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

318帖子457答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

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

奖励活动六月
我们使用 cookie 确保您在我们的网站上获得最佳体验。
更多信息