Move.

帖子

分享您的知识。

andreweth..
Jan 28, 2025
专家问答

Why is my SUI transaction showing increased amount in preview?

I'm working on a function to facilitate user transaction signing with a dApp kit, specifically to transfer a set amount of SUI from a user's wallet to our wallet for a purchase. The code seems to be ready for the task, but when previewing the transaction in the user's wallet, the SUI amount oddly increases. Did I overlook any details, or is there a typical fix for this oddity?

  • Move CLI
  • Move
3
2
分享
评论
.

答案

2
DuAn.
Jan 29 2025, 05:26

您的备用代码片段建议添加先决条件函数调用coinWithBalance和另一种方法transferObjects来处理硬币转移,这看起来更符合标准惯例. 仔细检查有关金额转换和交易对象操作的逻辑,以确保正确的显示和执行. 此外,请确保在环境变量中准确定义收件人地址. 另一个关键方面是交易中发件人的分配:tx.setSender(currentAccount!.address);.确保currentAccount设置正确,因为不正确的账户处理可能会导致钱包预览中出现意外结果.

3
最佳答案
评论
.
Tawhid.
Jan 28 2025, 23:37

看来您的交易设置存在误解,这可能会导致SUI金额似乎有所增加,而不是像预期的那样减少. 在您共享的第一个函数中,确保您正确初始化了交易,并且转账执行正确. 在创建交易时,您可能需要仔细检查如何处理金额的转换.

2
评论
.

你知道答案吗?

请登录并分享。

Move is an executable bytecode language used to implement custom transactions and smart contracts.

148帖子231答案
Sui.X.Peera.

赚取你的 1000 Sui 份额

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

奖励活动七月