Wallet Connections and Transaction UX

Wallet interfaces need to distinguish connection, account permission, signing, submission, inclusion, and the application’s intended outcome. A connected provider does not imply that a user authorized a transaction, and receiving a transaction hash does not establish successful execution.

Begin with the specific operation the user is considering. Show the account, network, requested action, and meaningful consequences before asking the wallet to proceed. Keep state changes visible so rejection or a network change becomes an understandable outcome rather than a mysterious spinner.

TL;DR

Quick Example

This complete JavaScript illustration classifies fictional attempt and receipt records. It includes rejection code 4001, a missing receipt, failed execution, successful inclusion, and changed chain context.

All five assertions passed in Node with assertion failures configured to throw. The script never connects a wallet, signs, sends RPC, or moves funds. It does not validate a real receipt’s identity, handle every provider error, prove finality, or verify a contract event. Its string identifiers are made-up teaching values.

Core Concepts

Provider events and errors

EIP-1193 defines the request/event interface and errors such as user rejection, unauthorized access, and disconnected chains. Applications must respond to account and chain changes instead of treating the initial connection as permanent context. Provider interface

Transaction observations

Ethereum’s JSON-RPC documentation distinguishes a transaction receipt and its execution status. For relevant modern receipts, status zero denotes failed execution and one denotes success. That is a receipt-level observation, not proof of every desired application result. Receipt interface

Signing intent

A message signature, a transaction signature, and a token or contract approval can authorize different things. Explain the actual request and use the relevant protocol’s verification rules. A connection button should not imply unlimited future authority.

Make the lifecycle visible without overstating it

The table is a proposed interface model. Actual wallet and chain behavior can require more states, including replacement, dropping, network unavailability, or a receipt that later changes with chain history. Use labels that match the evidence you actually have.

Preserve chain ID and transaction identity together. A hash viewed through the wrong network can look missing or unrelated. Recheck the context before constructing a request and when consuming asynchronous results.

If the user changes accounts or chains while a review is open, invalidate the old review or require the appropriate new confirmation. Do not silently submit the original operation under a newly selected context.

Separate account access from authorization

Account exposure lets an application learn an address under the provider’s rules. It does not automatically create a server session or prove the user is authorized to act on an application resource.

If using signed messages for authentication, follow a suitable established protocol with origin/domain, nonce, expiration, and replay handling as applicable. Verify the exact message and trusted context on the server. Do not invent an authentication protocol by asking for an arbitrary signature.

For transaction or contract approvals, communicate the destination, operation, relevant amount or scope, expected network, and other meaningful consequences. Avoid hiding consequential authorization inside a generic connect or continue action.

Handle rejection without automatically reopening the request. Preserve the user’s choice and provide an explicit way to revise or retry. Distinguish rejection from an unsupported method, unauthorized account, and transport failure so the next action is appropriate.

Protect the provider boundary as untrusted integration input. Validate responses and errors, subscribe only to needed events, and remove listeners when their owning view or session ends. Stale listeners can apply old results to a new context.

Recover from uncertainty using the actual operation

Keep submission identity available across page refreshes where the product requires it, using an appropriate privacy and storage policy. A lost HTTP or wallet response can leave execution uncertain; do not assume no side effect occurred.

When a receipt arrives, verify that it belongs to the intended chain and transaction, then inspect the execution status and the application-specific evidence. A successful outer transaction can still fail to produce the business result the interface promised.

Choose finality and confirmation behavior from the actual chain and consequence. Avoid a universal fixed block count across networks. Explain provisional outcomes and changes honestly rather than labeling every first inclusion permanently complete.

Test the UI with a controlled fake provider or approved test environment for rejection, chain/account change, missing receipt, failed execution, replacement, and delayed responses. The local example checks only fictional classification and makes no real wallet or financial request.

Best Practices

Show the reviewed context

Keep account, network, and consequential request scope visible. Invalidate stale reviews when context changes.

Preserve transaction identity

Track the correct chain and operation through pending and uncertain states. Offer a recovery path based on evidence.

Verify the intended outcome

Separate receipt status, application result, and finality. Test failure states as first-class user paths.

Common Mistakes

Bad: Connected means the user approved a transaction.

Correct: Request and verify the specific operation under the current account and network.

Bad: A transaction hash proves success.

Correct: Track the appropriate receipt and application outcome, then apply the required finality policy.

Bad: User rejection is an error to retry automatically.

Correct: Respect the choice and let the user explicitly decide whether to try again.

FAQ

Did the example use a wallet or funds?

No. It classifies fictional JavaScript objects and performs no signing or RPC.

Does receipt success mean the intended contract action happened?

Verify the relevant contract/application result under the actual protocol. A generic success flag alone may be insufficient.

How many confirmations should the UI wait for?

Use a reviewed policy for the actual chain, operation, and risk. There is no universal count.

Related Topics

References