Giter VIP home page Giter VIP logo

Comments (10)

greenkiller avatar greenkiller commented on May 18, 2024 1

Thanks for the prompt solution Juan!

from nethereum.

juanfranblanco avatar juanfranblanco commented on May 18, 2024

Thanks for the clarification... can you post your Event DTO?

from nethereum.

juanfranblanco avatar juanfranblanco commented on May 18, 2024

Also please raise another issue if it is changed :) (obviously not now)

from nethereum.

greenkiller avatar greenkiller commented on May 18, 2024

Hi Juan,

Here is the DTO for them. Thanks.

public class EventMultipliedSenderLog
{
    [Nethereum.ABI.FunctionEncoding.Attributes.Parameter("uint", "a", 1, true)]
    public int A { get; set; }

    [Nethereum.ABI.FunctionEncoding.Attributes.Parameter("address", "sender", 2, true)]
    public string Sender { get; set; }

    [Nethereum.ABI.FunctionEncoding.Attributes.Parameter("string", "hello", 3, true)]
    public string Hello { get; set; }
}

public class EventMultiplied
{
    [Nethereum.ABI.FunctionEncoding.Attributes.Parameter("uint", "a", 1, true)]
    public int A { get; set; }

    [Nethereum.ABI.FunctionEncoding.Attributes.Parameter("uint", "result", 2, true)]
    public int Result { get; set; }

    [Nethereum.ABI.FunctionEncoding.Attributes.Parameter("string", "hello", 3, false)]
    public string Hello { get; set; }
}

from nethereum.

greenkiller avatar greenkiller commented on May 18, 2024

The C# code to get the events:

            var multipliedEvent = contract.GetEvent("MultipliedLog");
            var filterAll = await multipliedEvent.CreateFilterAsync(new Nethereum.RPC.Eth.DTOs.BlockParameter(0));
            var eventLogsAll = await multipliedEvent.GetAllChanges<EventMultiplied2>(filterAll);

Event Multiplied (with DTO EventMultiplied) works well. The only difference I can find is the "indexed" string.

from nethereum.

juanfranblanco avatar juanfranblanco commented on May 18, 2024

Short story, retrieving the indexed values for dynamic types (strings, arrays) is not supported.
Long story:
The topics for indexed types if dynamics are stored as the SHA3 Keccak value (so they can be indexed and searched by matching the value).
Work around:
Use a bytes32, or don't index strings if you just want the data

from nethereum.

juanfranblanco avatar juanfranblanco commented on May 18, 2024

So for example if you look at the index topic for "Hello world" it retrieves ed6c11b0b5b808960df26f5bfc471d04c1995b0ffd2055925ad1be28d6baadfd

from nethereum.

juanfranblanco avatar juanfranblanco commented on May 18, 2024

Keeping it open as I need to validate the data part

from nethereum.

greenkiller avatar greenkiller commented on May 18, 2024

I see. Thanks.

from nethereum.

juanfranblanco avatar juanfranblanco commented on May 18, 2024

I have just pushed a fix which will allow to have indexed dynamic types as part of the Event DTO, mainly they will store the sha3 keccak string. This will prevent an error to be thrown, when decoding.

A further solution for your problem if you want to have the index and value of the string will be to have 2 event parameters, 1 for the index and another for the value.

from nethereum.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.