Skip to content

Instantly share code, notes, and snippets.

@tolitius
Last active April 16, 2018 20:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tolitius/4b8e217ec413f38bc083791b0572e29e to your computer and use it in GitHub Desktop.
Save tolitius/4b8e217ec413f38bc083791b0572e29e to your computer and use it in GitHub Desktop.
TIL: Today I Learned

what is it?

Chariot wants you to learn a basic idea about what the blockchain is made of. The only way to learn it is to use it: really.

Hence here is what we offer you, proud Charioteer:

You can get any educational materials such as ebooks, books, online courses, etc. and reimburse all or some of its cost by using the new and shiny Chariot cryptocurrency.

You do it by creating a Stellar account via BB-8 (instructions below), we will fill it with a "Today I Learned" or TIL tokens and any time you come accross something you like to learn that costs money you can send a corresponding number of TILs back to Chariot and get reimbursed.

how do I do it?

These are the 4 things that need to be done to get you up and running loaded with cash:

4 steps to get TIL

All examples are below and based on BB-8 which is a command line interface to Stellar networks.

In case you are not a developer (and only in that case). Please let me know, and I'll create an account for you filled with TIL cryptocurrency.

current rate

a TIL is a steal at:

1 USD (US Dollar) = 840 TIL (Today I Learned)

TIL to USD

$ bb gen-keys ~/.stellar/john_malkovich

~/.stellar is just an example, you can save your keys elsewhere

choosing Stellar network

By default BB-8 will run on the Stellar's testnet (a test network).

Since we are "for real", run all the examples on the public network by exporting STELLAR_NETWORK:

export STELLAR_NETWORK=public

there are also other ways to choose networks, including custom ones, but exporting STELLAR_NETWORK is the easiest for this exercise.

creating Stellar account

Once you have a pair of account keys, give me the public key, so I can create an account for you since it costs a couple of XLMs.

In case you have XLMs or/and would like to create an account yourself, you can do it with bb create-account

trusting Chariot's TIL

Once your account is created, you should add a trustline for the TIL token. Here is more about trustlines.

bb change-trust -s '{"source_account": "'$(cat ~/.stellar/your-private-key)'",
                     "code": "TIL",
                     "limit": "42000",
                     "issuer": "bb8*dotkam.com"}'

after this step is done, let me know and I'll send you 42,000 TILs from the Chariot account

At this point your account is created, you have your account keys and you have mad TIL funds.

In order to expense an ebook, a paper book or an online course (any thing that costs money and relates to education) you need to do two things:

  • send a corresponding number of TIL tokens back to Chariot
  • send a receipt for the e/book/course back to Chariot (via email)

sending TILs back to Chariot

42.00 is an example amount:

$ bb send-payment -s '{"to": "chariot*dotkam.com",
                       "token": "TIL",
                       "amount": "42.00",
                       "issuer": "bb8*dotkam.com"}'
2018/04/09 00:33:30 sending 42.00 TIL from anatoly*dotkam.com to chariot*dotkam.com
2018/04/09 00:33:30 submitting transaction to horizon at https://horizon.stellar.org

which will forever stay on the ledger which is one of the points of this exercise.

without defaults set

In case your didn't "Set Default Address and Seed", the above command won't work as you need to sign it with your private key explicitly:

$ bb send-payment -s '{"from": "'$(cat ~/.stellar/your-private-key)'"
                       "to": "chariot*dotkam.com",
                       "token": "TIL",
                       "amount": "42.00",
                       "issuer": "bb8*dotkam.com"}'

to summarize:

  • get your education materials anywhere for USD
  • send to Chariot two things:
    • a corresponding number of TIL (according to the current TIL to USD rate)
    • the actual receipt
  • Chariot will reimbuse you with USD

In order to see your account balances you can either use something like:

Browser

Stellar Expert by:

https://stellar.expert/explorer/public/account/your-account-address

BB-8 by account address

or by using BB-8's load-account command with an actual account address:

$ bb load-account GD3X327V6EAJS7H6KWPDWX3ZM4CYSF73Y2FPXCUSEWVV3VLAZILWHEEL | jq '.balances'
[{
    "balance": "2058000.0000000",
    "limit": "2100000.0000000",
    "asset_type": "credit_alphanum4",
    "asset_code": "TIL",
    "asset_issuer": "GBKOPETTWWVE7DM72YOVQ4M2UIY3JCKDYQBTSNLGLHI6L43K7XPDROID"
  },
  {
    "balance": "3.0000625",
    "asset_type": "native"
  }]

BB-8 by federation address

or by using BB-8's load-account command with an actual account federation address:

$ bb load-account "chariot*dotkam.com" | jq '.balances'
[{
    "balance": "2058000.0000000",
    "limit": "2100000.0000000",
    "asset_type": "credit_alphanum4",
    "asset_code": "TIL",
    "asset_issuer": "GBKOPETTWWVE7DM72YOVQ4M2UIY3JCKDYQBTSNLGLHI6L43K7XPDROID"
  },
  {
    "balance": "3.0000625",
    "asset_type": "native"
  }]

You can read about federations in BB-8 docs and in Stellar docs.

In order to be able to use your federation address, add a home_domain to your account by set-option command:

$ bb set-options -s '{"source_account": "'$(cat ~/.stellar/your-private-key)'",
                      "home_domain": "dotkam.com"}'

This will let Stellar know how to resolve "your_name*dotkam.com" to the account address.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment