How to use Laboratory

The goal of this documentation is to guide you to build transactions, sign them, and submit them to the network.

Contents

Accounts

Create an account

https://www.stellar.org/laboratory/#account-creator This is a web tool that allows you to create and fund accounts. It will also allow you to fund that account on the testnet.

Click to Generate keypair:

_images/generate-keypairs.png

An account is just a public/private keypair, like so:

_images/account.png

Account access is controlled by public/private key cryptography. For an account to perform a transaction–e.g., make a payment–the transaction must be signed by the private key that corresponds to that account’s public key.

Friendbot: fund a test network account

Make sure that you have “test” selected in the upper right. This is critical!

_images/network-options.png

Then fund it, like so:

_images/friendbot.png

Check balances of an account

Go to Endpoint Explorer

_images/endpoint_balance.png _images/endpoint_balance_result.png

Transactions

Active an account

This operation creates and funds a new account with the specified starting balance.

Go to Transaction Builder, this is what that operation looks like:

  • Source Account: Your public address
  • Operation Type: Create Account
  • Destination: New public key that you want to create
  • Starting Balance: e.g. 40
_images/create_account.png

Then sign transaction with your private key:

_images/create_account_signed.png

If all goes well, you’ll see a successful transaction like so:

_images/create_account_result.png

Now you can check the balance of new user here

Send and Receive Money

Now that you have an account, you can send and receive funds through the Triam network. If you haven’t created an account yet, please follow this.

Most of the time, you’ll be sending money to someone else who has their own account.

Go to Transaction Builder, this is what that operation looks like:

  • Source Account: Your public address
  • Operation Type: Payment
  • Destination: Your destination public address
  • Asset: Native
  • Amount: e.g. 20
_images/payment.png

Then sign transaction with your private key:

_images/payment_signed.png

If all goes well, you’ll see a successful transaction like so:

_images/payment_result.png

Now you can check the balance of new user here

Create a trustline

When you hold assets in Triam, you’re actually holding credit from a particular issuer. The issuer has agreed that it will trade you its credit on the Stellar network for the corresponding asset–e.g., fiat currency, precious metal–outside of Stellar. Let’s say that Scott issues oranges as credit on the network. If you hold orange credits, you and Scott have an agreement based on trust, or a trustline: you both agree that when you give Scott an orange credit, he gives you an orange.

When you hold an asset, you must trust the issuer to properly redeem its credit. Since users of Triam will not want to trust just any issuer, accounts must explicitly trust an issuing account before they’re able to hold the issuer’s credit. In the example above, you must explicitly trust Scott before you can hold orange credits.

To trust an issuing account, you create a trustline. Trustlines are entries that persist in the Triam ledger. They track the limit for which your account trusts the issuing account and the amount of credit from the issuing account that your account currently holds.

Now go to Transaction Builder to create a trust line:

_images/trust_line.png

Then sign transaction with your private key:

_images/trust_line_signed.png

If all goes well, you’ll see a successful transaction like so:

_images/trust_line_result.png

Transfer a token

Go to Transaction Builder, this is what that operation looks like:

_images/send_token.png

Then sign transaction with your private key:

_images/send_token_signed.png

If all goes well, you’ll see a successful transaction like so:

_images/send_token_result.png

Make a custom token

Foreword

In this article I’ll show you how to issue a token I’m going to call “BLOCKSIMPLE”.

Here are the steps involved:

  • Step 1: Create 2 accounts (One for Issuance, another for Distribution).
  • Step 2: Execute a change of trust transaction from Distribution to Issuance.
  • Step 3: Create the token.

Step 1: Create 2 accounts

You will need TWO (2) accounts. One to act as the issuer and one to act as the distributor account.

Create two and save them to your local computer. Make sure you clearly label somehow one as issuer and one as distributor. For me, I saved the data as “issuer-test-account-Stellar.txt” and “distributor-test-account-Stellar.txt”.

Using the testnet faucet and fund both accounts with RIA. Make sure that the slider in the top right is set to “test”.

Go to Create an account for more details.

Step 2: Change the trust between the two accounts.

