如何获取 solana 上的交易金额或价值?

发布于 2025-01-13 13:02:36 字数 975 浏览 0 评论 0原文

使用此代码可以为我提供 Solana 区块链上的交易信息:

var treansaction = await rpcClient.GetTransactionAsync("3QHYFzSn5Red7PZ2UA9AGkPWmcLgYrQhKAxWfK2AXCiCpe1wYBbf6BVRvtyTacSiD7PmREF8jNwqvbWo6z2NPWSc");
Console.WriteLine($"{treansaction.Result.Transaction}");
Console.WriteLine($"{treansaction.Result.BlockTime.Value}");
Console.WriteLine($"{treansaction.Result.Slot}");
Console.WriteLine($"{treansaction.Result.Meta.Fee}");
Console.WriteLine($"{treansaction.Result.Meta.Error}");
Console.WriteLine($"{treansaction.Result.Meta.PreTokenBalances}");
Console.WriteLine($"{treansaction.Result.Meta.PreBalances}");
Console.WriteLine($"{treansaction.Result.Meta.PostTokenBalances}");
Console.WriteLine($"{treansaction.Result.Meta.InnerInstructions}");
Console.WriteLine($"{treansaction.Result.Meta.PreTokenBalances}");

Console.WriteLine($"{treansaction.Result.Transaction.Message}");
Console.WriteLine($"{treansaction.Result.Transaction.Signatures}");

但我无法获取交易价值或金额?

using this code that gives me a transaction inforamation on Solana Blockchain :

var treansaction = await rpcClient.GetTransactionAsync("3QHYFzSn5Red7PZ2UA9AGkPWmcLgYrQhKAxWfK2AXCiCpe1wYBbf6BVRvtyTacSiD7PmREF8jNwqvbWo6z2NPWSc");
Console.WriteLine(
quot;{treansaction.Result.Transaction}");
Console.WriteLine(
quot;{treansaction.Result.BlockTime.Value}");
Console.WriteLine(
quot;{treansaction.Result.Slot}");
Console.WriteLine(
quot;{treansaction.Result.Meta.Fee}");
Console.WriteLine(
quot;{treansaction.Result.Meta.Error}");
Console.WriteLine(
quot;{treansaction.Result.Meta.PreTokenBalances}");
Console.WriteLine(
quot;{treansaction.Result.Meta.PreBalances}");
Console.WriteLine(
quot;{treansaction.Result.Meta.PostTokenBalances}");
Console.WriteLine(
quot;{treansaction.Result.Meta.InnerInstructions}");
Console.WriteLine(
quot;{treansaction.Result.Meta.PreTokenBalances}");

Console.WriteLine(
quot;{treansaction.Result.Transaction.Message}");
Console.WriteLine(
quot;{treansaction.Result.Transaction.Signatures}");

but i cant get Transaction Value or amount ??

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

晚风撩人 2025-01-20 13:02:36

这太糟糕了——Solnet 库将交易的返回格式硬编码为“json”,而不提供使用“jsonParsed”的选项。您需要更改此行以传入 "jsonParsed"https://github.com/bmresearch/Solnet/blob/591b814fef270606332da6a4c1da4866f83f07ce/src/Solnet.Rpc/SolanaRpcClient.cs#L432

之后,您将能够查看transaction.message.instructions[0].data 获取有关传输值的完整信息。

另外,您还可以使用 preBalancespostBalances 来查看整个交易期间移动了多少金额。

This is too bad -- the Solnet library hardcodes the return format for the transaction to "json", not giving the option to use "jsonParsed". You would need to change this line to pass in "jsonParsed": https://github.com/bmresearch/Solnet/blob/591b814fef270606332da6a4c1da4866f83f07ce/src/Solnet.Rpc/SolanaRpcClient.cs#L432

After that, you'll be able to look at transaction.message.instructions[0].data to get the full info about the value transferred.

Separately, you could also use the preBalances and postBalances to see how much was moved during the whole transaction.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文