pen-fieldMessage Signing and Wallet Balance

npm versionarrow-up-rightLicense: GPL-3.0arrow-up-rightGitHub starsarrow-up-right

This section demonstrates how to sign arbitrary messages (for authentication, proof-of-ownership, etc.) and retrieve wallet balances using the WalletConnector SDK.

Both features are essential in many dApps β€” message signing for login and wallet verification, and balance checking for enabling or disabling actions based on token/ETH holdings.

🧱 1. Framework Usage (ES6/Module Bundlers)

πŸ“ Installation

If you haven’t already:

Or if you use Yarn:

πŸ–ŠοΈ A. Sign Message Example

Here's a minimal setup for connecting to a wallet and signing a transaction:

For typescript users, declare as a module in your types file:

circle-info

🧠 Use Case: Message signing is commonly used for user authentication (e.g., login with wallet) without needing private key exposure or gas fees.

πŸ’° B. Fetch Wallet Balance

🌐 2. CommonJS via CDN (HTML/Vanilla JS)

βœ… Embed Script

Ensure this is added before your custom scripts in the HTML body.

πŸ–ŠοΈ A. Sign Message Example (CDN)

circle-info

⚠️ Signed messages do not incur gas fees. They’re purely cryptographic and used for validation or proof of identity.

For production readiness, always wrap async calls with try/catch:

πŸ“š Summary

Feature
Method
Gas Required
Use Case

Sign Message

❌ No

Auth, proof of ownership

Get Balance

❌ No

Display balance, condition UI flows

Last updated