Stellar news delivered weekly:

Pay on Stellar using Stellar Burrito

What is StellarBurrito?

StellarBurrito is a package available on npm.

This package’s aim is to simplify the use of stellar-sdk thanks simplified calls to the core library.

This project is open source and opens to PR so if you want to help take a look at the GitHub project!

This tutorial works on test-net, currently this library isn’t suitable for production use.

Let’s start

First of all, we need to create the project

chinaski@XPS:~/Desktop$ mkdir Medium-Pay
chinaski@XPS:~/Desktop$ cd Medium-Pay/
chinaski@XPS:~/Desktop/Medium-Pay$ touch index.js
chinaski@XPS:~/Desktop/Medium-Pay$ npm init

Then install stellar burrito package from npm

chinaski@XPS:~/Desktop/Medium-Pay$ npm i stellarburrito --save

Now our project should be initialized properly!

Do you already have two accounts for making this payment? If you don’t have these follow this tutorial.

Let’s start coding!

First of all, we need to import stellar burrito in our project

import in index.js

Now we need 2 accounts for this payment:
Alice: the sender of our payment.
Bob: the receiver of the payment.

We need Alice’s Private Key for signing the transaction and Bob Public Key as the receiver address.

The private key of Alice and the Public Key of Bob

Almost Done!

Now let’s call and handle the response of Pay function, passing

sender (Alice’s Private Key)

receiver (Bob’s Public Key)

amount (in this case 10 XLM)

as shown here

Payment operations

So your code should look like this

full code

Let’s try!

chinaski@XPS:~/Desktop/Medium-Pay$ node index.js

The result

Payment Processed!
4f9831f620cc72551e578bfccc695c952ec25cb667e131f4c53ebe84327923c0

You can verify the transaction simply copying the printed hash and pasting it on stellar.expert

That’s it!

Thanks for your attention!

If you want to collaborate for writing this library just contact me on Keybase @andreaborio!

Originally published
here
.