@iov/cli
Command line interface for iov core
Last updated a month ago by iovdave .
Apache-2.0 · Repository · Original npm · Tarball · package.json
$ cnpm install @iov/cli 
SYNC missed versions from official npm registry.

@iov/cli

npm version

Installation and first run

The iov-cli executable is available via npm. We recommend local installations to your demo project. If you don't have one yet, just mkdir iov-cli-installation && cd iov-cli-installation && yarn init -y.

locally with yarn

$ yarn add @iov/cli --dev
$ ./node_modules/.bin/iov-cli

locally with npm

$ npm install @iov/cli --save-dev
$ ./node_modules/.bin/iov-cli

globally with yarn

$ yarn global add @iov/cli
$ iov-cli

globally with npm

$ npm install -g @iov/cli
$ iov-cli

How to use the IOV-Core command line interface

  1. Install @iov/cli and run iov-cli as shown above
  2. Start a local BNS blockchain as described in scripts/bnsd/README.md
  3. Play around as in the following example code:
> const profile = new UserProfile();
> const signer = new MultiChainSigner(profile);
> const { connection } = await signer.addChain(createBnsConnector("ws://localhost:23456"));
> const chainId = connection.chainId;

> chainId
'test-chain-esuZ1V'

> const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic("degree tackle suggest window test behind mesh extra cover prepare oak script"));

> profile.getIdentities(wallet.id)
[]

> const faucet = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0))

