Ankr-network / game-unreal-aptos-sdk

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Aptos SDK

Demonstrates the integration of Aptos Blockchain in Unreal Engine in accordance with the Aptos Official Blochain API. The current project is only for Windows platform.

What's New

This project shows the following transactions using Aptos Blockchain.

How to transfer coin(s) from one account to another account?

How to get coin balance for an account?

How to create a collection?

How to create a token in a collection?

How to offer a token to another account?

How to claim a token which was offered?

How to cancel an offered token?

Before proceeding with anything else lets understand how transactions are submitted to the Aptos Blockchain.

Names such as 'Alice' or 'Bob' used in this documentation are used for demonstration purposes.

SUBMIT A TRANSACTION

These are the steps to submit a transaction in Aptos.

  1. To create a raw transaction we create an Encode Submission Request using GetEncodeSubmissionRequest function having the following variables:
  • sender
  • sequence_number
  • max_gas_amount
  • gas_unit_price
  • expiration_timestamp_secs
  • payload -> { type, function, type_arguments, arguments }
  • secondary_signers
  1. Call Encode Submission with the above request as a body to get a BCS (Binary Canonical Serialization) message.
  2. Sign the BCS message using SignMessage function to get a signature.
  3. Create a transaction signature by calling GetTransactionSignature.
  4. Create a submit transaction request by calling GetSubmitTransactionRequest.
  5. Call SubmitTransaction with the submit transaction request created to get the tranaction hash.

All the steps above and below are performed in the AptosClient.cpp ("UnrealAptosSDK\Plugins\AptosSDK\Source\AptosSDK\Private") folder which are called from Unreal's Widget_Menu Blueprint.

The method to get the reference to AptosClient.cpp is shown in Blueprint below:

0

TRANSFERRING COIN

Transfers the specified amount of coins from one account to another account.

To transfer coin(s) from an account to another account we need to provide the sender account, receiver account and the amount of coin to be transfered.

TransferCoin

GET COIN BALANCE

Gets the coin balance for the specified account.

To get the coin balance of an account we need to provide the account.

GetCoinBalance

CREATING COLLECTION

Create a new collection for the specified account.

To create a new collection we need to provide a collection name, collection description, uri, a max amount that the collection can hold which is shown in the blueprint below.

CreateCollection

CREATING TOKEN

Creates a new token in the specified collection.

To create a new token within the collection we need to provide the collection name, token name, token description, token supply, token uri, max supply (The maximum number of tokens that can be minted from this token) which is shown in the blueprint below.

CreateToken

OFFERING A TOKEN

Transfer a specified amount of tokens from account to receiver.

To transfer token from one account to another we need to provide the receiver address, creator address, collection name, token name, amount of tokens to be transfered which is shown in the blueprint below.

OfferToken

CLAIMING A TOKEN

Claim token on specified account.

To claim token on a specified account we need to provide the sender address, creator address, collection name, and token name which is shown in the blueprint below.

ClaimToken

CANCELING AN OFFERED TOKEN

Cancels a pending token that was offered to a another account to claim.

To cancel a pending offered token we need to provide the receiver account, creator account, collection name and the token name.

CancelTokenOffered

Please feel free to to use the SDK and update us on things that come to your attention. Thanks!

About


Languages

Language:C++ 72.0%Language:Java 25.4%Language:C# 2.2%Language:C 0.2%Language:Batchfile 0.2%