Before using, please review the prerequisites
All unity SDKs are open source, click here to view
Drag prefab to your scene
Drag the ParticleWalletGUI.prefab to your first scene(Required)
It is required before call other method, you can define your app info as a metadata or user the default value, metadata is used for wallet connect.
var metadata = new DAppMetaData("Particle Connect",
"https://connect.particle.network/icons/512.png",
"https://connect.particle.network");
ChainInfo chainInfo = new AvalancheChain(AvalancheChainId.Mainnet);
// Init and set default chain info.
ParticleNetwork.Init(chainInfo);
ParticleConnectInteraction.Init(chainInfo, metadata);
// The following methods are optional, used for configure your project.
// Set support chain info array. you can set a chain info array, default value is all chains.
ParticleWalletGUI.SupportChain(new []{chainInfo});
// Disable buy.
ParticleWalletGUI.EnablePay(false);
// Disable testnet if release.
ParticleWalletGUI.ShowTestNetwork(false);
// Disable wallet manage page if you only support one wallet.
ParticleWalletGUI.ShowManageWallet(false);
// Use this method to control dark mode or light mode. you can call this method with your button.
ParticleNetwork.SetInterfaceStyle(UserInterfaceStyle.DARK);
// Manage Tokens and NFTs, set show only native and your tokens, NFTs, don't show other tokens and NFTs.
ParticleWalletGUI.SetDisplayTokenAddresses(new []{"Your token address"});
ParticleWalletGUI.SetDisplayNFTContractAddresses(new []{"Your nft address"});
// Manage Tokens and NFTs, set priority tokens and NFTs.
ParticleWalletGUI.SetPriorityTokenAddresses(new []{"Your token address"});
ParticleWalletGUI.SetPriorityNFTContractAddresses(new []{"Your nft address"});
// Control if show add button in wallet page.
ParticleWalletGUI.SetSupportAddToken(false);
// Control if support wallet connect as a wallet
ParticleWalletGUI.SupportWalletConnect(false)
// Control if show dapp browser in wallet page
ParticleWalletGUI.SupportDappBrowser(false)
// Control UI pages native currency symbol
ParticleWalletGUI.SetFiatCoin("HKD");
// Set language
ParticleWalletGUI.SetLanguage(Language.KO);
// Control if show language setting button in setting page.
ParticleWalletGUI.ShowLanguageSetting(true);
// Control if show appearance setting button in setting page.
ParticleWalletGUI.ShowAppearanceSetting(true);
{% hint style="info" %}
Starting from version 0.14.0, WalletConnectV2 is supported.
var metaData = new WalletMetaData("Particle Connect",
"https://connect.particle.network/icons/512.png",
"https://connect.particle.network", description: "", "your wallet connect project id");
ParticleWalletGUI.ParticleWalletConnectInitialize(metaData);
{% endhint %}
public void NavigatorWallet()
{
// If you want to navigator wallet token, set display to 0
// If you want to navigator wallet NFT, set display to 1
int display = 0;
ParticleWalletGUI.NavigatorWallet(display);
}
public void NavigatorTokenReceive()
{
// If you want to test solana, your should replace under value with solana test account.
// Navigator to token receive page
// This is ChainLink Token in Ethereum Gnerli
string tokenAddress = TestAccount.EVM.TokenContractAddress;
ParticleWalletGUI.NavigatorTokenReceive(tokenAddress);
}
public void NavigatorTokenSend()
{
// If you want to test solana, your should replace under value with solana test account.
// This is ChainLink Token in Ethereum Gnerli
string tokenAddress = TestAccount.EVM.TokenContractAddress;
// Another receiver address
string toAddress = TestAccount.EVM.ReceiverAddress;
// Send amount
string amount = "1000000000";
ParticleWalletGUI.NavigatorTokenSend(tokenAddress, toAddress, amount);
}
public void NavigatorTokenTransactionRecords()
{
// If you want to test solana, your should replace under value with solana test account.
// This is ChainLink Token in Ethereum Gnerli
string tokenAddress = TestAccount.EVM.TokenContractAddress;
ParticleWalletGUI.NavigatorTokenTransactionRecords(tokenAddress);
}
public void NavigatorNFTSend()
{
// If you want to test solana, your should replace under value with solana test account.
// This is a test NFT
string mint = TestAccount.EVM.NFTContractAddress;
string tokenId = TestAccount.EVM.NFTTokenId;
string receiveAddress = "";
ParticleWalletGUI.NavigatorNFTSend(mint, tokenId, receiveAddress);
}
public void NavigatorNFTDetails()
{
// If you want to test solana, your should replace under value with solana test account.
// This is a test NFT
string mint = TestAccount.EVM.NFTContractAddress;
string tokenId = TestAccount.EVM.NFTTokenId;
ParticleWalletGUI.NavigatorNFTDetails(mint, tokenId);
}
public void NavigatorBuyCrypto()
{
// buy crypto with parameters
BuyCryptoConfig config = new BuyCryptoConfig(TestAccount.EVM.PublicAddress,
OpenBuyNetwork.BinanceSmartChain, "BNB", "USD", 100);
ParticleWalletGUI.NavigatorBuyCrypto(config);
// also support buy crypto without parameters
ParticleWalletGUI.NavigatorBuyCrypto();
}
public async void NavigatorLoginList()
{
var nativeResultData = await ParticleWalletGUI.Instance.NavigatorLoginList();
if (nativeResultData.isSuccess)
{
Debug.Log(nativeResultData.data);
}
else
{
var errorData = JsonConvert.DeserializeObject<NativeErrorData>(nativeResultData.data);
Debug.Log(errorData);
}
}
public void NavigatorSwap()
{
ParticleWalletGUI.NavigatorSwap();
}
public void NavigatorDappBrowser()
{
ParticleWalletGUI.NavigatorDappBrowser("https://opensea.io");
}
You'd better call this method to sync wallet with GUI, before open any GUI page.
For example, user connects more than one wallet, then open wallet page, call this method to make sure open this right wallet in GUI pages.
public async void SwitchWallet()
{
var walletType = WalletType.MetaMask;
var publicAddress = "";
var nativeResultData = await ParticleWalletGUI.Instance.SwitchWallet(walletType, publicAddress);
Debug.Log(nativeResultData.data);
if (nativeResultData.isSuccess)
{
ShowToast($"{MethodBase.GetCurrentMethod()?.Name} Success:{nativeResultData.data}");
Debug.Log(nativeResultData.data);
}
else
{
ShowToast($"{MethodBase.GetCurrentMethod()?.Name} Failed:{nativeResultData.data}");
var errorData = JsonConvert.DeserializeObject<NativeErrorData>(nativeResultData.data);
Debug.Log(errorData);
}
}
ChainInfo avalanche = new AvalancheChain(AvalancheChainId.Mainnet);
ChainInfo ethereum = new EthereumChain(EthereumChainId.Mainnet);
ChainInfo bsc = new BSCChain(BscChainId.Mainnet);
ParticleWalletGUI.SupportChain(new []{avalanche, bsc, ethereum});
ParticleWalletGUI.EnableSwap(true);
ParticleWalletGUI.EnablePay(true);
Set show or hidden test network in switch network page, default value is false.
ParticleWalletGUI.ShowTestNetwork(false);
Set show or hidden wallet manage page, default value is true.
ParticleWalletGUI.ShowManageWallet(false);
ParticleNetwork.SetInterfaceStyle(UserInterfaceStyle.DARK);
ParticleWalletGUI.SetLanguage(Language.EN);
public void GetSwapEnableState()
{
var result = ParticleWalletGUI.GetEnableSwap();
Debug.Log($"Swap enable state = {result}");
}
public void GetBuyCryptoEnableState()
{
var result = ParticleWalletGUI.GetEnablePay();
Debug.Log($"Buy crypto enable state = {result}");
}