In the past I checked the users CCD token stake via the node https://api.hive-engine.com/rpc/contracts - but this stopped working. I tried a few other nodes, but can't get it working (because the other nodes don't deliver the full spectrum of functions?). However, I decided to ask for help here. If you have an idea or solution or can forward this question/post to a Hivian who could help, this would be awesome!
Is there another way to check the stake (in best case with JavaScript I think)? Which node do you use? What is wrong suddenly? It worked until 2, 3 days ago. Then api.hive-engine.com was down completely, now the node seems to be back, but my stake reading doesn't start to work again. Your support would be very welcome.
(Yes, I asked at the HiveDevs Discord and two buddies, too. As soon as I have a solution from anywhere I post the solution as comment under this article.)
The way I did it all the time - and worked as far as the api.hive-engine.com node was running well:
SOLVED. Or at least seems to work / works for me again. Node seems to deliver the data as needed again. So when the node is working as now and in the past, the CCCEO users should be able to use the voter as normal.
async function findUserCCDStake() {
try {
const response = await fetch('https://api.hive-engine.com/rpc/contracts', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'find',
params: {
contract: 'tokens',
table: 'balances',
query: {
symbol: 'CCD',
account: 'powerpaul', // powerpaul has 300,000 CCD in stake
},
},
id: 1,
}),
});
if (!response.ok) {
throw new Error(`HTTP error! Status: ${response.status}`);
}
const userData = await response.json();
if (userData.result && userData.result.length > 0) {
userCCDStake = parseFloat(userData.result[0].stake || 0);
console.log(userCCDStake);
return userCCDStake;
} else {
return 0; // If no CCD stake found
}
} catch (error) {
console.error('Error on api.hive-engine.com/rpc/contracts:', error.message);
return 0;
}
}
Once again thank you for your support!