Closed devgreek closed 3 years ago
what is the value of addr
?
I fixed it, silly mistake, it's getTransactions() not getTransaction()
The code emit real-time payments on your address
In case anyone need this, now I have to find the same solution for ethereum
const app = express()
const http = require('http').Server(app)
const io = require('socket.io')(http)
const addr = 'rppm2hDuKZVhN1GZ8E3E9syuaTFne53cL6'
const server = 'wss://s.altnet.rippletest.net:51233'
const RippleAPI = require('ripple-lib').RippleAPI
const api = new RippleAPI({server:server})
api.on('error', (code, msg) => {
console.log(code, msg)
})
api.on('connected', ()=> {
console.log('connected to testnet');
})
api.on('disconnected', (code)=> {
console.log('disconnected to testnet');
})
api.connect().then((result) => {
let checks = 0
let checktx = setInterval(() => {
if (checks < 900 ){
api.getLedgerVersion().then((ledger) => {
api.getTransactions(addr, {minLedgerVersion:ledger}).then((txs) => {
console.log(txs)
for (tx of txs) {
if(tx.specification.destination.tag === 41){
clearInterval(checktx)
io.emit('emit', {
id: elem.id,
from: elem.specification.destination.source.address,
tag: elem.specification.destination.source.tag,
amount: elem.specification.destination.amount.value,
msg: 'payment was recievd'
})
}
}
})
})
checks++
} else {
clearInterval(checktx)
console.log('Payment is cancelled')
io.emit({msg: 'Payment is cancelled'})
}
}, 1000)
}).catch((err) => {
console.log(err);
});
Are you happy to close this issue @Yeppman?
Are you happy to close this issue @Yeppman?
yes
I'm setting up a function that calls and receives any payments made then I run into this error as I begin