Provider Initialisation

This function does not trigger any UI elements

Description

The base component for the Metafi SDK which takes in your API Key, unique user ID, and other options as Arguments. Call this function as soon as your initial scene is loaded, before any other functions are invoked.

Details

Signature

Task Init(string apiKey, string secretKey, dynamic options, List<Metafi.Unity.Chain> supportedChains, List<Metafi.Unity.Token> customTokens, bool metafiSSO = false)

Arguments

Parameter
Type
Definition

apiKey

String

Your API Key. This can be displayed publicly

secretKey

String

Your Secret Key. Keep this securely and do not expose.

options

dynamic

supportedChains

List<Metafi.Unity.Chain>

customTokens

List<Metafi.Unity.Token>

An array of custom tokens that you want supported in your users wallet. To pass a custom token, you will need to use the Metafi.Unity.Token constructor to generate a new token. The format of the inputs are as follows:

metafiSSO

bool

Specify whether to use MetafiSSO or not. Set to false if you are using your own custom login mechanism.

Return Value

N/A

Example

using Metafi.Unity;
using System.Dynamic;

public class StartButton : MonoBehaviour {
    async void Start() {
        Debug.Log("Initializing Metafi Provider");

        dynamic _options = new ExpandoObject();
        _options.logo = @"Assets/Resources/logo-2.png";
        _options.theme = new {
            fontColors = new {
                primary = "#FFFFFF",
                secondary = "#e8e8e8"
            },
            bgColor = "#29327F",
            ctaButton = new {
                color = "#F19B28",
                fontColor = "#FFFFFF"
            },
            optionButton = new {
                color = "rgba(255,255,255,0.1)",
                fontColor = "#FFFFFF"
            },
            metafiLogoColor = "light",
        };
        
        Token wethToken = new Token(
            "Wrapped Ethereum",
            "goerliWETH",
            Chains.GOERLI,
            "https://d2qdyxy3mxzsfv.cloudfront.net/images/logo/ethereum.png",
            "0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6",
            18
        );

        await MetafiProvider.Instance.Init(
            "apiKey",
            "secretKey",
            _options,
            new List<Chain> {Chains.ETH, Chains.MATIC, Chains.GOERLI, Chains.MUMBAI},
            new List<Token> {wethToken},
            false
        );
        
        Debug.Log("Metafi Provider initialized");
    }
}

Last updated