Skip to main content

Demos Wallet Provider API

Provider Interface

The injected provider exposes a small surface:
  • provider.request({ method, params? }): Generic RPC-style method. Preferred for all interactions.
  • provider.accounts() → Promise<{ code: 404|401|200, data: string|null }>: Returns account status/address, used primarily for discovery gating.
The provider posts messages into the page. Internally, they are forwarded to the extension background and resolved back into a unified response:

Supported Methods

See all supported methods here: wallet-provider-api-methods.md

Usage Examples

Connect and get xM addresses:
Send a transaction:
Add a Twitter identity (shape defined by SDK TwitterProof):

Error Semantics

Common error codes surfaced in response.error.code:
  • TIMEOUT: popup not resolved before timeout
  • POPUP_ERROR: could not open popup
  • ...Cancelled: user closed popup (validationCancelled, addTwitterIdentityCancelled, etc.)
  • Method-specific errors (e.g., addGithubIdentityError, sendTransactionError) include details when available

Notes

  • The extension only announces the provider after provider.accounts() indicates a non-404 status.
  • Always prefer provider.request with the methods above for forward-compatibility.