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()

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pera_wallet-0.0.16.tar.gz (1.8 MB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pera_wallet-0.0.16-py3-none-any.whl (14.2 MB view details)

Uploaded Python 3

File details

Details for the file pera_wallet-0.0.16.tar.gz.

File metadata

  • Download URL: pera_wallet-0.0.16.tar.gz
  • Upload date:
  • Size: 1.8 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for pera_wallet-0.0.16.tar.gz
Algorithm Hash digest
SHA256 58a2c1add1fd3dff734ef0701ca3b3de1d4522c593055108e1c5dc59c25820fe
MD5 cff5614a33dc7c97d224124f5943fe87
BLAKE2b-256 eb340f08c2f618965052ca2608aedb2e842a3ef7338be12e78c710c91e4240bb

See more details on using hashes here.

File details

Details for the file pera_wallet-0.0.16-py3-none-any.whl.

File metadata

  • Download URL: pera_wallet-0.0.16-py3-none-any.whl
  • Upload date:
  • Size: 14.2 MB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.0.1 CPython/3.11.9

File hashes

Hashes for pera_wallet-0.0.16-py3-none-any.whl
Algorithm Hash digest
SHA256 84b1ddb858981c95951e06b94cf1c959712883653d855fb3bd805c35172a5677
MD5 5cec4b0f5f7a0dd204c2ee317951708d
BLAKE2b-256 8c10ec841e599d8f15ebacc24ecd0abf58bd42297af9095338582a5367ba8fe1

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.0.16 This release

2 files

0.0.14

2 files

0.0.13

2 files

0.0.12

2 files

0.0.11

2 files

0.0.10

2 files

0.0.9

2 files

0.0.8

2 files

0.0.7

2 files

0.0.6

2 files

0.0.5

2 files

0.0.4

2 files

0.0.3

2 files

0.0.2

2 files

0.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page