Hi, Moralis stopped its servers. In Moralis there was a server function that you put the abi code and synchronized functions. How can I do this on the auto host server? this in my own host https://moralis.io/web3-syncing-how-to-sync-smart-contract-web3-events/
The equivalent of event syncs is to use streams api. You will find more info about streams api in the documentation at docs.moralis.io
so this https://moralis.io/web3-syncing-how-to-sync-smart-contract-web3-events/ is equivalent to this http://docs.moralis.io/? Is there any video in reference also that can do this?
You have a tab for streams api in the documentation with more info.
thanks cryptokid. I will review the documentation, Could you tell me where is the synchronization after an event to store in the db as moralis did?
In depends on what you are using as a backend. Streams api sends webhook requests with the new emitted events on blockchain and after that the backend will process them as needed.
thanks for the help but I see in the documentation the synchronization events to a smart contract but I donโt see an example in the documentation of how to synchronize only one function and store it in the table as sync did from the moralis server, is there an example in the moralis repository? I mean doing exactly the same as in v1 where you synchronized specific functions and when an event occurred it was automatically saved in the db.
Or do I have to do it manually?
it can depend on what you are using as backend on how you can do it, what are you using as backend now?
the same backend that provides moralis, parse server.
here it should be the documentation about how to use streams with a self hosted parse server:
https://v1docs.moralis.io/moralis-dapp/getting-started/self-hosting-moralis-server/optional-features/streams
Thanks, this documentation is clearer for me, I have another question, regarding the login, I need the moralis db for the session start and I used this Moralis.User.logIn()
, now in the new authentication api I donโt see documentation either, what would be the new version?
and also use
await user.signUp()
complete code for aut registration
const SetLoginMail = async (values: any) => {
setStateCircularProgress(true);
const user = new Moralis.User();
user.set("fullname", values.fullname);
user.set("username", values.username.toLowerCase());
user.set("email", values.email);
user.set("password", values.password);
const wallet = ethers.Wallet.createRandom();
user.set("mnemonic", wallet.mnemonic.phrase);
user.set("privateKey", wallet.privateKey);
user.set("ethAddress", wallet.address.toLowerCase());
user.set("accounts", [wallet.address.toLowerCase()]);
user.set("loginType", "email");
user.set("authData", {
"moralisEth": {
"id": `${wallet.address.toLowerCase()}`,
"signature": `${wallet.privateKey}`,
"data": `Welcome to Koolinart\n\nId:${wallet.address}`
}
})
try {
await user. signUp();
// user.save();
setValuesAlertFunc(true, "Successful creation", "success");
// Hooray! Let them use the app now.
} catch(error) {
const errorMessage = JSON.stringify(error);
const errorObject = JSON.parse(errorMessage);
setValuesAlertFunc(true, errorObject.message, "error");
// Show the error message somewhere and let the user try again.
// alert("Error: " + error.code + " " + error.message);
}
setStateCircularProgress(false);
};
backend error:
Request contains unknown parameter: symbol. This operation supports the following parameters: address, chain, toBlock, tokenAddresses {"code":141,"stack":"Error: [C0005] Request contains unknown parameter: symbol. This operation supports the following parameters: address, chain, toBlock, tokenAddresses\n at C:\\Users\\david\\Documents\\Programacion\\react\\Koolinart\\backend\\src\\cloud\\generated\\evmApi.ts:186:11\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)"}
warn: DeprecationWarning: auth.moralisEth is deprecated and will be removed in a future version. auth.moralisEth.enabled: true
error: Moralis auth failed, invalid data {"code":101,"stack":"Error: Moralis auth failed, invalid data\n at C:\\Users\\david\\Documents\\Programacion\\react\\Koolinart\\backend\\src\\auth\\MoralisEthAdapter.ts:32:13\n at runMicrotasks (<anonymous>)\n at processTicksAndRejections (node:internal/process/task_queues:96:5)\n at async Promise.all (index 0)"}
I identify that the problem is in the syntax here:
what should be the correct syntax?
// user.set("authData", {
// "moralisEth": {
// "id": `${wallet.address.toLowerCase()}`,
// "signature": `${wallet.privateKey}`,
// "data": `Welcome to Koolinart\n\nId:${wallet.address}`
// }
// })
Maybe you can check the network tab to see what was sent in the request. I didnโt see this error before.