transfer.js 832 B

12345678910111213141516171819202122232425262728293031
  1. /* global api, hashing, keyring, types, util, joy, window */
  2. // run this script with:
  3. // yarn script testTransfer
  4. //
  5. // or copy and paste the code into the pioneer javascript toolbox at:
  6. // https://testnet.joystream.org/#/js
  7. //
  8. const script = async ({ api, keyring }) => {
  9. const sudoAddress = (await api.query.sudo.key()).toString()
  10. let sudo
  11. if (typeof window === 'undefined') {
  12. // In node, get the keyPair if the keyring was provided
  13. sudo = keyring.getPair(sudoAddress)
  14. } else {
  15. // Pioneer: let the UI Signer handle it
  16. sudo = sudoAddress
  17. }
  18. const transfer = api.tx.balances.transfer(sudoAddress, 100)
  19. await transfer.signAndSend(sudo)
  20. }
  21. if (typeof module === 'undefined') {
  22. // Pioneer js-toolbox
  23. script({ api, hashing, keyring, types, util, joy })
  24. } else {
  25. // Node
  26. module.exports = script
  27. }