ghost-portal/packages/app-js/src/snippets/transfer.ts
Stefanie Doll a69548866b
App-js follow up tasks (#703)
* Bump up yarn.lock

* Clean up examples, added jacos example to storage examples

* Fixed Dropdown

* Update package.json

* resize wip

* css resize fix

* Add line-break after code in exec to prevent catch from  being commented out

* Fixed typo in example

* Formatting

* More formatting

* Added missing semicolon

* Update to use UI signer

* Make visible on sidebar

* Combine some info from samples

* blockPeriod.toNumber() (oops, dropped that, reinstate)

* lifecycle bugfix for duplicate comments

* Kicked Intro, moved info to WRAPPER

* removed leftover <Intro /> import
2019-02-13 12:30:41 +01:00

29 lines
974 B
TypeScript

// Copyright 2017-2019 @polkadot/app-123code authors & contributors
// This software may be modified and distributed under the terms
// of the Apache-2.0 license. See the LICENSE file for details.
export default `// transfer
const sender = '5GoKvZWG5ZPYL1WUovuHW3zJBWBP5eT8CbqjdRY4Q6iMaDtZ';
const recipient = '5GTZEKgRKX2a5hepNjwTBzR5nR6UqtEsMZ4TnL1Yuah1N2Tu';
const nonce = await api.query.system.accountNonce(ALICE),
console.log('Current nonce', nonce);
const unsub = await api.tx.balances
.transfer(recipient,12345)
.signAndSend(sender, ({ events = [], status, type }) => {
console.log('Transaction status:', type);
if (type === 'Finalised') {
console.log('Completed at block hash', status.asFinalised.toHex());
console.log('Events:');
events.forEach(({ phase, event: { data, method, section } }) => {
console.log('\t', phase.toString(), \`: \${section}.\${method}\`, data.toString());
});
unsub();
}
});`;