Oasis Sapphire encryption middleware for Web3.py
Project description
sapphire.py
Installation
pip3 install --user -r requirements.txt
pip3 install --user -r requirements.dev.txt
make
Changelog
https://github.com/oasisprotocol/sapphire-paratime/tree/main/clients/py/CHANGELOG.md
Usage
from web3 import Web3, AsyncWeb3
from web3.middleware import SignAndSendRawMiddlewareBuilder
from eth_account import Account
from eth_account.signers.local import LocalAccount
from sapphirepy import sapphire
w3 = Web3(Web3.HTTPProvider(sapphire.NETWORKS['sapphire-localnet']))
async_w3 = AsyncWeb3(
AsyncWeb3.AsyncHTTPProvider(
sapphire.NETWORKS['sapphire-localnet']
)
)
# Optional: Setup your Web3 provider with a signing account.
# This account is used for signing transactions.
account: LocalAccount = (
Account.from_key( # pylint: disable=no-value-for-parameter
private_key="<your_private_key_here>"
)
)
w3.middleware_onion.add(SignAndSendRawMiddlewareBuilder.build(account))
# Finally, wrap the provider to add Sapphire end-to-end encryption.
# Note: Account parameter in the wrap() function is used for signing view
# calls and can be different from the account used for singing transactions.
w3 = sapphire.wrap(w3, account) # Can provide custom "account" parameter
# Wrapper middleware also works with AsyncWeb3
async_w3 = sapphire.wrap(async_w3, account)
# Optionally, query Oasis Web3 Gateway for the gas price.
# from web3.gas_strategies.rpc import rpc_gas_price_strategy
# w3.eth.set_gas_price_strategy(rpc_gas_price_strategy)
The Sapphire middleware for Web3.py ensures all transactions, gas estimates and view calls are end-to-end encrypted between your application and the smart contract.
License
The Deoxys-ii library and its test vectors are derived directly from the original go library.
The remainder of the Oasis Sapphire python bindings is licensed under Apache 2.0 license.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distributions
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file oasis_sapphire_py-0.4.0-py3-none-any.whl.
File metadata
- Download URL: oasis_sapphire_py-0.4.0-py3-none-any.whl
- Upload date:
- Size: 17.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
994a19af11ec7dad1b397e16f3aabd637a38116b382fa93cc6ef27baf0fa2932
|
|
| MD5 |
5c93111a653cb9d31ebda4377a939789
|
|
| BLAKE2b-256 |
3a2a2e1e7a649ba2a12e34411e081143f1de6623f52d4386a983aafd3368747d
|