How Sync Multiple Contract in Same Functions / class

try first to sync that event directly and not from code, to make sure that all the other parameters have the right value

also, at some point you will have to remove the previous events if one event was added with the wrong abi, coreservices may get stuck if wrong parameters are used

When i do Sync event for swap from website adding Contract it work for that contract only but when i did it from code without address, it did not

Please could you explain me bit, I think your did not understand i am trying to do ? or i have to explain more

can you paste what you use to do a simple event sync from code, without historical sync, with contract address? preferably only the abi for the event and not the entire contract abi

// code example of creating a sync event from cloud code
let options = {
chainId: “0x38”,
topic: “Swap(address,uint256,uint256,uint256,uint256,address)”,
address:“0x05faf555522fa3f93959f86b41a3808666093210”
abi: {
anonymous: false,
inputs: [
{
indexed: true,
internalType: “address”,
name: “sender”,
type: “address”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount0In”,
type: “uint256”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount1In”,
type: “uint256”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount0Out”,
type: “uint256”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount1Out”,
type: “uint256”,
},
{
indexed: true,
internalType: “address”,
name: “to”,
type: “address”,
},
],
name: “Swap”,
type: “event”,
},
limit: 500000,
tableName: “UniPairCreatedwq”,
sync_historical: false,
};

Moralis.Cloud.run(“watchContractEvent”, options, { useMasterKey: true });

you can see here how to post code on forum:

does this work as expected?

Hey bro thanks now all swap are also being index, But Can i save Amount0 In in decimals formatted and, At the time of swap what was the price of token on data base ?

you can use a hook like afterSave or beforeSave to add data in a new column, you can add it as string, I don’t know how to add a new column as decimal

you could compute that swap price and add it to a table, you can also query that price anytime later based on the block number, you can also make a job that runs every x minutes that updates that data

do you have any docs about it

you could start from here: https://docs.moralis.io/moralis-dapp/cloud-code/triggers#aftersave

Hello the cloud code is not syncing and indexing historical swap evets why?

Now sure what you mean with that

I mean that The event is not indexing historical / past events , its only syncing new events only

let options = {
chainId: “0x38”,
topic: “Swap(address,uint256,uint256,uint256,uint256,address)”,
address:“0x05faf555522fa3f93959f86b41a3808666093210”
abi: {
anonymous: false,
inputs: [
{
indexed: true,
internalType: “address”,
name: “sender”,
type: “address”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount0In”,
type: “uint256”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount1In”,
type: “uint256”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount0Out”,
type: “uint256”,
},
{
indexed: false,
internalType: “uint256”,
name: “amount1Out”,
type: “uint256”,
},
{
indexed: true,
internalType: “address”,
name: “to”,
type: “address”,
},
],
name: “Swap”,
type: “event”,
},
limit: 500000,
tableName: “UniPairCreatedwq”,
sync_historical: true,`Preformatted text`
};

Moralis.Cloud.run(“watchContractEvent”, options, { useMasterKey: true })

Ok, strange, maybe you have to wait some time. But it shouldn’t take more than 10-20 minutes

its been 2hours, it only sync present events , Not historical or past events

can you tell me why…

Maybe is some issue somewhere, can you also paste the server url?

https://kl4j5eyvvnp5.usemoralis.com:2053/server

This is my serval url