Skip to content

Instantly share code, notes, and snippets.

@gdb
Last active October 13, 2018 20:30
Show Gist options
  • Save gdb/70efc16fb432601acd33 to your computer and use it in GitHub Desktop.
Save gdb/70efc16fb432601acd33 to your computer and use it in GitHub Desktop.
Notes from Stellar dev meetup

Stellar meetup notes

These are the public notes from the live demo at http://www.meetup.com/Stellar-Developers-Space-Camp/events/199384122/.

If you come here during the talk, you'll probably want to scroll down to Accepting my $1 offer.

Account introspection tools

You can use one of the webviewers to look at an account:

Or use curl:

$ curl -X POST https://live.stellar.org:9002 -d \
'{"method":"account_tx","params":[{"account":"gUzSF7j4toeoxiibijxdey9UbZGawur1yQ"}]}'

Creating a new address

You can also create an address manually:

curl -X POST https://live.stellar.org:9002/ -d \
'{ "method" : "create_keys" }'

(If you want to be fully paranoid, you could instead generate a cold wallet.)

Setting trust

stellar('submit', secret: NEW_SECRET, tx_json: {Account: NEW_ACCOUNT, TransactionType: 'TrustSet', LimitAmount: {currency: 'USD', value: 1, issuer: OLD_ACCOUNT}})

Sending a credit

The following command issues 1 USD credit (issued by OLD_ACCOUNT) to NEW_ACCOUNT:

stellar('submit', secret: OLD_SECRET, tx_json: {TransactionType: 'Payment', Account: OLD_ACCOUNT, Amount: {currency: 'USD', value: 1, issuer: OLD_ACCOUNT}, Destination: NEW_ACCOUNT})

Trading away a credit

The following credit trades away an existing credit (offering 1 USD from OLD_ACCOUNT in exchange for 300 STR):

stellar('submit', secret: NEW_SECRET, tx_json: {Account: NEW_ACCOUNT, TransactionType: 'OfferCreate', TakerPays: 300 * 1_000_000, TakerGets: {value: 1, currency: 'USD', issuer: OLD_ACCOUNT}})

Viewing pending offers

You can see pending offers on the network using the following:

$ curl https://live.stellar.org:9002 -d \
'{
  "method": "book_offers",
  "params": [
    {
      "taker_gets": {
        "currency": "USD",
        "issuer": "gUzSF7j4toeoxiibijxdey9UbZGawur1yQ"
      },
      "taker_pays": {
        "currency": "STR"
      }
    }
  ]
}'

Accepting my $1 offer

As part of the demo, I've offered $1 on Stellar's distributed exchange.

You need to make an offer that crosses over my existing offer on the exchange. Fill in YOUR_SECRET and YOUR_ACCOUNT below — note YOUR_ADDRESS must be your actual address, not your username. (See http://gdb.github.io/stellarjob/#instructions for help finding your secret and account.)

$ curl https://live.stellar.org:9002 -d \
'{
  "method": "submit",
  "params": [
    {
      "secret": "<YOUR_SECRET>",
      "tx_json": {
        "Account": "<YOUR_ADDRESS>",
        "TransactionType": "OfferCreate",
        "TakerGets": 300000000,
        "TakerPays": {
          "value": 1,
          "currency": "USD",
          "issuer": "gUzSF7j4toeoxiibijxdey9UbZGawur1yQ"
        }
      }
    }
  ]
}'

Via my stellar helper, this looks like:

stellar('submit', secret: YOUR_SECRET, tx_json: {Account: YOUR_ACCOUNT, TransactionType: 'OfferCreate', TakerGets: 300 * 1_000_000, TakerPays: {value: 1, currency: 'USD', issuer: OLD_ACCOUNT}})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment