Skip to content

Commit

Permalink
Update Web3Unity.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
kantagara committed Oct 28, 2024
1 parent 23f5a03 commit 40cb2c3
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions Packages/io.chainsafe.web3-unity/Runtime/Scripts/Web3Unity.cs
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,21 @@ public async Task Connect<T>() where T : ConnectionProvider
await Connect(provider);
}

/// <summary>
/// Returns the currently connected wallet's public address
/// </summary>
/// <returns></returns>
/// <exception cref="InvalidOperationException">Throws an exception if the wallet is not bound</exception>
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;
}

/// <summary>
/// Sign message.
/// </summary>
Expand Down

0 comments on commit 40cb2c3

Please sign in to comment.