In this series of tutorials you'll go through the basics of blockchain technology, send example transactions on Stellar's network and finally write a smart contract for content creators and their viewers. If you're already familiar with classic Stellar assets you can move on to the next post in the series which covers the smart contracts alone.
What is blockchain?
You can think of blockchain as a decentralized public ledger that records all the transactions in the network. Its general use case is transferring digital money between people and parties. Currently there are lots of blockchains that accomplish this task and some of them additionally support a feature called Smart contracts.
Smart contracts
Smart contracts are a way to implement an arbitrary user-defined logic that handles transactions on the network. The possibilities are basically infinite but some example use cases that could benefit from incorporating this feature are: your own digital token, a fundraising app or a multiplayer game that distributes collectibles to players.
Stellar and Soroban
Stellar is a blockchain that was created in 2014. One of the traits that distinguishes it from older Proof-of-Work platforms like Bitcoin is very low transaction fees. Recently the team behind Stellar started developing their own smart contract platform called Soroban that integrates with classic Stellar assets. This tutorial focused on those two technologies.
Stellar assets
Stellar's native asset is Lumen (XLM). It represents a real world value and can be acquired for example on crypto exchanges. To take part in this tutorial you don't have have to actually spend any money. Stellar hosts two more networks (Test and Futurenet) in addition to its main network, where you can fund your account for free and experiment with all the blockchain's features. We'll use Futurenet from now on as it also supports Soroban. There is a great tool that makes it easy to experiment with Stellar's features called Laboratory and you can find it here.
Creating an account
Stellar uses asymmetric cryptography to enable authentication of transactions. Each account is associated with two keys - public and private. Public key provides you with an identity on the network and private key is needed for signing transactions. Let's start by generating this keypair and funding your account with some starting funds by using Stellar Lab.
Your first transaction
To send your first payment in XLM, you'll have to generate and fund another account first. Note down the keypair you've generated earlier - if you lose it, you'll lose access to the account. Then go to "Build transaction" and fill out the necessary fields:
- Source account
- Click "Fetch next sequence number..." (it needs to be re-fetched after each transaction on an account)
- Operation type: Payment
- Destination
- Asset: Native (XLM)
- Amount (e.g. 5000)
Click "Sign in Transaction Signer", enter private key of the source account, click "Submit in Transaction Submitter" and then "Submit Transaction".
If everything went well you'll see a success message informing you that this transaction was a success.
Checking your balance
Usually you'd check the details of your account on a blockchain explorer like StellarExpert, but Futurenet is not supported yet, so we'll query the endpoint for our account with Stellar Lab. Open up this link and check the response for both of your accounts. The response will contain the information we're looking for somewhere at the bottom in "balances" section.
As you can see our balance has been reduced by the amount we've sent to the receiving account plus a small fee of 0.0000200 XLM.
Summary
Now that you're familiar with the basics of classic Stellar assets we can move on to designing our own smart contract application with the help of Soroban platform. If you want to learn more Stellar Quest Learn is a place where you can learn about blockchain and also earn some real XLM for completing the tasks. It's also worth mentioning that in everyday use you'd use a hardware or software wallet instead of Stellar Lab. They make it a lot easier to operate your account.
Top comments (0)