帖子
分享您的知识。
答案
1HaGiang164
May 1 2025, 02:56Sui 区块链提供了一个带有函数 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答案