You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

100 lines
2.8 KiB

  1. **OUTDATED**
  2. # Using with lightclient
  3. We have an awesome cluster running, let's try to test this out without
  4. relying on executing commands on the cluster. Rather, we can connect to the
  5. rpc interface with the `light-client` package and execute commands locally,
  6. or even proxy our webapp to the kubernetes backend.
  7. ## Setup
  8. In order to get this working, we need to know a few pieces of info,
  9. the chain id of tendermint, the chain id of basecoin, and an account
  10. with a bit of cash....
  11. ### Tendermint Chain ID
  12. `kubectl exec -c tm tm-0 -- curl -s http://tm-1.basecoin:46657/status | json_pp | grep network`
  13. set TM_CHAIN with the value there
  14. ### Basecoin Chain ID
  15. `kubectl exec -c app tm-1 -- grep -A1 chainID /app/genesis.json`
  16. set BC_CHAIN with the value there
  17. ### Expose tendermint rpc
  18. We need to be able to reach the tendermint rpc interface from our shell.
  19. `kubectl port-forward tm-0 46657:46657`
  20. ### Start basecoin-proxy
  21. Using this info, let's connect our proxy and get going
  22. `proxy-basecoin -tmchain=$TM_CHAIN -chain=$BC_CHAIN -rpc=localhost:46657`
  23. ## Basecoin accounts
  24. Well, we can connect, but we don't have a registered account yet...
  25. Let's look around, then use the cli to send some money from one of
  26. the validators to our client's address so we can play.
  27. **TODO** we can add some of our known accounts (from `/keys`) into
  28. the genesis file, so we can skip all the kubectl money fiddling here.
  29. We will want to start with money on some known non-validators.
  30. ### Getting validator info (kubectl)
  31. The basecoin app deployment starts with 1000 "blank" coin in an account of
  32. each validator. Let's get the address of the first validator
  33. `kubectl exec -c app tm-1 -- grep address /app/key.json`
  34. Store this info as VAL1_ADDR
  35. ### Querying state (proxy)
  36. The proxy can read any public info via the tendermint rpc, so let's check
  37. out this account.
  38. `curl localhost:8108/query/account/$VAL1_ADDR`
  39. Now, let's make out own account....
  40. `curl -XPOST http://localhost:8108/keys/ -d '{"name": "k8demo", "passphrase": "1234567890"}'`
  41. (or pick your own user and password). Remember the address you get here. You can
  42. always find it out later by calling:
  43. `curl http://localhost:8108/keys/k8demo`
  44. and store it in DEMO_ADDR, which is empty at first
  45. `curl localhost:8108/query/account/$DEMO_ADDR`
  46. ### "Stealing" validator cash (kubectl)
  47. Run one command, that will be signed, now we have money
  48. `kubectl exec -c app tm-0 -- basecoin tx send --to <k8demo-address> --amount 500`
  49. ### Using our money
  50. Returning to our remote shell, we have a remote account with some money.
  51. Let's see that.
  52. `curl localhost:8108/query/account/$DEMO_ADDR`
  53. Cool. Now we need to send it to a second account.
  54. `curl -XPOST http://localhost:8108/keys/ -d '{"name": "buddy", "passphrase": "1234567890"}'`
  55. and store the resulting address in BUDDY_ADDR
  56. **TODO** finish this