For us to issue the token, we need to issue a change trust transaction between the distribution account and the issuance account. You can do that through this handy web interface.

Using the accounts you have created, change trust using the distribution account aimed at the issuing account:

_images/change_trust_token.png

Submit this using your private key

_images/change_trust_token_pk.png

And you’ll come to this final screen:

_images/change_trust_token_result.png

If all goes well, you’ll see a JSON response similar to above.

Step 3: Creating the Actual Token

This step is not intuitive: the token creation is done by sending a payment from the issuing account to the distribution account, denominated in the new token. This is why we had to change trust to begin with — the distribution account issued a statement of trust that this “BLOCKSIMPLE” thing was the real deal.

Go to Transaction Builder, this is what that operation looks like:

_images/send_payment_token.png

If all goes well, you’ll see a successful transaction like so:

_images/send_payment_token_result.png

Ok, so now we have issued 5000 BLOCKSIMPLE tokens on the test net. Woohoo!

Congratulations! You just issued your first ever custom token!

_images/custom_token.png

Source: https://hackernoon.com/how-to-make-a-custom-token-on-stellar-ae5296512a2e

Freezing Assets

Foreword

By default, anyone can create a trustline with an asset issuer to accept an asset. However, as an anchor, you can explicitly authorize and revoke user access to your asset by enabling the following flags on your issuing account.

  • AUTHORIZATION REQUIRED: with this setting, the anchor must approve anyone who wants to hold its asset, allowing it to control who its customers are. Approving is done by the anchor by setting the Authorize flag of an existing trustline to true with the Allow Trust operation.
  • AUTHORIZATION REVOCABLE: with this setting, the anchor can set Authorize flag of existing trustline to false with the Allow Trust operation, to freeze the asset held by another account. When an asset is frozen for a particular account, that account can’t transfer the asset to any other account, not even back to the anchor. This setting allows the issuing account to revoke assets that it accidentally issued or that were obtained improperly. To use this setting, AUTHORIZATION REQUIRED must also be enabled.

Example flow for an account with AUTHORIZATION REQUIRED and AUTHORIZATION REVOCABLE enabled:

  1. User decides he/she wants to accept an asset
  2. User opens a trust line with this asset’s issuing account
  3. Issuer authorizes the user’s trustline
  4. User can accept and send the asset to whomever else has a trustline open with the issuer
  5. Issuer wants to freeze user’s access to asset
  6. Issuer deauthorizes user’s trustline
  7. User cannot send or accept this asset

Now, let’s freeze an asset on test network:

Asset details:

  • Issuer: GDEOWSTRKOKKZYGFSACSCXKONNB6W7V4ZEPBW7H7DUXJ3Y7ZJHYDBHZQ
  • Asset Code: TEC
  • Asset Type: credit_alphanum4

Step 1: Check the flags of Issuer

Make sure issuer’s flags: “auth_required” and “auth_revocable” are TRUE

Now go to Endpoint Explorer

_images/endpoint.png _images/endpoint_result.png

Step 2: Set flags to True

Go to Transaction Builder, this is what that operation looks like:

  • Source Account: Issuer’s public address
  • Operation Type: Set Options
  • Set Flags: “Authorization required” and “Authorization revocable”
_images/set-flags.png

Then sign transaction and submit to the network.

If all goes well, you’ll see a successful transaction like so:

_images/set-flags-result.png

Now go to Step 1 to re-check statuses.

Step 3: Deauthorizes User’s Trustline

Go to Transaction Builder, this is what that operation looks like:

  • Source Account: Issuer’s public address
  • Operation Type: Allow Trust
  • Trustor: User’s public key that you want to freeze the asset
  • Asset Code: e.g. TEC
  • Authorize: false
_images/lock.png

Then sign transaction and submit to the network.

Finally, User cannot send or accept this asset.

Un-Freezing Assets

Go to Transaction Builder, this is what that operation looks like:

  • Source Account: Issuer’s public address
  • Operation Type: Allow Trust
  • Trustor: User’s public key that you want to un-freeze the asset
  • Asset Code: e.g. TEC
  • Authorize: true
_images/unlock.png

Then sign transaction and submit to the network.

Now, User can send or accept this asset.