I am using the DASH npm package with a MeteorJS application. I would like to be able to listen for transaction events so I can call a Meteor method called "funds" whenever a transaction is sent to my wallet. However, I am receiving "undefined" errors in the console when attempting to set this up.
Documentation: https://dashevo.github.io/platform/SDK/examples/receive-money-and-check-balance/ https://www.npmjs.com/package/dash
What I would like to do looks in theory like this (fixtures.js):
import { Meteor } from 'meteor/meteor';
Meteor.startup(() => {
const Dash = require("dash");
const mnemonic = 'there ghost stay ripple silk gym curtain body salad icon sentence service';
const client = new Dash.Client({ network: "testnet", wallet: { mnemonic } });
client.getWalletAccount().then(async (account) => {
account.events.on('FETCHED_CONFIRMED_TRANSACTION', (data)=>{
var amount = data.amount;
var address = data.address;
if (address) {
Meteor.call('funds', address, amount, (error) => {
if (error) {
console.log(error);
}
});
}
});
});
});
This is what I have and what has worked successfully:
import { Meteor } from 'meteor/meteor';
Meteor.startup(() => {
const Dash = require("dash");
const mnemonic = 'there ghost stay ripple silk gym curtain body salad icon sentence service';
const client = new Dash.Client({ network: "testnet", wallet: { mnemonic } });
client.getWalletAccount().then(async (account) => {
console.log("Funding address", account.getUnusedAddress().address); // THIS WORKS!!!
console.log("Confirmed Balance", account.getConfirmedBalance()); // THIS WORKS!!!
// THE FOLLOWING DOES NOT CURRENTLY WORK!!!
// account.events.on('FETCHED_CONFIRMED_TRANSACTION', (data)=>{
// console.log('FETCHED/UNCONFIRMED_TRANSACTION');
// console.dir(data);
// var amount = data.amount;
// var address = data.address;
// if (address) {
// Meteor.call('funds', address, amount, (error) => {
// if (error) {
// console.log(error);
// }
// });
// }
// });
});
});
I have also tried the following per the documentation to no avail:
import { Meteor } from 'meteor/meteor';
Meteor.startup(() => {
const Dash = require("dash");
const mnemonic = 'there ghost stay ripple silk gym curtain body salad icon sentence service';
const client = new Dash.Client({ network: "testnet", wallet: { mnemonic } });
client.account.events.on('FETCHED/UNCONFIRMED_TRANSACTION', (data)=>{
console.log('FETCHED/UNCONFIRMED_TRANSACTION');
console.dir(data)
});
});
Thank you for your help
the documentation is currently in the process of updating
Instead of account.events.on do account.on https://github.com/dashevo/platform/issues/377#issuecomment-1124617321