From 40cb2c366e6b661e2a2f73d00c2159eff5fcb325 Mon Sep 17 00:00:00 2001 From: Nikola Garabandic Date: Mon, 28 Oct 2024 09:22:02 +0100 Subject: [PATCH] Update Web3Unity.cs --- .../Runtime/Scripts/Web3Unity.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Web3Unity.cs b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Web3Unity.cs index 61225ad00..8e5eb6694 100644 --- a/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Web3Unity.cs +++ b/Packages/io.chainsafe.web3-unity/Runtime/Scripts/Web3Unity.cs @@ -166,6 +166,21 @@ public async Task Connect() where T : ConnectionProvider await Connect(provider); } + /// + /// Returns the currently connected wallet's public address + /// + /// + /// Throws an exception if the wallet is not bound + public string WalletPublicAddress() + { + if (_web3.ServiceProvider.GetService(typeof(ISigner)) == null) + { + throw new InvalidOperationException("You don't have the wallet bounded to the Web3 instance. Make sure you are logged in."); + } + + return _web3.Signer.PublicAddress; + } + /// /// Sign message. ///