Friday, 1 August 2014

Setting up a Stellar trust line

Recently Stellar, a decentralized protocol for sending and receiving money in any pair of currencies, was announced. I decided to have a play around (because why not?). A core concept to Stellar is that of a gateway; an individual or organisation that takes a deposit (in 'real' currency) and credits you on the network.

Coinex are a New Zealand-based gateway, and are the first gateway for Stellar; they put up a challenge to be the first person to use them as a gateway (which I won!). To do this, you have to say that you trust that gateway to hold a particular amount of currency; in this case I wanted to publish the fact that I trust Coinex to hold up to $20 NZD for me.

To do this, you'll need to interact directly with the API (Stellar clients are still playing catch-up), and submit the following JSON:
{
    "method": "submit",
    "params": [
        {
            "secret": "<SECRET>",
            "tx_json": {
                "TransactionType": "TrustSet",
                "Account": "<your Stellar address>",
                "LimitAmount": {
                    "value": "<the amount you trust the issuer to hold>",
                    "currency": "<the currency the issuer will hold>",
                    "issuer": "<the issuer's Stellar address>"
                }
            }
        }
    ]
}
You can find <SECRET> on your Stellar settings page; everything else will obviously depend on what you're trying to do.

WARNING: POSTing your secret to live.stellar.org is potentially insecure; you would be better off signing requests locally; a blog post on this may be forthcoming.

You'll then need to POST this to the API:
curl -X POST https://live.stellar.org:9002 -d'<JSON>'
There's a bug in Stellar that means that newlines and/or indentation cause problems, so you'll need to make the above JSON just a single line and slot it in to the above command line.

Once you run that, you're done!