-
|
Hi @skibitsky ,
|
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
|
Hi @sebas6612, Do you await It seems like you are using WalletConnectUnity v2. There is a demo app which shows how to implement Disconnect and how to get current address. This code snippet returns the session, address, and chain ID: public (SessionStruct, string, string) GetCurrentAddress()
{
var currentSession = _wcSignClient.Session.Get(_wc.Session.Keys[0]);
var defaultChain = currentSession.Namespaces.Keys.FirstOrDefault();
if (string.IsNullOrWhiteSpace(defaultChain))
return (default, null, null);
var defaultNamespace = currentSession.Namespaces[defaultChain];
if (defaultNamespace.Accounts.Length == 0)
return (default, null, null);
var fullAddress = defaultNamespace.Accounts[0];
var addressParts = fullAddress.Split(":");
var address = addressParts[2];
var chainId = string.Join(':', addressParts.Take(2));
return (currentSession, address, chainId);
} In WalletConnectUnity v3.0.0 it can be simplified: var session = WalletConnect.Instance.ActiveSession;
var sessionNamespace = session.Namespaces;
var address = WalletConnect.Instance.ActiveSession.CurrentAddress(sessionNamespace.Keys.FirstOrDefault()).Address; |
Beta Was this translation helpful? Give feedback.
Hi @sebas6612,
Do you await
_client.Disconnect()?WCSignClientis a singleton, have you tried accessing it withWCSignClient.Instancein your script?It seems like you are using WalletConnectUnity v2. There is a demo app which shows how to implement Disconnect and how to get current address.
This code snippet returns the session, address, and chain ID: