-
Notifications
You must be signed in to change notification settings - Fork 7
Tutorial #1. (Blueprint version) Basic plugin usage.
In this tutorial we'll show you how to use basic functionality of Stratis Unreal plugin: create a wallet, check your balance and unspent transaction outputs (UTXOs), and send coins to another address.
You need to setup your project and Stratis Unreal Plugin within it. If you looking for a tutorial about basic project setup, please check our tutorial #0.
First of all, we need to setup StratisUnrealManager to be able to use all of the API methods provided by plugin.
Let's click on Blueprints menu in the toolbar and click Open Level Blueprint.

Now we see blueprint editor, let's create a variable stratisManager with type Stratis Unreal Manager.
Also, let's create a function called InitializeStratisUnrealManager, where we will define initialization logic for a our manager.

Define InitializeStratisUnrealManager like below:

Now we're going to set up base URL, network and wallet mnemonic.
Let's walk through the parameters:
-
Mnemonic. Mnemonic is a sequence of words used to define private key of your wallet. You can create mnemonic using just a pen, a papper and a dice, or using a various of a hardware & software mnemonic generators. -
Base Url. To use Stratis Unreal Plugin, you need a full node to be running locally or remotely. Find your node's address (IP or domain) if you're running remote node, or usehttp://localhost:44336if you're running your node locally. -
Network. The network you want to operate on. UseCirrusandCirrusTestfor production and testing respectively.
The last thing we need to do is call our new function Initialize Stratis Manager on BeginPlay event:

Now let's learn how we can get a balance of our wallet.
First, let's make a function for printing balance response to screen. Implement a blueprint like below:

Note:
Valuehas a type ofFUInt64.
Now, let's make very similar function for the Error type:

Well, now we can actually call GetBalance function and await result. Add GetBalance to the event graph (right after manager initialization or after delay like in example) and set its Delegate and Error Delegate fields to custom events via Get Custom Event.

Bind newly created events to the functions we defined: Print Balance and Print Error.
Desired event graph is shown below (Delay node is not necessary):

Now, just press Play key and balance will be printed on your screen & debug console.
Okay, now we will try to find unpsent transaction outputs for our wallet.
At first, let's create a method Print UTXOs and add input parameter UTXOs with type Array of UTXO. Now we're going to iterate over UTXO's array using For Each Loop node:

Now let's just print every UTXO using Break... and Format Text nodes:

We are almost done. Now we just need to call Get Coins node like we did for Get Balance node, and use functions (Print UTXOs and Print Error) we made previously. Final scheme is shown below:

Now let's try to implement a more complex logic: send some coins and await for transaction's receipt.
At first, add Send Coins Transaction node and set its inputs:
-
Destination address: in this example we're usingtD5aDZSu4Go4A23R7VsjuJTL51YMyeoLySfor Cirrus Test network -
Money: amount of satoshis we want to send. Let's send 10.000 satoshis (= 0.0001 STRAX).

And now we need to join Transaction ID output of TransactionSent event to Transaction ID input of Wait Till Receipt Available node.
At last, add some printing logic to see when receipt is available, and we're done!

(See this scheme on blueprintue.com)
In this tutorial we've learned how to use some core plugin's functions: get balance, send coins and wait for receipt. In next tutorial we'll cover more advanced functionality of plugin: sending no-op transactions and interacting with smart contracts.
If you found a problem, you can open an issue on project's Github page. If you still have a questions, feel free to ask them in our Discord channel.
Stay tuned!