Skip to main content

streamlit-web3

streamlit-web3 packages a hidden Streamlit component that bridges a browser-injected EIP-1193 wallet provider into Web3.py.

Install

pip install streamlit-web3

Minimal usage

import streamlit as st

from streamlit_browser_web3 import wallet_get

handler = wallet_get()
if handler.status == "connected":
    if st.button("Disconnect your wallet"):
        handler.disconnect()
    page_body(handler)
else:
    if st.button("Connect your wallet"):
        handler.connect()

Important Streamlit behavior

Wallet operations are asynchronous in the browser but Streamlit scripts are synchronous and rerun-driven.

  • wallet_get() must be rendered on every rerun.
  • A wallet request may complete over multiple reruns.
  • For button-triggered Web3 calls, persist the user intent in st.session_state until the call returns.
  • Requests are serialized through the hidden browser bridge.

Chain metadata and ERC-20 helper code are intentionally kept in the example app, not in the package.

Handler API

wallet_get() returns a WalletHandler instance. Render it on every rerun and use the same handler object as your app's wallet state interface.

State properties

  • handler.status: One of "not-available", "disconnected", or "connected".
  • handler.available: True when an injected browser provider such as window.ethereum exists.
  • handler.connected: True when the wallet is connected and at least one account is available.
  • handler.accounts: List of currently exposed account addresses.
  • handler.chain_id: Current chain id as an int, or None.
  • handler.chain_id_hex: Current chain id as a hex string such as "0x1", or None.
  • handler.busy: True while a connect/disconnect action or an interactive wallet request is still pending.
  • handler.last_error: Last wallet or bridge error message, if any.
  • handler.snapshot: Raw snapshot dictionary returned by the hidden browser component.

Methods

  • handler.connect(): Starts the wallet connection flow and reruns the Streamlit script.
  • handler.disconnect(): Starts the wallet disconnect flow and reruns the Streamlit script.
  • handler.request(method, params=None, *, key): Sends an EIP-1193 request and returns (status, result).
  • handler.get_request_status(key): Returns the current status + result of a given request, or None if it does not exist.
  • handler.forget(key): Removes a tracked request so the same key can be reused for a new flow.
  • handler.snapshot_view(): Returns a typed WalletSnapshot dataclass with the main handler fields.

request() status values

handler.request(...) returns a (status, result) tuple:

  • "pending": The wallet request is still waiting for completion in the browser.
  • "success": The request completed successfully and result contains the returned value.
  • "error": The request failed and result contains an error message.

The key argument is required. Requests are tracked by key across reruns, which lets button-triggered flows continue until the browser returns a result.

Supported request methods

The handler has built-in support for these immediate methods, which resolve from the current snapshot without opening a wallet prompt:

  • eth_accounts
  • eth_chainId
  • eth_coinbase
  • net_version

The handler also marks these methods as interactive, meaning they can leave handler.busy == True while the wallet is waiting for user confirmation:

  • eth_requestAccounts
  • eth_sendTransaction
  • eth_sign
  • eth_signTransaction
  • eth_signTypedData
  • eth_signTypedData_v1
  • eth_signTypedData_v3
  • eth_signTypedData_v4
  • personal_sign
  • wallet_addEthereumChain
  • wallet_requestPermissions
  • wallet_revokePermissions
  • wallet_switchEthereumChain

Other provider methods can still be passed to handler.request(...). They are tracked as non-interactive requests unless they are in the interactive list above.

Build

python -m build

Example app

An end-to-end example is included at examples/streamlit_app.py.

Metadata

Release files for streamlit-browser-web3 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for streamlit-browser-web3 0.3.0
File Size Uploaded Provenance
streamlit_browser_web3-0.3.0.tar.gz 10.8 kB Without provenance Details

Release files / streamlit_browser_web3-0.3.0.tar.gz

Download URL streamlit_browser_web3-0.3.0.tar.gz
Size 10.8 kB
Tags Source
SHA-256 checksum
How to use checksums
0eb34b94ce861cb01bcee5ba7fc593ec097955215cb0c712d47d9448f0ee503f
BLAKE2b-256 checksum
How to use checksums
7f989e7f81f3c73f22d6353f26a7fe88b8e5a3cf829a1f0bd1cf63dab4a9114b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.7

Security for streamlit-browser-web3 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page