transfer signAndSend example for the dapp dev (#76)

This commit is contained in:
Jaco Greeff 2019-07-14 11:29:50 +02:00 committed by GitHub
parent b58c7e371d
commit 84c7870499
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -28,4 +28,11 @@ const injector = await web3FromAddress('5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7
// sets the signer for the address on the @polkadot/api
api.setSigner(injector.signer);
// sign and send out transaction - notice here that the address of the account (as retrieved injected)
// is passed through as the param to the `signAndSend`, the API then calls the extension to present
// to the user and get it signed. Once completex, the api sends the tx + signature via the normal process
api.tx.balances
.transfer('5C5555yEXUcmEJ5kkcCMvdZjUo7NGJiQJMS7vZXEeoMhj3VQ', 123456)
.signAndSend('5DTestUPts3kjeXSTMyerHihn1uwMfLj8vU8sqF7qYrFabHE', (status) => { ... });
```