Tokens
HeathenEngineering.BGSDK.API.Tokens
1
HeathenEngineering.BGSDK.API.Server.Tokens
Copied!
A wrapper around token management features.

Overview

These methods can only be called from a server build.
The Token API is primarily used during dev time, that is most of the actions against a token type or "template" will be performed in the Unity Editor while creating your game/app, and can be done through the editor tools as described in the Getting Started article.
The only relevant Token function to be used during run time is the "Get" operation, which can be executed from the raw api such as:
1
API.Server.Tokens.GetTokens(token, resultAction);
Copied!
or can be called on the Token object itself
1
myToken.Get(resultAction);
Copied!
This of course assumes that mytoken is a reference to a Token ScriptableObject such as you defined in your BGSDK Settings object.

Features

List Contracts

1
public static IEnumerator ListContracts(Action<ListContractsResult> callback);
Copied!
List the available contracts configured for the app.
In most cases this will not be needed at run time as you should already have all contracts used by your app defined as Contract objects in your BGSDK Settings.

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Server.Tokens.ListContracts((requestState) =>
2
{
3
if (!requestState.hasError)
4
{
5
Debug.Log("Found " + requestState.result.Count + " contracts");
6
}
7
}));
Copied!

Get Contract

1
public static IEnumerator GetContract(Contract contract,
2
Action<ContractResult> callback);
Copied!
Get data about a target contract.
In most cases this will not be needed at run time as you should already have all contracts and all relevant contract data used by your app defined in your Contract objects in your BGSDK Settings.

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Server.Tokens.GetContract(contract, (requestState) =>
2
{
3
if (!requestState.hasError && requestState.result.HasValue)
4
{
5
Debug.Log("Found " + requestState.result.Value.name + " contract data");
6
}
7
}));
Copied!

List Token Types

1
public static IEnumerator ListTokenTypes(Contract contract,
2
Action<ListTokenTypesResult> callback);
Copied!
Gets a list of available tokens in a given contract.
In most cases this will not be needed at run time as you should already have all tokens and all relevant token data used by your app defined in your Token objects in your BGSDK Settings.

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Server.Tokens.ListTokenTypes(contract, (requestState) =>
2
{
3
if (!requestState.hasError)
4
{
5
Debug.Log("Found " + requestState.result.Count + " token types");
6
}
7
}));
Copied!

Get Token Type

1
public static IEnumerator GetTokenType(Contract contract,
2
string tokenId,
3
Action<ContractResult> callback);
Copied!
Get data about a target token.
In most cases this will not be needed at run time as you should already have all contracts and all relevant token data used by your app defined in your Token objects in your BGSDK Settings.

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Server.Tokens.GetTokenType(contract, id, (requestState) =>
2
{
3
if (!requestState.hasError)
4
{
5
Debug.Log("Found " + requestState.result.name + " token data");
6
}
7
}));
Copied!

Get Tokens

1
public static IEnumerator GetTokens(Token token,
2
Action<Token.ResultList> callback);
Copied!
Get the tokens of the same type the user has.
Retrieve NFTs by template
Venly API

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Server.Tokens.GetTokens(token, (requestState) =>
2
{
3
if (!requestState.hasError)
4
{
5
Debug.Log("Found " + requestState.result.Count + " tokens");
6
}
7
}));
Copied!

Privileged Features

These are features that are only available in the editor or server builds and are for testing purposes only!
These features will not compile for client builds.

Mint Non Fungible Token

1
public static IEnumerator Privileged.MintNonFungibleToken(Token token,
2
string[] destinations,
3
Action<BGSDKBaseResult> callback);
Copied!
Creates an instance of this token on the destinations indicated. Note the destinations are wallet addresses.

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Privileged.MintNonFungibleToken(token,
2
destinations,
3
(requestState) =>
4
{
5
if (!requestState.hasError)
6
{
7
Debug.Log("Tokens created");
8
}
9
}));
Copied!

Mint Fungible Token

1
public static IEnumerator Privileged.MintFungibleToken(Token token,
2
int[] amounts,
3
string[] destinations,
4
Action<BGSDKBaseResult> callback);
Copied!
Creates an amount of this token on the destinations indicated. Note the destinations are wallet addresses.
Mint fungible-NFT
Venly API

Examples

These examples assume you are familiar with the use of Unity Co-routines and the basics of C# in the context of Unity.
1
StartCoroutine(API.Privileged.MintFungibleToken(token,
2
amounts,
3
destinations,
4
(requestState) =>
5
{
6
if (!requestState.hasError)
7
{
8
Debug.Log("Tokens created");
9
}
10
}));
Copied!
Last modified 8mo ago