Created
June 10, 2019 19:14
-
-
Save JesseAbram/920a5316c4606f705c289d30c659ec73 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 { ApiPromise } = require("@polkadot/api"); | |
const WsProvider = require("@polkadot/rpc-provider").WsProvider; | |
const { Keyring } = require("@polkadot/keyring"); | |
exports.createTransaction = async (to, wallet, token) => { | |
const provider = new WsProvider(token.networkUrl); | |
const keyring = new Keyring({ type: wallet.keyType }); | |
const pk = keyring.addFromMnemonic(wallet.privateKey); | |
const api = await ApiPromise.create(provider); | |
const txn = await api.tx.balances.transfer(to, token.maxSupplyAllowed).signAndSend(pk); | |
if (provider.isConnected()) provider.disconnect() | |
return txn | |
} | |
exports.sendTransaction = async (txn, options) => { | |
return Object.assign(options, { | |
hash: txn.toHex(), | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment