Created
December 8, 2021 10:10
-
-
Save jamland/a53da5b7aec1b5ca2536e310d1ac9bb4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const util = require("util"); | |
const path = require("path"); | |
const exec = util.promisify(require("child_process").exec); | |
const fs = require("fs"); | |
const splToken = "G7eETAaUzmsBPKhokZyfbaT4tD9igdZSmfQGEYWem8Sw"; | |
const iterateOverRecievers = async () => { | |
const rawdata = fs.readFileSync( | |
path.resolve(__dirname, "./address-for-drop.json") | |
); | |
const recievers = JSON.parse(rawdata); | |
console.log("recievers", recievers); | |
for (const reciever of recievers) { | |
await drop(reciever); | |
} | |
}; | |
async function drop(reciever) { | |
try { | |
const splTransferCmd = `spl-token transfer --fund-recipient --allow-unfunded-recipient ${splToken} 10000 ${reciever}`; | |
const { | |
// stdout, | |
stderr, | |
} = await exec(splTransferCmd); | |
if (stderr) { | |
console.log("stderr:", stderr); | |
} else { | |
console.log("Token succesfully sent to: ", reciever); | |
// console.log('stdout:', stdout); | |
} | |
} catch (err) { | |
console.error(err); | |
} | |
} | |
iterateOverRecievers(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment