如何在C#中解码ETH原始日志数据

发布于 2025-02-06 04:17:23 字数 675 浏览 0 评论 0 原文

我有一个从共价获取的原始日志数据列表()。我知道该日志与之对应的事件,但是如何将其解码到此事件中?

看起来像“ 0x000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000097922D241BD41BD41BD4BD4BBBB0E13693284H8EA”

[Event("TokenFound")]
public class TokenFoundEventDTO : IEventDTO
{
    [Parameter("uint256", "tokenId", 1, false )]
    public BigInteger TokenId { get; set; }

    [Parameter("address", "buyer", 2, false )]
    public string? Buyer { get; set; }
}

。谁能帮助我做正确的事?

谢谢!

I have a list of raw log data retrieved from Covalent (https://api.covalenthq.com/v1/137/events/topics/). I know what the event this log corresponds to, but how do I decode it into this event?

It looks like "0x000000000000000000000000000000000000000000000000000000000000002d00000000000000000000000097922d241bd4e4ef4bb0e13693284H8ea75a6c52"

The event is something like

[Event("TokenFound")]
public class TokenFoundEventDTO : IEventDTO
{
    [Parameter("uint256", "tokenId", 1, false )]
    public BigInteger TokenId { get; set; }

    [Parameter("address", "buyer", 2, false )]
    public string? Buyer { get; set; }
}

I expected Nethereum to provide something where I can translate that raw log data into an event like this but I cannot find anything like that. Could anyone help guide me to the right thing?

Thanks!

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

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

发布评论

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

评论(1

一笔一画续写前缘 2025-02-13 04:17:23

令牌ID似乎是带有256位的UINT。这是32个字节,在十六进制字符串中构成64个字符。如果修剪起始 0x ,然后将其余部分拆分,则剩下两个64个字符字符串。

000000000000000000000000000000000000000000000000000000000000002d
00000000000000000000000097922d241bd4e4ef4bb0e13693284H8ea75a6c52

第一个(以“ 2D” 结尾)应解析为 biginteger (在那之前再次准备 0x ),第二个似乎是成为买方地址(也许剥夺领先的零)。

The token id seems to be a uint with 256 bits. That's 32 bytes which make up 64 characters in the hex string. If you trim the starting 0x and split the remainder in the middle you are left with two 64 character strings.

000000000000000000000000000000000000000000000000000000000000002d
00000000000000000000000097922d241bd4e4ef4bb0e13693284H8ea75a6c52

The first one (ending with "2d") should be parsed as a BigInteger (prepend the 0x again before that) and the second one seems to be the buyer address (maybe strip the leading zeros).

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