Provider Initialisation
This function does not trigger any UI elements
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.
Task Init(string apiKey, string secretKey, dynamic options, List<Metafi.Unity.Chain> supportedChains, List<Metafi.Unity.Token> customTokens, bool metafiSSO = false)
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 | A list of options to customise the look and feel of how the Metafi wallet looks. Here you can pass in a custom logo, as well as theme styling options. More information can be found in the UI customisation section. dynamic options = new { logo = "./logo.png", // pass in the URL or path to your logo theme = new { fontColors = new { primary = '#ffffff', secondary = '#e8e8e8' }, bgColor = "linear-gradient(40deg, rgba(209,29,255,1) 0%, rgba(7,52,235,1) 100%)", ctaButton" = new { color = "#430aa0", fontColor = "#ffffff" }, optionButton = new { color = "rgba(0,0,0,0.1)", fontColor = "#ffffff" }, metafiLogoColor = "light", }, } |
supportedChains | List<Metafi.Unity.Chain> | An array of chains supported by your application. Please refer to the section on Chains for more information on what chains we support. |
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:
Token (string name, string symbol, Metafi.Unity.Chain chain, string image, string contractAddress, int decimals) |
metafiSSO | bool | Specify whether to use MetafiSSO or not. Set to false if you are using your own custom login mechanism. |
N/A
1
using Metafi.Unity;
2
using System.Dynamic;
3
4
public class StartButton : MonoBehaviour {
5
async void Start() {
6
Debug.Log("Initializing Metafi Provider");
7
8
dynamic _options = new ExpandoObject();
9
_options.logo = @"Assets/Resources/logo-2.png";
10
_options.theme = new {
11
fontColors = new {
12
primary = "#FFFFFF",
13
secondary = "#e8e8e8"
14
},
15
bgColor = "#29327F",
16
ctaButton = new {
17
color = "#F19B28",
18
fontColor = "#FFFFFF"
19
},
20
optionButton = new {
21
color = "rgba(255,255,255,0.1)",
22
fontColor = "#FFFFFF"
23
},
24
metafiLogoColor = "light",
25
};
26
27
Token wethToken = new Token(
28
"Wrapped Ethereum",
29
"goerliWETH",
30
Chains.GOERLI,
31
"https://d2qdyxy3mxzsfv.cloudfront.net/images/logo/ethereum.png",
32
"0xb4fbf271143f4fbf7b91a5ded31805e42b2208d6",
33
18
34
);
35
36
await MetafiProvider.Instance.Init(
37
"apiKey",
38
"secretKey",
39
_options,
40
new List<Chain> {Chains.ETH, Chains.MATIC, Chains.GOERLI, Chains.MUMBAI},
41
new List<Token> {wethToken},
42
false
43
);
44
45
Debug.Log("Metafi Provider initialized");
46
}
47
}
Last modified 30d ago