Not sure why it stopped working but it was working a couple days ago.
Code:
var Web3 = require('web3');
const Moralis = require('moralis/node');
const ethers = require('ethers');
const options = {
// Enable auto reconnection
reconnect: {
auto: true,
delay: 5000, // ms
maxAttempts: 5,
onTimeout: false
}
};
var web3 = new Web3(
new Web3.providers.WebsocketProvider(
"speedynode url",
options
)
);
const serverUrl = "moralis_serverurl";
const appId = "app_id";
Moralis.start({ serverUrl, appId });
async function init(){ //this function is where it goes wrong
let query = new Moralis.Query('PairCreatedEvents');
let subscription = await query.subscribe();
subscription.on('create', pair_created);
subscription.on('open', () => {
console.log('subscription opened');
});
subscription.on('close', () => {
console.log('subscription closed');
});
}
the Exact error:
C:\Users\Do Yugen\Desktop\TestBot\Node\node_modules\moralis\lib\node\MoralisWeb3Api.js:37
throw new Error('Web3Api.initialize failed: initialize with apiKey or serverUrl');
^
Error: Web3Api.initialize failed: initialize with apiKey or serverUrl
at Function.initialize (C:\Users\Do
Yugen\Desktop\TestBot\Node\node_modules\moralis\lib\node\MoralisWeb3Api.js:37:13)
at Function.start (C:\Users\Do
Yugen\Desktop\TestBot\Node\node_modules\moralis\lib\node\Parse.js:132:18)
at Object.<anonymous> (C:\Users\Do Yugen\Desktop\TestBot\Node\app.js:42:9)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:17:47
Not sure where something has changed