NodeJs library to Pay using IOTA
Install the library npm install iotapay
Import package: require('iotapay');
Initialize:
new IOTAPAY({
host : 'http://node06.iotatoken.nl:14265'
});
Initialize:
const iotapay = new IOTAPAY();
Set Host manually like this:
iotapay.setHost('http://node06.iotatoken.nl:14265');
or we will find a suitable host for you like this:
iotapay.findHost(function (err, host) {
if(err) {
console.log('error:', err);
}
iotapay.setHost(host);
})
Get Balance:
iotapay.getBalance(['ADDRESS'], function (err, balance) {
if(err) {
console.log('error:', err);
}
console.log('balance:', balance);
})
Pay:
iotapay.transfer({
address: 'ADDRESS',
value: 1,
message: 'Testing',
seed: 'SEED'
}, function (err, result) {
if(err) {
console.log('error:', err);
}
console.log('result:', result);
})
Result gives bundle hash.
NOTE: Please, use proper iota node url, ADDRESS and your SEED to initialise. These are simple dummy values. NOT meant for production usage.