-
-
Save niponchi/732303b3acd5c86ea3ff9548969814ca 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 distributeXlm = async (masterAccount, amount, ...walletAccounts) => { | |
console.log('distribute xlm') | |
const transferFunc = async (master, destinationPublic, asset, amount) => { | |
console.log('transfer', asset.code) | |
let account = await server.loadAccount(destinationPublic) | |
let transaction = new TransactionBuilder(account, { fee: 100 }) | |
.addOperation( | |
Operation.payment({ | |
source: master.publicKey(), | |
amount: `${amount}`, | |
asset: asset, | |
destination: destinationPublic, | |
}) | |
) | |
.addOperation( | |
Operation.payment({ | |
source: master.publicKey(), | |
amount: `${2*0.00001}`, | |
asset: asset, | |
destination: destinationPublic, | |
}) | |
) | |
.addMemo(Memo.text(`${Date.now()}`)) | |
.setTimeout(TimeoutInfinite) | |
.build() | |
transaction.sign(master) | |
return server.submitTransaction(transaction) | |
} | |
txs = walletAccounts.map(w => transferFunc(masterAccount, w.publicKey(), Asset.native(), amount)) | |
await Promise.all(txs) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment