2

I have to add/update some data in a database when specific events are emitted by a solidity smart contract. When using web3.js there is a simple method called watch(), but I didn't find anything like that in the Nethereum C# library.

There is an example in web3.js:

var instructorEvent = Coursetro.Instructor();
instructorEvent.watch(function(error, result){
     ...
});

Another way to do it using web3.js:

myContract.events.MyEvent({})
    .on('data', async function(event){
        console.log(event.returnValues);
        // Do something here
    })
    .on('error', console.error);

It hasn't to be a solution with Nethereum but has to work on C#. In case I don't discover an answer to C#, I will try it using a Node.JS API.

1

1 Answer 1

1

You can use streaming websocket client. It is present in the docs - https://docs.nethereum.com/en/latest/introduction/ws/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.