Aptos Integration
Aptos SDK is the means to integrate the Aptos blockchain into Unreal Engine via the official Aptos API. The project is in the early stages of development and currently supports the Windows platform only.
Supported functionality
Aptos SDK provides the following functionality:
- Submit transaction — submitting a transaction to the Aptos blockchain.
- Transfer coins — transferring coins between accounts.
- Check account balance — checking the account's coin balance.
- Create collection — creating a collection.
- Create token — creating a token inside a collection.
- Offer tokens — offering tokens to another account.
- Claim tokens — claiming the offered tokens.
- Cancel tokens — canceling the offered tokens.
The supported functions reside inside the AptosClient.cpp
file located in the Aptos SDK GitHub repository at the following path UnrealAptosSDK/Plugins/AptosSDK/Source/AptosSDK/Private/
. Those functions are to be called from Unreal Engine's Widget_Menu
Blueprint.
Use the methods in the Blueprint below to reference AptosClient.cpp
:
Submit transaction
In Aptos, a transaction submission executes via the number of functions:
GetEncodeSubmissionRequest
— creates a request to encode submission data required to perform a transaction.EncodeSubmission
— gets a signing message.SignMessage
— signs the BSC message.GetTransactionSignature
— creates a transaction signature.GetSubmitTransactionRequest
— creates a request for transaction submission.SubmitTransaction
— submits a transaction and obtains a transaction hash.
GetEncodeSubmissionRequest
The GetEncodeSubmissionRequest
function requests encoding the transaction data required to submit a transaction.
Here you create a request for serialization that will be sent to Aptos. You need to provide the raw transaction for the function to be executed in an Aptos Module (Contract) and the provided transaction data to be encoded in BSC (Binary Canonical Serialization).
EncodeSubmission
The EncodeSubmission
function obtains the signing message.
Here you receive the BSC-encoded transaction data and the prefix_bytes
(which is sha3_256
hash bytes of the APTOS::RawTransaction
string) concatenated into the signing message:
signing_message = prefix_bytes | bcs_bytes_of_raw_transaction
.
SignMessage
The SignMessage
function signs the BCS message.
GetTransactionSignature
Call the GetTransactionSignature
function to create a transaction signature.
Here you sign the signing message with the sender's account private key.
GetSubmitTransactionRequest
The GetSubmitTransactionRequest
function creates a transaction request ready to submit to Aptos.
Here you have the BSC-encoded transaction data and the transaction signature to be processed into the submit transaction request for Aptos.
SubmitTransaction
The SubmitTransaction
function submits a transaction request provided in the previous step and obtains a transaction hash.
Transfer coins
Transfers the specified amount of coins from the sender to receiver account.
Coins transfer between two account requires the following info to be specified:
- Sender account (
From
) - Receiver account (
To
) - The amount of coins to transfer
Get account balance
Gets the coin balance for the account specified.
To get the account's coin balance, provide the following parameter:
- Account address.
Create collection
Creates a new collection for the account specified.
To create a new collection, provide the following parameters:
- Collection name
- Collection description
- URI
- Max. amount the collection can hold
Create token
Creates a new token within the collection specified.
To create a new token within the collection, provide the following parameters:
- Collection name
- Token name
- Token description
- Token supply
- Token URI
- Max. supply (the maximum number of tokens that can be minted from this token)
Offer tokens
Transfer a specified amount of tokens from the creator to receiver account.
To transfer tokens between two accounts, provide the following parameters:
- Receiver address
- Creator address
- Collection name
- Token name
- Amount of tokens to transfer
Claim tokens
Claims tokens under the account specified.
To claim tokens under the account specified, provide the following parameters:
- Sender address
- Creator address
- Collection name
- Token name
Cancel tokens
Cancels pending tokens offered for another account to claim.
To cancel pending offered tokens, provide the following parameters:
- Receiver account
- Creator account
- Collection name
- Token name