Last active
April 1, 2019 18:59
-
-
Save JesseAbram/7f3652aac7e14b2a5c931a35233fcc5e 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"); | |
const keyring = new Keyring(); | |
const address = "5CdPxYGJvhL8EmK5vK9snmws1mjHJTQEtUAx2ihtdBne5fAF"; | |
const sender = "5DXnxgx4EAWc3d39gZmfUEw4g8NUMdiwFvWbwYsQuH72nRFj"; | |
const pk = keyring.addFromMnemonic( | |
"mneumoinc goes here" | |
); | |
const provider = new WsProvider("wss://poc3-rpc.polkadot.io/"); | |
const main = async () => { | |
const api = await ApiPromise.create(provider); | |
const balance = await api.query.balances.freeBalance(sender); | |
console.log("this is your balance", balance.toString()); | |
const nonce = await api.query.system.accountNonce(sender); | |
console.log("nonce", nonce); | |
const hash = await api.tx.balances.transfer(address, 1).signAndSend(pk); | |
console.log(hash.toHex()) | |
}; | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This worked exactly as-is for me (test mnemonic for my local account)
("@polkadot/api": "^0.45.9")