Stellar
$0.11249 -1.89%
XLM · 9w

[Beginner Tutorial] - Manage flags using StellarBurrito

Let’s start

First of all, we need to create the project

[email protected]:~/Desktop$ mkdir [email protected]:~/Desktop$ cd Medium-ManageFlags/[email protected]:~/Desktop/Medium-ManageFlags$ touch [email protected]:~/Desktop/Medium-ManageFlags$ npm init

Then install stellar burrito package from npm

[email protected]:~/Desktop/Medium-ManageFlags$ npm i stellarburrito --save

Now our project should be initialized properly!

Why we need flags?

Flags are used to set particular authorization level on an account.

According to Stellar’s official doc currently, there are three flags, used by issuers of assets.

Authorization required (0x1): Requires the issuing account to give other accounts permission before they can hold the issuing account’s credit. Authorization revocable (0x2): Allows the issuing account to revoke its credit held by other accounts. Authorization immutable (0x4): If this is set then none of the authorization flags can be set and the account can never be deleted.

Pretty cool right?

Actually, it’s also pretty simple!

Introduction

In this tutorial, we will use accountOptions and accountStatus of stellarburrito. accountOptions.SetFlag allows you to set all of the 3 types of flag on an account given as input.  Just pass account’s secretKey and the flag that you want to set (1 for Authorization required 2 for Authorization revocable 4 for Authorization Immutable). accountStatus.getFlags return a json containing info about flags of the given account. Here an example :

{ auth_required: true, auth_revocable: false, auth_immutable: false } Let’s start coding!

first of all, include stellar burrito in your project

Set authorization_required flag

This flag can be set passing 1 as a parameter to the setFlag function, as shown in the picture.

flags should contain

{ auth_required: true, auth_revocable: false, auth_immutable: false } It works!

Now let’s c...

Continue on medium.com
Recent news