Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection not open to send() when getPastEvents call for smart contract subscribe #15

Open
eldorado-Coder opened this issue May 31, 2022 · 0 comments

Comments

@eldorado-Coder
Copy link

I am going to subscribe event from polygon mainnet token contract, but connection not open to send() error comes out
`
const { contractAddress } = process.env;

const Web3 = require('web3');

const url = 'wss://ws-mumbai.matic.today/';
const web3 = new Web3(url);

const options = {
reconnect: {
auto: true,
delay: 1000, // ms
maxAttempts: 1,
onTimeout: false,
},
address: contractAddress,
topics: [
'0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
],

function initSubscription() {
web3.eth
.subscribe('logs', options, (error, result) => {
if (!error) console.log('got result');
else console.log('error - ', error);
})
.on('data', (log) => {
console.log('got data', log);
})
.on('changed', (log) => {
console.log('changed');
});
}
};`

wss url is not right?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant