Skip to main content

pera_wallet

A Streamlit component to connect to Pera Wallet.

Installation instructions

pip install pera-wallet

Usage instructions

"""Example usage of the Pera Wallet component."""

import streamlit as st

from pera_wallet import (
    pera_wallet,
    TransactionPending,
    TransactionConfirmed,
    TransactionFailed,
    WalletConnected,
    WalletDisconnected,
)

NETWORK = "testnet"


def account() -> str | None:
    with st.expander("Account", expanded=True):
        # Add msgpack-encoded transactions to sign, if needed
        transactions_to_sign = []

        wallet, txn = pera_wallet(
            network=NETWORK,
            transactions_to_sign=transactions_to_sign,
            key="pera_wallet",
        )

        match wallet:
            case WalletDisconnected(status="unavailable"):
                st.error("Wallet is only available in secure contexts (HTTPS).")
            case WalletDisconnected(status="disconnected"):
                st.caption("Connect your wallet to begin.")
            case WalletConnected(address=address):
                st.caption(f"Connected address: {address}")

        match txn:
            case TransactionPending(status="proposed"):
                st.info(
                    "Please open the Pera Wallet app to sign this transaction.",
                    icon="✍️",
                )
            case TransactionPending(status="submitted"):
                st.info(
                    "Transaction submitted. Waiting for confirmation.",
                    icon="⏳",
                )
            case TransactionConfirmed(transaction_id=tx_id):
                st.success(
                    f"Transaction confirmed! View your transaction on [lora](https://lora.algokit.io/{NETWORK}/transaction/{tx_id}) the explorer.",
                    icon="🥳",
                )
            case TransactionFailed(msg=msg):
                st.error(f"Transaction failed: {msg}", icon="😞")

    return wallet.address


if __name__ == "__main__":
    st.title("My App")

    connected_address = account()
    if not connected_address:
        st.stop()

Metadata

Release files for pera-wallet 0.0.16

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

Source distribution (sdist)

Source distribution for pera-wallet 0.0.16
File Size Uploaded
pera_wallet-0.0.16.tar.gz 1.8 MB Details

Built distribution (wheel)

Table of built distributions (wheels) for pera-wallet 0.0.16
File Interpreter ABI Platform
pera_wallet-0.0.16-py3-none-any.whl Python 3 none any Details

Total release size: 16.0 MB

Release files / pera_wallet-0.0.16.tar.gz

Download URL pera_wallet-0.0.16.tar.gz
Size 1.8 MB
Tags Source
SHA-256 checksum
How to use checksums
58a2c1add1fd3dff734ef0701ca3b3de1d4522c593055108e1c5dc59c25820fe
BLAKE2b-256 checksum
How to use checksums
eb340f08c2f618965052ca2608aedb2e842a3ef7338be12e78c710c91e4240bb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.9

Release files / pera_wallet-0.0.16-py3-none-any.whl

Download URL pera_wallet-0.0.16-py3-none-any.whl
Size 14.2 MB
Tags Python 3
SHA-256 checksum
How to use checksums
84b1ddb858981c95951e06b94cf1c959712883653d855fb3bd805c35172a5677
BLAKE2b-256 checksum
How to use checksums
8c10ec841e599d8f15ebacc24ecd0abf58bd42297af9095338582a5367ba8fe1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.0.1 CPython/3.11.9

Release history Release notifications | RSS feed

This release

0.0.16 This release

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.7

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

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