1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480
|
XBR Command line interface
==========================
Autobahn includes a command-line interface for the `XBR network <https://xbr.network>`__.
Status
------
* ``version``
* ``get-member``
* ``get-market``
* ``get-actor``
* ``register-member``
* ``register-member-verify``
* ``join-market``
* ``join-market-verify``
* ``create-market``
* ``create-market-verify``
* ``open-channel``
* ``get-channel``
Prerequisites
-------------
Installation
............
The XBR CLI (included in the `xbr` install flavor of Autobahn) can be installed using pip:
.. code-block:: console
$ pip install autobahn[all]
To run the CLI and check for the installed version including on-chain XBR contract addresses in use:
.. code-block:: console
$ xbrnetwork version
XBR CLI v20.6.1
Profile default loaded from /home/oberstet/.xbrnetwork/config.ini
Contract addresses:
XBRToken : 0xaCef957D54c639575f4DB68b1992B36504f33FEA [source: builtin]
XBRNetwork : 0x7A3d22c59e8F8f1b88ba7205f3f5a65Bc86D04Bc [source: builtin]
XBRDomain : 0xf5fb56886f033855C1a36F651E927551749361bC [source: builtin]
XBRCatalog : 0x2C77E46Ea9502B363343e8c826c41c7fdb25Db66 [source: builtin]
XBRMarket : 0x0DcF924ab0846101d31514E9fb3adf5070d4B83d [source: builtin]
XBRChannel : 0x670497A012322B99a5C18B8463940996141Cb952 [source: builtin]
Help
....
To get help on the available top-level commands:
.. code-block:: console
$ xbrnetwork --help
usage: xbrnetwork [-h] [-d] [--url URL] [--realm REALM] [--ethkey ETHKEY] [--cskey CSKEY] [--username USERNAME] [--email EMAIL]
[--market MARKET] [--market_title MARKET_TITLE] [--market_label MARKET_LABEL] [--market_homepage MARKET_HOMEPAGE]
[--provider_security PROVIDER_SECURITY] [--consumer_security CONSUMER_SECURITY] [--market_fee MARKET_FEE]
[--marketmaker MARKETMAKER] [--actor_type {1,2,3}] [--vcode VCODE] [--vaction VACTION] [--channel CHANNEL]
[--channel_type {1,2}] [--delegate DELEGATE] [--amount AMOUNT]
{get-member,register-member,register-member-verify,get-market,create-market,create-market-verify,get-actor,join-market,join-market-verify,get-channel,open-channel,close-channel}
positional arguments:
{get-member,register-member,register-member-verify,get-market,create-market,create-market-verify,get-actor,join-market,join-market-verify,get-channel,open-channel,close-channel}
Command to run
optional arguments:
-h, --help show this help message and exit
-d, --debug Enable debug output.
--url URL The router URL (default: "wss://planet.xbr.network/ws").
--realm REALM The realm to join (default: "xbrnetwork").
--ethkey ETHKEY Private Ethereum key (32 bytes as HEX encoded string)
--cskey CSKEY Private WAMP-cryptosign authentication key (32 bytes as HEX encoded string)
--username USERNAME For on-boarding, the new member username.
--email EMAIL For on-boarding, the new member email address.
--market MARKET For creating new markets, the market UUID.
--market_title MARKET_TITLE
For creating new markets, the market title.
--market_label MARKET_LABEL
For creating new markets, the market label.
--market_homepage MARKET_HOMEPAGE
For creating new markets, the market homepage.
--provider_security PROVIDER_SECURITY
--consumer_security CONSUMER_SECURITY
--market_fee MARKET_FEE
--marketmaker MARKETMAKER
For creating new markets, the market maker address.
--actor_type {1,2,3} Actor type: PROVIDER = 1, CONSUMER = 2, PROVIDER_CONSUMER (both) = 3
--vcode VCODE For verifications of actions, the verification UUID.
--vaction VACTION For verifications of actions (on-board, create-market, ..), the verification code.
--channel CHANNEL For creating new channel, the channel UUID.
--channel_type {1,2} Channel type: Seller (PAYING) = 1, Buyer (PAYMENT) = 2
--delegate DELEGATE For creating new channel, the delegate address.
--amount AMOUNT Amount to open the channel with. In tokens of the market coin type, used as means of payment in the market of
the channel.
Crypto Wallet
.............
XBR is based on the `Ethereum blockchain <https://ethereum.org/>`__, and all XBR data markets, market operators
and actors (buyers & sellers) in markets are registered on the Ethereum blockchain.
.. note::
Currently, XBR is still in alpha, and the latest version is XBR v20.5.1 deployed on Rinkeby testnet.
XBR will be deployed on mainnet with the official stable release.
Market operators and market actors (buyers & sellers) maintain their (potentially anonymous) identity
via crypto wallets where the private wallet key is under exclusive access to the operator or actor.
Running your own crypto wallet is easy using `MetaMask <https://metamask.io/>`__, a browser plugin that runs
in Chrome and Firefox.
First step is to install MetaMask, creating a new wallet:
.. thumbnail:: _static/screenshots/xbr-metamask-1.png
and connect to `Rinkeby testnet <https://www.rinkeby.io/>`__:
.. thumbnail:: _static/screenshots/xbr-metamask-2.png
Then, to use your Ethereum private key with the XBR CLI, export the private key:
.. thumbnail:: _static/screenshots/xbr-metamask-3.png
When using the XBR CLI, you can provide your Ethereum private key using the command line argument ``--ethkey=0x``
appended with your key:
.. code-block:: console
--ethkey=0x4C1F...
You can also persistently store your Ethereum private key in the CLI configuration file for one of the user
profiles you have there:
.. code-block:: console
$ cat ${HOME}/.xbrnetwork/config.ini
[default]
# user private Ethereum key
ethkey=0x4C1F...
.. note::
Obviously, you must protect your *private key*! The *public address* of your wallet is not security
sensitive. Even the public address however should always be treated carefully regarding privacy. When you
store your private key in the CLI configuration file, make sure to protect this file using
``chmod 600 ${HOME}/.xbrnetwork/config.ini``.
Finally, for testing on Rinkeby, get yourself some Ether from the `Rinkeby faucet <https://faucet.rinkeby.io/>`__:
.. thumbnail:: _static/screenshots/rinkeby-faucet.png
If you want to use the accounts from your MetaMask wallet derived from your wallet's seedphrase, you can
use a helper included with Autobahn to derive private keys for all accounts, eg account `0`:
.. code-block:: console
>>> from autobahn.xbr import account_from_seedphrase
>>> acct = account_from_seedphrase('myth like bonus scare over problem client lizard pioneer submit female collect', 0)
>>> acct.address
'0x90F8bf6A479f320ead074411a4B0e7944Ea8c9C1'
>>> acct.privateKey.hex()
'0x4f3edf983ac636a65a842ce7c78d9aa706d3b113bce9c46f30d7d21715b23b1d'
>>>
Client Key
..........
To connect to the XBR Network using the XBR CLI, the client (which connects via WAMP) needs a client private
key (used for WAMP-cryptosign authentication).
A new key can be created by generating 32 random bytes:
.. code-block:: console
$ openssl rand -hex 32
ecdc5e97...
When using the XBR CLI, provide your WAMP client private key using the command line argument ``--cskey=0x`` appended
with your key:
.. code-block:: console
--cskey=0xecdc5e97...
You can also persistently store your WAMP client private key in the CLI configuration file for one of the user
profiles you have there:
.. code-block:: console
$ cat ${HOME}/.xbrnetwork/config.ini
[default]
# user private WAMP client key
cskey=0xecdc5e97...
.. note::
Obviously, you must protect your *private key*! The *public key* of WAMP client key pair is not security
sensitive. Even the public key however should always be treated carefully regarding privacy. When you
store your private key in the CLI configuration file, make sure to protect this file using
``chmod 600 ${HOME}/.xbrnetwork/config.ini``.
CLI User Profile
----------------
The CLI maintains a local user configuration file in ``${HOME}/.xbrnetwork/config.ini``.
The configuration file will contain at least one (CLI) user profile.
To create a new CLI configuration file and user profile:
.. code-block:: console
$ xbrnetwork
created new local user directory /home/oberstet/.xbrnetwork
creating new user profile "default"
enter a XBR data market URL: wss://markets.international-data-monetization-award.com/ws
enter the WAMP realm of the XBR data market: idma
your private Etherum key: 0x4C1F7...
your private WAMP client key: 0x7e8f...
your Infura gateway key: 40c69...
your Infura gateway secret: 55119...
created new local user configuration /home/oberstet/.xbrnetwork/config.ini
user profile "default" loaded
Not a member yet
----------------
Before you have registered in the XBR Network, this is what you get:
.. code-block:: console
$ xbrnetwork get-member
.. thumbnail:: _static/screenshots/xbr-cli-not-a-member-yet.png
On-boarding
-----------
To on-board and register in the XBR Network using the CLI, submit a request providing your Ethereum private key, your
client key, as well as your username and email:
.. code-block:: console
$ xbrnetwork register-member \
--cskey=0x7e8f... \
--ethkey=0x4C1F7... \
--username=oberstet5 \
--email=tobias.oberstein@gmail.com
.. note::
Of course, neither your username nor your email is stored on-chain (on the blockchain). Your email is required so that
we can send a verification code to you (see next step).
This is what you should see:
.. code-block:: console
(cpy382_1) oberstet@intel-nuci7:~/scm/crossbario/autobahn-python$ xbrnetwork register-member \
> --username=oberstet6 \
> --email=tobias.oberstein@gmail.com
2020-06-05T18:23:18+0200 XBR CLI v20.6.1
2020-06-05T18:23:18+0200 Profile default loaded from /home/oberstet/.xbrnetwork/config.ini
2020-06-05T18:23:18+0200 Connecting to "wss://planet.xbr.network/ws" at realm "xbrnetwork" ..
2020-06-05T18:23:18+0200 Client Ethereum key loaded, public address is 0x66290fA8ADcD901Fd994e4f64Cfb53F4c359a326
2020-06-05T18:23:18+0200 Client WAMP authentication key loaded, public key is 0x7172c38631864153e16f4db7a4a7ff0e2fbe7a180591d28d60e909d77d644964
2020-06-05T18:23:18+0200 Client connected, now joining realm "xbrnetwork" with WAMP-cryptosign authentication ..
2020-06-05T18:23:18+0200 Ok, client joined on realm "xbrnetwork" [session=3664895410309954, authid="anonymous-T3WJ-LLHN-AYFW-64WP-TXPM-W53F", authrole="anonymous"]
2020-06-05T18:23:18+0200 not yet a member in the XBR network
2020-06-05T18:23:20+0200 On-boarding member - verification "dc65d1e9-2387-4226-a1dc-d50f80531574" created
2020-06-05T18:23:20+0200 Client left realm (reason="wamp.close.normal")
2020-06-05T18:23:20+0200 Client disconnected
2020-06-05T18:23:20+0200 Main loop terminated.
You should receive an email with a verification action ID such as ``072061e8-d1b4-4988-9524-6873b4d5784e`` and
a verification code such as ``5QRM-R5KR-7PGU``.
Verify the on-boarding request using the verification action and code:
.. code-block:: console
$ xbrnetwork register-member-verify \
--vaction=dc65d1e9-2387-4226-a1dc-d50f80531574 \
--vcode=A346-GJLE-64SW
This is what you should see:
.. code-block:: console
$ xbrnetwork register-member-verify \
> --vaction=dc65d1e9-2387-4226-a1dc-d50f80531574 \
> --vcode=A346-GJLE-64SW
2020-06-05T18:27:08+0200 XBR CLI v20.6.1
2020-06-05T18:27:08+0200 Profile default loaded from /home/oberstet/.xbrnetwork/config.ini
2020-06-05T18:27:08+0200 Connecting to "wss://planet.xbr.network/ws" at realm "xbrnetwork" ..
2020-06-05T18:27:08+0200 Client Ethereum key loaded, public address is 0x66290fA8ADcD901Fd994e4f64Cfb53F4c359a326
2020-06-05T18:27:08+0200 Client WAMP authentication key loaded, public key is 0x7172c38631864153e16f4db7a4a7ff0e2fbe7a180591d28d60e909d77d644964
2020-06-05T18:27:08+0200 Client connected, now joining realm "xbrnetwork" with WAMP-cryptosign authentication ..
2020-06-05T18:27:08+0200 Ok, client joined on realm "xbrnetwork" [session=8735495987511209, authid="anonymous-N7PW-H7F7-TPCP-ATFP-9X49-GA9C", authrole="anonymous"]
2020-06-05T18:27:08+0200 not yet a member in the XBR network
2020-06-05T18:27:08+0200 Verifying member using vaction_oid=dc65d1e9-2387-4226-a1dc-d50f80531574, vaction_code=A346-GJLE-64SW ..
2020-06-05T18:27:08+0200 SUCCESS! New XBR Member onboarded: member_oid=ab4dd6fd-6250-4cda-81ba-97f7d52ceac9, result=
{'created': 1591374428420644124,
'member_oid': b'\xabM\xd6\xfdbPL\xda\x81\xba\x97\xf7\xd5,\xea\xc9',
'transaction': b'\xa4\xa7W\xfe"\x16\xe1l\x9f\xe0\xf7\x18\x8ak\xeb\xba'
b'J\xd5S\xb6\xd9\x99\x9d\x96\xce\x1c\xbcw1\xcd\xec%'}
2020-06-05T18:27:08+0200 Client left realm (reason="wamp.close.normal")
2020-06-05T18:27:08+0200 Client disconnected
2020-06-05T18:27:08+0200 Main loop terminated.
To access your new XBR Network member profile, run:
.. code-block:: console
$ xbrnetwork get-member
This is what you should see:
.. code-block:: console
$ xbrnetwork get-member
2020-06-05T18:28:38+0200 XBR CLI v20.6.1
2020-06-05T18:28:38+0200 Profile default loaded from /home/oberstet/.xbrnetwork/config.ini
2020-06-05T18:28:38+0200 Connecting to "wss://planet.xbr.network/ws" at realm "xbrnetwork" ..
2020-06-05T18:28:38+0200 Client Ethereum key loaded, public address is 0x66290fA8ADcD901Fd994e4f64Cfb53F4c359a326
2020-06-05T18:28:38+0200 Client WAMP authentication key loaded, public key is 0x7172c38631864153e16f4db7a4a7ff0e2fbe7a180591d28d60e909d77d644964
2020-06-05T18:28:38+0200 Client connected, now joining realm "xbrnetwork" with WAMP-cryptosign authentication ..
2020-06-05T18:28:38+0200 Ok, client joined on realm "xbrnetwork" [session=6918284698412513, authid="member-ab4dd6fd-6250-4cda-81ba-97f7d52ceac9", authrole="member"]
2020-06-05T18:28:39+0200 Member found:
{'address': '0x66290fA8ADcD901Fd994e4f64Cfb53F4c359a326',
'balance': {'eth': Decimal('0.199585784'), 'xbr': 0},
'catalogs': 0,
'created': numpy.datetime64('2020-06-05T16:27:08.420644124'),
'domains': 0,
'email': 'tobias.oberstein@gmail.com',
'eula': 'QmeHTWw717jPEF6aJqhNMrXx4KLrDiTHi5m7gfbjA1BqMj',
'level': 'ACTIVE',
'markets': 0,
'oid': UUID('ab4dd6fd-6250-4cda-81ba-97f7d52ceac9'),
'profile': 'QmV1eeDextSdUrRUQp9tUXF8SdvVeykaiwYLgrXHHVyULY',
'username': 'oberstet6'}
2020-06-05T18:28:39+0200 Client left realm (reason="wamp.close.normal")
2020-06-05T18:28:39+0200 Client disconnected
2020-06-05T18:28:39+0200 Main loop terminated.
XBR Token Transfer
------------------
When doing ``xbrnetwork get-member``, the information returned will include both your current on-chain ETH balance,
as well as your balance of XBR Token (which is one coin that can be used as a market-payment-coin in markets
configured to use XBR as a means of payment).
Transfering XBR tokens looks like this
.. thumbnail:: _static/screenshots/xbr-token-transfer.png
This transfer of 1000 XBR to some target address did cost 0.001541 ETH (or 0.33 EUR) on Rinkeby testnet.
After the transfer (to that member), the member information returned will look like this:
.. thumbnail:: _static/screenshots/xbr-token-transfer-after.png
Getting market information
--------------------------
To get information about an existing XBR data market:
.. code-block:: console
$ xbrnetwork get-market \
--market=1388ddf6-fe36-4201-b1aa-cb7e36b4cfb3
Creating a market
-----------------
To create a new XBR data market, generate a new market UUID:
.. code-block:: console
$ /usr/bin/uuidgen
394205e5-5d3d-4eab-a7e8-6c4de21bc76d
.. code-block:: console
xbrnetwork create-market \
--market 394205e5-5d3d-4eab-a7e8-6c4de21bc76d \
--market_title "IDMA test market 1" \
--market_label "idma-market1" \
--market_homepage https://markets.international-data-monetization-award.com/market1 \
--provider_security 0 \
--consumer_security 0 \
--market_fee 0 \
--marketmaker 0x163D58cE482560B7826b4612f40aa2A7d53310C4
.. code-block:: console
$ xbrnetwork create-market \
> --market 394205e5-5d3d-4eab-a7e8-6c4de21bc76d \
> --market_title "IDMA test market 1" \
> --market_label "idma-market1" \
> --market_homepage https://markets.international-data-monetization-award.com/market1 \
> --provider_security 0 \
> --consumer_security 0 \
> --market_fee 0 \
> --marketmaker 0x163D58cE482560B7826b4612f40aa2A7d53310C4
2020-06-05T20:54:47+0200 XBR CLI v20.6.1
2020-06-05T20:54:47+0200 Profile default loaded from /home/oberstet/.xbrnetwork/config.ini
2020-06-05T20:54:47+0200 Connecting to "wss://planet.xbr.network/ws" at realm "xbrnetwork" ..
2020-06-05T20:54:48+0200 Client Ethereum key loaded, public address is 0x66290fA8ADcD901Fd994e4f64Cfb53F4c359a326
2020-06-05T20:54:48+0200 Client WAMP authentication key loaded, public key is 0x7172c38631864153e16f4db7a4a7ff0e2fbe7a180591d28d60e909d77d644964
2020-06-05T20:54:48+0200 Client connected, now joining realm "xbrnetwork" with WAMP-cryptosign authentication ..
2020-06-05T20:54:48+0200 Ok, client joined on realm "xbrnetwork" [session=6290962938304946, authid="member-ab4dd6fd-6250-4cda-81ba-97f7d52ceac9", authrole="member"]
2020-06-05T20:54:49+0200 Total markets before: 3
2020-06-05T20:54:49+0200 Market for owner: 0
2020-06-05T20:54:55+0200 SUCCESS: Create market request submitted:
{'action': 'create_market',
'timestamp': 1591383295497514499,
'vaction_oid': b'\x14\xd5\xe8\xf8\x0f\x9aM\\\x97{\xbd4\x159\xf1\xba'}
2020-06-05T20:54:55+0200 SUCCESS: New Market verification "14d5e8f8-0f9a-4d5c-977b-bd341539f1ba" created
2020-06-05T20:54:55+0200 Client left realm (reason="wamp.close.normal")
2020-06-05T20:54:55+0200 Client disconnected
2020-06-05T20:54:55+0200 Main loop terminated.
Joining a market
----------------
To join a XBR data market, you will need the XBR data market ID, such as ``1388ddf6-fe36-4201-b1aa-cb7e36b4cfb3``
(which is the IDMA test market).
Here is how to join as an actor in that market as both a buyer and seller:
.. code-block:: console
$ xbrnetwork join-market \
--market=1388ddf6-fe36-4201-b1aa-cb7e36b4cfb3 \
--actor_type=3
You will receive an email with a verification action ID and a verification code. Submit these
to complete joining the market:
.. code-block:: console
xbrnetwork join-market-verify \
--vaction=ddcd5452-28cc-4ecb-a0f3-8fc8b596f9a5 \
--vcode=AGGA-PK6G-57NY
To access your actor status in a market, run:
.. code-block:: console
$ xbrnetwork get-actor \
--market=1388ddf6-fe36-4201-b1aa-cb7e36b4cfb3
Opening a channel
-----------------
|