It is strongly discouraged to use private key or mnemonic import/generate function, if you use it, you need to secure the data yourself, Particle's SDK has no relationship with the imported/generated mnemonic or private key.
Quick Start
Drag prefab to your scene
Drag the ParticleConnect.prefab to your first scene(Required)
Drag the ParticleUnityRpc.prefab to your first scene(Required), then replace your project id, app id and client key.
Initialize the SDK
Init
// Get your wallet connect project id from https://walletconnect.com/// it is required by wallet connect v2.var metadata =newDAppMetaData(TestConfig.walletConnectProjectId,"Particle Connect","https://connect.particle.network/icons/512.png","https://connect.particle.network","");ParticleNetwork.Init(_chainInfo);ParticleConnectInteraction.Init(_chainInfo, metadata);List<ChainInfo> chainInfos = new List<ChainInfo>{new EthereumChain(EthereumChainId.Mainnet), new EthereumChain(EthereumChainId.Goerli), new EthereumChain(EthereumChainId.Sepolia)};
ParticleConnectInteraction.SetWalletConnectV2SupportChainInfos(chainInfos.ToArray());
Migrating to WalletConnect v2
Starting from version 0.14.0, WalletConnectV2 is supported.
// set wallet connect support chain infos after init.List<ChainInfo> chainInfos = new List<ChainInfo>{new EthereumChain(EthereumChainId.Mainnet), new EthereumChain(EthereumChainId.Goerli), new EthereumChain(EthereumChainId.Sepolia)};
ParticleConnectInteraction.SetWalletConnectV2SupportChainInfos(chainInfos.ToArray());
use after connect, because ParticleAuthService support both solana and evm, if switch to solana from evm, Auth Service will create a evm address if the user doesn't has a evm address.
var nativeResultData =awaitParticleConnect.Instance.SetChainInfoAsync(_chainInfo);Debug.Log(nativeResultData.data);if (nativeResultData.isSuccess){Debug.Log(nativeResultData.data);}else{var errorData =JsonConvert.DeserializeObject<NativeErrorData>(nativeResultData.data);Debug.Log(errorData);}
Connect Wallet
var nativeResultData =awaitParticleConnect.Instance.Connect(this._walletType);if (nativeResultData.isSuccess){Debug.Log(nativeResultData.data);}else{var errorData =JsonConvert.DeserializeObject<NativeErrorData>(nativeResultData.data);Debug.Log(errorData);}// if conenct with particle, you could pass a config parameter,// like ParticleAuthService.login// contains login type, account, support auth types and login from mode.ConnectConfig config =newConnectConfig(LoginType.PHONE,null,SupportAuthType.ALL,false);var nativeResultData =awaitParticleConnect.Instance.Connect(WalletType.Particle, config);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);}