> faucet.pubkey
{ algo: 'ed25519',
  data:
   Uint8Array [
     224,
     42, ...

> profile.setIdentityLabel(faucet, "blockchain of value faucet")

> profile.getIdentities(wallet.id)
[ { chainId: 'test-chain-esuZ1V',
    pubkey: { algo: 'ed25519', data: [Uint8Array] } } ]

> const faucetAddress = signer.identityToAddress(faucet);
> faucetAddress
'tiov1k898u78hgs36uqw68dg7va5nfkgstu5z0fhz3f'
> (await connection.getAccount({ address: faucetAddress })).balance

> const recipient = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(1));
> const recipientAddress = signer.identityToAddress(recipient);

> .editor
const sendTx = await connection.withDefaultFee<SendTransaction>({
  kind: "bcp/send",
  chainId: faucet.chainId,
  sender: faucetAddress,
  recipient: recipientAddress,
  memo: "My first transaction",
  amount: {
    quantity: "33123456789",
    fractionalDigits: 9,
    tokenTicker: "CASH" as TokenTicker,
  },
}, faucetAddress);
^D
> await signer.signAndPost(faucet, sendTx);
> (await connection.getAccount({ address: recipientAddress })).balance;

> await connection.searchTx({ sentFromOrTo: faucetAddress });
> await connection.searchTx({ sentFromOrTo: recipientAddress });
  1. Congratulations, you sent your first money!
  2. Add an additional wallet
> profile.wallets.value
[ { id: 'ReYESw51lsOOr8_X', label: undefined } ]

> const wallet2 = profile.addWallet(Secp256k1HdWallet.fromMnemonic("organ wheat manage mirror wish truly tool trumpet since equip flight bracket"))

> profile.wallets.value
[ { id: 'ReYESw51lsOOr8_X', label: undefined },
  { id: 'FtIcQqMWcRpEIruk', label: undefined } ]

> profile.getIdentities(wallet.id)
[ { chainId: 'test-chain-esuZ1V',
    pubkey: { algo: 'ed25519', data: [Uint8Array] } } ]

> profile.getIdentities(wallet2.id)
[]

> profile.setWalletLabel(wallet.id, "ed")
> profile.setWalletLabel(wallet2.id, "secp")

> profile.wallets.value
[ { id: 'ReYESw51lsOOr8_X', label: 'ed' },
  { id: 'FtIcQqMWcRpEIruk', label: 'secp' } ]
  1. Now store to disk
> const db = levelup(leveldown('./my_userprofile_db'))
> await profile.storeIn(db, "secret passwd")
  1. and restore
> const profileFromDb = await UserProfile.loadFrom(db, "secret passwd");
> profileFromDb
UserProfile {
  createdAt: 2018-07-04T16:07:14.583Z,
  keyring:
   Keyring { wallets: [ [Ed25519HdWallet], [Secp256k1HdWallet] ] },
  ...

Disconnecting

When you are done using a WebSocket connection, disconnect the connection

> (await connection.getAccount({ address: faucetAddress })).balance
[ { quantity: '123456755876543211',
    fractionalDigits: 9,
    tokenTicker: 'CASH' } ]
> connection.disconnect()
undefined
> (await connection.getAccount({ address: faucetAddress })).balance
Error: Socket was closed, so no data can be sent anymore.
    at ...

Faucet usage

When using a Testnet, you can use the IovFaucet to receive tokens.

In this example we connect to a public test network.

> const mnemonic = Bip39.encode(Random.getBytes(16)).toString();
> mnemonic
'helmet album grow detail apology thank wire chef fame core private cargo'
> const profile = new UserProfile();
> const wallet = profile.addWallet(Ed25519HdWallet.fromMnemonic(mnemonic));

> const signer = new MultiChainSigner(profile);
> const { connection } = await signer.addChain(createBnsConnector("ws://rpc-private-a-x-exchangenet.iov.one:16657"));
> const chainId = connection.chainId;

> const alice = await profile.createIdentity(wallet.id, chainId, HdPaths.iov(0));
> const aliceAddress = signer.identityToAddress(alice);

> const faucet = new IovFaucet("http://faucet.x-exchangenet.iov.one:8080/");

> await faucet.credit(aliceAddress, "IOV" as TokenTicker)
> (await connection.getAccount({ address: aliceAddress })).balance
[ { quantity: '10000000000',
    fractionalDigits: 9,
    tokenTicker: 'IOV' } ]

License

This package is part of the IOV-Core repository, licensed under the Apache License 2.0 (see NOTICE and LICENSE).

Current Tags

  • 2.2.4-alpha.1                                ...           canary (2 months ago)
  • 2.3.0                                ...           latest (a month ago)
  • 2.0.0-alpha.7                                ...           next (4 months ago)

99 Versions

  • 2.3.0                                ...           a month ago
  • 2.2.5                                ...           a month ago
  • 2.2.4                                ...           2 months ago
  • 2.2.4-alpha.1                                ...           2 months ago
  • 2.2.4-alpha.0                                ...           2 months ago
  • 2.2.3                                ...           2 months ago
  • 2.2.0                                ...           3 months ago
  • 2.1.0                                ...           3 months ago
  • 2.0.2                                ...           3 months ago
  • 2.0.1                                ...           4 months ago
  • 2.0.0                                ...           4 months ago
  • 2.0.0-alpha.7                                ...           4 months ago
  • 2.0.0-alpha.6                                ...           4 months ago
  • 2.0.0-alpha.5                                ...           5 months ago
  • 2.0.0-alpha.4                                ...           5 months ago
  • 2.0.0-alpha.3                                ...           5 months ago
  • 2.0.0-alpha.2                                ...           5 months ago
  • 2.0.0-alpha.1                                ...           5 months ago
  • 2.0.0-alpha.0                                ...           5 months ago
  • 1.2.0                                ...           6 months ago
  • 1.1.0                                ...           7 months ago
  • 1.0.0                                ...           8 months ago
  • 1.0.0-alpha.1                                ...           8 months ago
  • 1.0.0-alpha.0                                ...           8 months ago
  • 0.17.8                                ...           8 months ago
  • 0.17.7                                ...           8 months ago
  • 0.17.6                                ...           8 months ago
  • 0.17.5                                ...           9 months ago
  • 0.17.4                                ...           9 months ago
  • 0.17.3                                ...           9 months ago
  • 0.17.2                                ...           9 months ago
  • 0.17.1                                ...           9 months ago
  • 0.17.0                                ...           9 months ago
  • 0.16.3                                ...           9 months ago
  • 0.16.2                                ...           10 months ago
  • 0.16.1                                ...           10 months ago
  • 0.16.0                                ...           10 months ago
  • 0.16.0-alpha.4                                ...           10 months ago
  • 0.16.0-alpha.3                                ...           10 months ago
  • 0.16.0-alpha.2                                ...           10 months ago
  • 0.16.0-alpha.1                                ...           10 months ago
  • 0.16.0-alpha.0                                ...           10 months ago
  • 0.15.0                                ...           a year ago
  • 0.14.5                                ...           a year ago
  • 0.14.4                                ...           a year ago
  • 0.14.3                                ...           a year ago
  • 0.13.8                                ...           a year ago
  • 0.14.2                                ...           a year ago
  • 0.13.7                                ...           a year ago
  • 0.14.1                                ...           a year ago
  • 0.13.6                                ...           a year ago
  • 0.13.5                                ...           a year ago
  • 0.13.4                                ...           a year ago
  • 0.14.0                                ...           a year ago
  • 0.13.3                                ...           a year ago
  • 0.13.2                                ...           a year ago
  • 0.13.1                                ...           a year ago
  • 0.13.0                                ...           a year ago
  • 0.12.3                                ...           a year ago
  • 0.13.0-alpha.0                                ...           a year ago
  • 0.12.2                                ...           a year ago
  • 0.12.1                                ...           a year ago
  • 0.11.3                                ...           a year ago
  • 0.12.0                                ...           a year ago
  • 0.11.2                                ...           a year ago
  • 0.11.1                                ...           a year ago
  • 0.11.0                                ...           a year ago
  • 0.11.0-alpha.1                                ...           a year ago
  • 0.11.0-alpha.0                                ...           a year ago
  • 0.10.4                                ...           a year ago
  • 0.10.3                                ...           a year ago
  • 0.10.2                                ...           a year ago
  • 0.10.1                                ...           a year ago
  • 0.10.0                                ...           a year ago
  • 0.9.3                                ...           a year ago
  • 0.9.2                                ...           a year ago
  • 0.9.1                                ...           2 years ago
  • 0.9.0                                ...           2 years ago
  • 0.8.1                                ...           2 years ago
  • 0.8.0                                ...           2 years ago
  • 0.7.1                                ...           2 years ago
  • 0.7.0                                ...           2 years ago
  • 0.7.0-alpha.1                                ...           2 years ago
  • 0.7.0-alpha.0                                ...           2 years ago
  • 0.6.1                                ...           2 years ago
  • 0.6.0                                ...           2 years ago
  • 0.5.4                                ...           2 years ago
  • 0.5.3                                ...           2 years ago
  • 0.5.2                                ...           2 years ago
  • 0.5.1                                ...           2 years ago
  • 0.5.0                                ...           2 years ago
  • 0.4.1                                ...           2 years ago
  • 0.4.0                                ...           2 years ago
  • 0.3.1                                ...           2 years ago
  • 0.3.0                                ...           2 years ago
  • 0.3.0-alpha.0                                ...           2 years ago
  • 0.2.0                                ...           2 years ago
  • 0.2.0-7                                ...           2 years ago
  • 0.2.0-6                                ...           2 years ago
Downloads
Today 0
This Week 99
This Month 100
Last Day 0
Last Week 0
Last Month 40
Dependencies (13)
Dev Dependencies (3)
Dependents (0)
None

Copyright 2014 - 2016 © taobao.org |