Hi there.
Is it possible to use subscribes like this or future Web3 Alerts the same?
Are there any approximate time on the implementation of this functional?
Thanks.
Hi there.
Is it possible to use subscribes like this or future Web3 Alerts the same?
Are there any approximate time on the implementation of this functional?
Thanks.
We don’t know when web3 alerts will be implemented
Can you post better links in the future? Not easy to read on phone where links go. And I can not click on random links.
No problem at all ) Link which I was wrote above: https://web3js.readthedocs.io/en/v1.2.11/web3-eth-subscribe.html. Its enough?
that subscribe is if you connect directly to a speedy node, there is also this type of subscription with live queries that works with a server: https://docs.moralis.io/moralis-server/database/live-queries
Yep, thanks, I saw it. But where I can find the list of types of subscribes?
For example I am interested subscribe for events (methods) PairCreated / Mint / Presale / addLiquidityETH.
Thanks.
if you ant you could do it manually by subscribing to a specific contract event and then using the name of the event you wanr to subscribe to. something like
myContract.events.Transfer(options)
.on('data', event => console.log(event))
.on('changed', changed => console.log(changed))
.on('error', err => throw err)
.on('connected', str => console.log(str))
but youd have to know the event names before hand
you may need to know the topic for that event
So u mean about like this:
myContract.events.PairCreated(options)
.on('data', event => console.log(event))
.on('changed', changed => console.log(changed))
.on('error', err => throw err)
.on('connected', str => console.log(str))
What options is?
I know the topic. U give this link https://docs.moralis.io/moralis-server/database/live-queries, but I don’t see where I can use subscribe for a event.
Thanks.
I may have understood something wrong, maybe you don’t need the topic if you know the entire ABI
I knew how to do this in the past: How to subscribe to OwnershipTransferred event for any smart contract [SOLVED]
@tcolonel options is just other params you can pass to the request for more customisation such as filtering the event by address for example or filtering the event by its params like you could filter an event where one where you only return events where one of the params is a certain value etc, other options you can use is chhosing what how many blocks you want to listen for. so options would be this
let options = {
filter: {
value: [],
},
fromBlock: 0
};
where from block 0 just measn return the entire history of that event. but if the event is getting emitted very regularily this can be slow.
Yep I know it. But I don’t see any ABI at this page How to subscribe to OwnershipTransferred event for any smart contract [SOLVED]. And what is OwnershipTransferred in this example? Or it’s internal method?
But where I can read about it?
Thanks.
That should be the name of the event in that case. But it may be a completely different syntax than what you want to use
So where I can find info about it? Or its outside your service / site?
You have there the entire code in that example. That is direct usage of web3. Maybe you can find more in the documentation for web3. That code uses a RPC node.
Got u. Thanks for this.