-
Notifications
You must be signed in to change notification settings - Fork 12
Testing Yoroi and Cardano wallet
(These notes used as starting point a document by Alfredo di Napoli)
Runs 3 core nodes and 1 wallet and generates a fresh blockchain all the time.
It's handy as it comes with a wallet called the "Genesis wallet" which can be used to test the various features without worrying about money.
On the other hand, the staging cluster has the advantage of targeting a "semi-realistic" blockchain (especially in size) but stake cannot be created out of thin air.
In order to test transactions on this blockchain, IOHK developers share a bunch of staging wallets for testing on this chain. For that, see the test wallet worksheet to claim and use wallets:
https://docs.google.com/spreadsheets/d/1CN69eb48Ww9jciBE4ZKE0y7JyLQi7lP4nxY5-FHz6k0/edit#gid=0
(if you create new wallets and transfer funds to them, add the wallet details to this sheet so that other devs can test with those funds in future since ADA on staging is a limited resource)
This guide will focus on testing using the staging cluster.
The Yoroi wallet is packaged as a Chrome Browser plugin. This does not give us an easy handle to test cardano wallets against Yoroi wallets. Instead of using Yoroi directly, we can rely on the underlying command-line for Cardano - cardano-cli.
To use this command line, you'll need to install Rust lang. Then install cardano-cli:
git clone https://github.com/input-output-hk/cardano-cli.git --recursive
cd cardano-cli
cargo install
(There are cardano-cli tutorials here: https://cardanorust.iohkdev.io/cli-wallet/)
Use one of staging/mainnet/testnet:
cardano-cli blockchain new staging --template=staging
cardano-cli blockchain pull staging
There is also a fast fetch, but this is still experimental code, try with caution:
cardano-cli blockchain remote-fetch staging hermes # to kill when 1s remain
You can check the status of the blockchain with
cardano-cli blockchain status staging
Note the 12 word mnemonic and random_index_2levels for Daedelus wallets. We need to name the new wallet (TestWallet in this case).
cardano-cli wallet recover --daedalus-seed --derivation-scheme=v1 --mnemonics-length=12 --wallet-scheme=random_index_2levels TestWallet
You will need to enter the wallet's 12-word mnemonic along with a spending password.
Next we attach the wallet to our staging blockchain and then catch the wallet up with the chain using sync:
cardano-cli wallet attach TestWallet staging
cardano-cli wallet sync TestWallet
You can check the status (including balance) of the wallet with
cardano-cli wallet status TestWallet
We can now also see a statement of all transactions for this wallet:
cardano-cli wallet statement TestWallet
and to see the wallet utxo:
cardano-cli wallet utxos TestWallet
- Follow the steps above to install and setup the
cardano-cli - Run
$ cardano-cli wallet create myWallet - Run
$ cardano-cli wallet attach myWallet mainnet(provided there's a blockchain created namedmainnet) - Run
$ cardano-cli wallet address 0 0to generate an address with account index 0' and address index 0 - Note that, addresses are by default, generated on the external chain and addresses can be generated on the internal chain by passing
--internalto the command above.
stack build cardano-node --ghc-options=-optl-Wl,-dead_strip_dylibs
If you are not an a Mac, you can ignore the --ghc-options being passed here.
Before running the node we need to generate some TLS certs. This is important so
that Daedalus and the node agrees on the https certs and can communicate securely.
Daedalus doesn't support querying the node from plain "http", so this is required,
moreover if you want to enable "client side authentication", but we are not going to
enable client-side auth, so that you can also query the node easily via the
web browser.
We can do this with the cardano-x509-certificates tool:
stack build cardano-sl-tools --ghc-options=-optl-Wl,-dead_strip_dylibs
stack exec cardano-x509-certificates -- --server-out-dir ../tls-certs --clients-out-dir ../tls-certs -k default -c lib/configuration.yaml
The --no-client-auth option is very important to disable client-side TLS verification.
stack exec cardano-node -- --topology=docs/network/example-topologies/mainnet-staging.yaml \
--configuration-key mainnet_dryrun_full \
--db-path ../staging-db \
--tlscert ../tls-certs/server.crt \
--tlskey ../tls-certs/server.key \
--tlsca ../tls-certs/ca.crt \
--no-client-auth
Note: Here I'm using an explicit --db-path at a directory of choice so that I will go
through the pain of syncing with the blockchain only once. It's important you use the same
RocksDB name across multiple runs, unless you want to test other things like syncing or
wallet restoration on a partially-synced node.
Note that you cannot operate Daedalus if you are more than 6 blocks behind the BlockChain.
If all is well, now you should be able to query successfully from the browser these two endpoints:
GET https://localhost:8090/api/v1/node-infoGET https://localhost:8090/docs/v1/index/
Now that you have a node running talking to staging it's time for Daedalus.
These instructions works out of the box on a Mac, but for Linux things are more complicated. Talk to devops on how to run Daedalus on Linux.
In order to run Daedalus, you have to:
-
Clone the Daedalus repo
-
(Optional) Install the Node Version Manager. This is a simple bash script which allows you to install and manage multiple versions of node, both globally and (important), locally. I usually use Node
8.2.1in the Daedalus repo. You can have a.nvmrcin the Daedalus repo with content:8.2.1And then simply typing
nvm usewill drop you in a shell with the right version. -
Run
npm installinside the Daedalus repo.If this steps fails due to python2 not being present, you can solve it with a tool likepyenv, which is basically likenvm. Google for it! -
Finally run:
CARDANO_TLS_PATH=/Users/.../tls-certs yarn run devNote that obviously the filepath to the
tls-certsis what I (Alfredo) use, but you will have to specify thetls-certsfolder you created using thecardano-x509-certificatestool.
If all is well, Daedalus should appear and you should see the white screen of
syncing. If it stays on the blue one, something is not working as it should.
Check out the cardano-node logs or the "Developer Tools" in the Electron app.