Skip to content
This repository was archived by the owner on Apr 2, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
120 changes: 79 additions & 41 deletions docs/pages/guides/unreal-ew-guide.mdx
Original file line number Diff line number Diff line change
@@ -1,74 +1,112 @@
---
title: How to build a Game with Unreal Engine
description: Use Sequence's Unreal SDK to display Embedded Wallet information, sign messages, and send transactions.
title: Building and Integrating Web3 Game Features with Sequence's Unreal Engine SDK
description: Integrate the Sequence Wallet, fetch your players assets, sign messages, send transactions and more using Sequence's Unreal SDK.
---

# How to build a Game with Unreal Engine
# Intro to Cropout - Unreal Engine Game Guide

In this guide we will walk you through how to integrate Embedded Wallet features using Sequence's Unreal SDK.
Checkout the [Boilerplate for this guide.](https://github.com/0xsequence/sequence-unreal)

Cropout is a top-down casual RTS game built with Unreal Engine, in this guide we will walk you through how to integrate Embedded Wallet features using Sequence's Unreal SDK.

With this integration, players will be able to access features like smart contract wallets, in-game asset ownership, and transaction management—all without disruptive popups or gas fee requirements.


Checkout the [Boilerplate for this guide.](https://github.com/0xsequence/sequence-unreal)
[Learn more about Embedded Wallets.](/solutions/wallets/overview#what-are-the-differences-between-these-options)


## 1. Setup

::::steps

### Installation
### Download the game sample


If you have the Unreal Engine installed go straight to [Unreal's Cropout page.](https://www.unrealengine.com/en-US/blog/cropout-casual-rts-game-sample-project).

If not then start by installing Epic Games Launcher:

To get started, download the [latest version](https://github.com/0xsequence/sequence-unreal/releases)
of the Sequence SDK and put the `SequencePlugin` folder into your Unreal project's `Plugin` folder.
1. Download and install the launcher from [Epic Games’ website.](https://www.unrealengine.com/en-US/download).

Alternatively, [learn how to get the SDK from the Epic Games Marketplace.](/sdk/unreal/installation#using-epic-games-marketplace)
2. Log In: Sign in or create an Epic Games account.

3. Find the Project: Go to the Unreal Engine tab, then the Learn section, and search for "Cropout Sample Project".

4. Download: Click Add to Library and then Install to download the project files.


## Download the Sequence Unreal Engine SDK

To get started, download the [latest version](https://github.com/0xsequence/sequence-unreal/releases) of the Sequence SDK and put the `SequencePlugin` folder into your Unreal project's `Plugin` folder.

Alternatively, [get the SDK from the Epic Games Marketplace.](/sdk/unreal/installation#using-epic-games-marketplace)

### Configure your Project

Now create the `SequenceConfig.ini` file, [based on this format](/sdk/unreal/configuration/), in your project's `Config/` directory and include the
WaaS- and Project Key from the [Sequence Builder.](https://sequence.build/) Generate a 32-character encryption key. This key will be used to securely store your user credentials.
The remaining values can be filled in later or whenever new authentication options are needed.
1. [Sign in to the Sequence Builder Console.](/solutions/builder/getting-started)

2. [Create a Project For Your Game in the Builder Console.](/support/builder/project-management)

3. Setup an [Embedded Wallet in the Builder Console.](/solutions/builder/embedded-wallet#embedded-wallet-in-builder)

4. In your `SequenceConfig.ini` file, add your `WaaS Config Key` and your Builder API Key from the [Builder Console](/solutions/builder/getting-started#claim-an-api-access-key) under `Settings > API Access Keys`.

5. Do not forget to add your preferred Oauth client ids, which you must set in the Builder under `Onboard > Embedded Wallet > Configuration`.


### Login using the Built-In UI


On the Main Menu level blueprint we will spawn our `Sequence Connector` Actor which will initiate and display the Login Panel.

We recommend using the Built-In UI for development purposes, here's a more [detailed explanation. ](/sdk/unreal/user_interfaces/)
For further customization, [learn how to create your own UI.](/sdk/unreal/authentication/)


## 2. Setting the Network Id and Chain


To start our interaction with the Sequence SDK, open the *Sequence Connector* blueprint, locate the `Auth Success` event on *Event Graph > Begin Play*, and we will call `Api Update Network Id` from the SequenceWalletBP Subsystem to set the wallet to your builders project selected chain.
In the same event, we will also call `Set Chain` from the Sequence Indexer Subsystem so we can correctly fetch the assets.


## 3. Get Wallet address


To display the wallet's address we first retrieve the user's wallet reference again using the SequenceWalletBP and use it to fetch and display the wallet's address from the selected network using `Api GetWallet Address` from the SequenceWalletBP Subsystem. We will display the user address on UI_Layer_Menu.


## 4. Set your NFTs


In our case we are starting with an ERC-1155 contract, for our Resource Bundle packs and Farming Boosts. To create the NFTs go to [Builder Console > Deploy > Contracts](/solutions/builder/contracts/) and select `Web3 Game Item`.

### Include the Built-In UI
Once we've made our items we will now create their respective sale contracts by deploying a new contract and selecting `Web 3 Game Item(Sale)`.

Let's build on top of the Pawn `BP_CustomSpectatorPawn` and GameMode `GM_Sequence` included with the SDK by duplicating them into our project.
This will allow us to customize them as needed.
We will add to our Web 3 Game items its corresponding rewards and it's Sale contract address as a property.

We recommend using the Built-In UI for development purposes, [learn how to create your own UI.](/sdk/unreal/authentication/)

::::
### Fetching our NFTs

## 2. Interact with the SDK
To enable interaction with the Sequence SDK, start by creating a widget blueprint for your project.
Open the Sequence Pawn, locate the `Auth Success` event, and create a reference of your new UserWidget.
Finally, use our subsystems like the `SequenceWalletBP` to access our features from the following sections.
To retrieve our newly created NFTs we will use the Indexer subsystem to call Get Token Supply, which will return us the information and metadata for the given contract address. You will find this in the `CUI_Purchase` blueprint.

## 3. Display Wallet Information

To display the wallet's address and balance, first retrieve the user's wallet reference.
Then, use it to fetch and display the wallet's address and current balance directly from the connected blockchain.
### Purchasing an NFTs

<b>Example Use Case:</b><br/>Build a UserWidget for your users Web3 profile.
To allow the player to purchase an NFT we will use the SequenceSDK subsystem to create and send a `PrimaryPurchase` transaction the desired `Web 3 Game Item(Sale)` and will use the contracts "Sale" property to reference our `Web 3 Game Item(Sale)`. You will find this in the `CUI_PurchaseItem` blueprint.

<img alt={'img'} src={'/img/unreal/unreal_boilerplate_address.png'} style={{borderRadius: 20}}/>
<img alt={'img'} src={'/img/unreal/unreal_boilerplate_balance.png'} style={{borderRadius: 20}}/>
### Fetch the players NFTs

## 4. Sign a Message
To retrieve the players NFTs will be using the Indexer Subsystem to call `Get Token Balances`, which will return us all the contract Balances for the given wallet address. Once returned, we will call Get Token Balances once again, but this time for each specific contract, which will return us the balance plus the information and metadata for the given contract. You will find this in the `CUI_Vault` blueprint.

To sign a message, first retrieve the user's wallet reference. Then, use the input message from the boilerplate
and initiate the signing process through the wallet to generate the signature.
### Burn the players NFTs

<b>Example Use Case:</b><br/>You can use this feature to sign a message from your backend, allowing you to verify your user's wallet upon receipt.
To give the player the rewards for using one of our NFTs we will use the SequenceSDK subsystem to create and send a `Burn` transaction of the desired `Web 3 Game Item` which will return us the transaction status and the contract address, to verify the success of the items burn. On Succes, we will use the contracts properties to give the players their reward. You will find this in the `CUI_VaultItem` blueprint.

<img alt={'img'} src={'/img/unreal/unreal_boilerplate_signature.png'} style={{borderRadius: 20}}/>
For a more detailed explanation go to [Read From Blockchain](/sdk/unreal/read-from-blockchain/) and [Write to Blockchain](/sdk/unreal/write-to-blockchain/) sections.

## 5. Send Ether to another User

To send an Ether transaction, use the recipient's address and amount from the boilerplate's input fields to initiate
the transaction with the `SequenceWalletBP` subsystem and listen to the response event.
## 5. Sign out the player

<b>Example Use Case:</b><br/>A user initiates a payment transaction to another user within your game client.

<img alt={'img'} src={'/img/unreal/unreal_boilerplate_transaction.png'} style={{borderRadius: 20}}/>
To sign out the player and terminate his session we will call `Clear Session from the Sequence Sessions Subsytem, this way we will remove his stored credentials and the user will need to login again when he returns. We will be calling this method in the UI_Layer_Menu.

:::warning
Make sure to include your own error handling. The provided code snippets are simplified.
:::
9 changes: 6 additions & 3 deletions nav.ts
Original file line number Diff line number Diff line change
Expand Up @@ -518,9 +518,12 @@ export const sidebar = {
text: 'Game Developers',
collapsed: true,
items: [
{ text: 'Build a Game with WebGL', collapsed: true, link: '/guides/webgl-guide' },
{ text: 'Build a Game with WebGL',
collapsed: true,
link: '/guides/webgl-guide'
},
{
text: 'Build a Unity Game',
text: 'Build a Game with Unity',
collapsed: true,
link: '/guides/jelly-forest-unity-guide',
},
Expand All @@ -530,7 +533,7 @@ export const sidebar = {
link: '/guides/building-transaction-heavy-games-with-unity',
},
{
text: 'How to build a Game with Unreal Engine',
text: 'Build a Game with Unreal Engine',
collapsed: true,
link: '/guides/unreal-ew-guide',
},
Expand Down