Optimism-Python: Unofficial Python Client for the OP-Stack
This library is a Python implementation of the OP-Stack SDK. It tries to mirror some of the core functionalities such as:
- providing easy access to the OP-Stack contracts
- bridging of assets from L1 to L2 (deposits) and vice-versa (withdrawls)
- creating withdrawl proofs
Getting started
Installation
pip install optimism-python
Deposit ETH to L2
from web3 import Web3
from optimism import CrossChainMessenger
from optimism.types import Chains
# Create a node provider for each chain
provider_l1 = Web3(Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/<your-alchemy-key>"))
provider_l2 = Web3(Web3.HTTPProvider("https://optimism-mainnet.g.alchemy.com/v2/<your-alchemy-key>"))
# Specify an account for each chain (can be the same)
account_l1 = provider_l1.eth.account.from_key("<your-private-key>")
account_l2 = provider_l2.eth.account.from_key("<your-private-key>")
# Create a messenger instance
messenger = CrossChainMessenger(chain_l1=Chains.ETHEREUM_MAINNET,
chain_l2=Chains.OPTIMISM_MAINNET,
account_l1=account_l1,
account_l2=account_l2,
provider_l1=provider_l1,
provider_l2=provider_l2)
# Deposit 1 ETH to L2
messenger.deposit_eth(10**18)
Metadata
Release files for optimism-python 0.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| optimism-python-0.3.1.tar.gz | 17.1 kB | Without provenance | Details for optimism-python-0.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| optimism_python-0.3.1-py3-none-any.whl | Python 3 | none | any | Details for optimism_python-0.3.1-py3-none-any.whl |
Total release size: 40.3 kB
Release files / optimism-python-0.3.1.tar.gz
| Download URL | optimism-python-0.3.1.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
f168167ee0ee29ee7fd0be29d9ab6afa17fb1c664a31ae01be5d400896e4eff0
|
|
BLAKE2b-256 checksum How to use checksums |
86be2e9613850c30e649cd4be7ac32213041cb4400e312c5b4bff7b05ad85d8a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.12 Linux/6.8.0-47-generic
|
Release files / optimism_python-0.3.1-py3-none-any.whl
| Download URL | optimism_python-0.3.1-py3-none-any.whl |
|---|---|
| Size | 23.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d3711da08058c3275a91cac51cc42492e9da337472d9642757bd7e61cb8817fd
|
|
BLAKE2b-256 checksum How to use checksums |
916ba33d5d935e13d13c83e3f1a05612693f6a85e0ee0fff2d017ec9675570da
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.1.12 CPython/3.10.12 Linux/6.8.0-47-generic
|
Security for optimism-python 0.3.1
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.
To learn more about protecting yourself from malicious actors, visit our package security documentation.