-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathpin.js
28 lines (23 loc) · 836 Bytes
/
pin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var shiftjs = require('../shift-js');
// Variables
var node = 'localhost';
var SHIFT = shiftjs.api({ testnet: true, port: 9405, node: node });
var secretPhrase = 'your secret phrase goes here';
var secondPhrase = false;
// Arguments
var args = process.argv.splice(process.execArgv.length + 2);
var hash = args[0] || "Qm";
var bytes = parseInt(args[1]) || 0;
var unpin = args[2] == 'true';
var parent = args[3].toString() || null;
// Create pin transaction
var account = SHIFT.getAddressFromSecret(secretPhrase);
// Generate and broadcast pin transaction
SHIFT.sendRequest('pins', {
hash: hash, bytes: bytes, parent: parent, secret: secretPhrase, secondSecret: secondPhrase, type: (unpin ? 'unpin' : 'pin' )},
function (data) {
data.senderid = account.address;
// Output to console
console.log(JSON.stringify(data));
}
);