Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
Simple steps to start a Stellar Gateway

You can become your own gateway in two simple steps! Here we'll show how easy it is to issue your own currency on the Stellar network.

Extending trust & issuing credit

1: A user extends trust to your gateway account for a "maximum" amount of your currency. Remember, they're trusting you'll honor whatever your currency represents when they give it back to you.

$ curl -X POST https://test.stellar.org:9002  -d '
{
    "method": "submit",
    "params": [
        {
            "secret": "<USER_SECRET>",
            "tx_json": {
                "Account": "<USER_ACCOUNT>",
                "LimitAmount": {
                    "currency": "USD",
                    "issuer": "<GATEWAY_ACCOUNT>",
                    "value": 30
                },
                "TransactionType": "TrustSet"
            }
        }
    ]
}
'

2: Now, you'll issue your credits (currency) to the user (presumably after they've given you something in the real world!).

$ curl -X POST https://test.stellar.org:9002  -d '
{
    "method": "submit",
    "params": [
        {
            "secret": "<GATEWAY_SECRET>",
            "tx_json": {
                "Account": "<GATEWAY_ACCOUNT>",
                "Amount": {
                    "currency": "USD",
                    "issuer": "<GATEWAY_ACCOUNT>",
                    "value": 30
                },
                "Destination": "<USER_ACCOUNT>",
                "TransactionType": "Payment"
            }
        }
    ]
}
'

heeton commented Jul 31, 2014

This url is old, I think https://test.stellar.org or https://live.stellar.org work

Owner

thejollyrogers commented Jul 31, 2014

Thanks heeton, fixed.

heeton commented Aug 1, 2014

Are you sure? testnet.stellar.org results in Could not resolve host: testnet.stellar.org

heeton commented Aug 1, 2014

I'm assuming there is some sort of special Gateway account needed? I've tried this with about a dozen different combinations of normal account credentials and Source account not found is the furthest I can get.

EDIT: Looks like test accounts get wiped every so often? I got a single request to work, subsequent ones show that the account is gone...

EDIT2: Yep, live accounts work and stick around.

do we have something similar to rippled ?

Thanks for sharing these scripts. And now I am wondering, is there away for the <USER_ACCOUNT> to requests redemption to the <GATEWAY_ACCOUNT> of the issued credit?

EDIT: I think I figured out. It's just sending a payment back from the <USER_ACCOUNT> to the <GATEWAY_ACCOUNT> for the amount issued. There is a video showing this proccess in Ripple: https://www.youtube.com/watch?v=ti9QYSADWeQ

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