Unofficial Python Client for the OP-Stack
Project description
Optimism-Python: Unofficial Python Client for the OP-Stack
[!WARNING] Reference SDK is still under active development so the repository might be temporarily out of date.
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)
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 Distribution
optimism-python-0.3.1.tar.gz
(17.1 kB
view details)
Built Distribution
File details
Details for the file optimism-python-0.3.1.tar.gz
.
File metadata
- Download URL: optimism-python-0.3.1.tar.gz
- Upload date:
- Size: 17.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.12 Linux/6.8.0-47-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | f168167ee0ee29ee7fd0be29d9ab6afa17fb1c664a31ae01be5d400896e4eff0 |
|
MD5 | c001fc9056fae8fae7a92ce56010ff2b |
|
BLAKE2b-256 | 86be2e9613850c30e649cd4be7ac32213041cb4400e312c5b4bff7b05ad85d8a |
File details
Details for the file optimism_python-0.3.1-py3-none-any.whl
.
File metadata
- Download URL: optimism_python-0.3.1-py3-none-any.whl
- Upload date:
- Size: 23.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.1.12 CPython/3.10.12 Linux/6.8.0-47-generic
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | d3711da08058c3275a91cac51cc42492e9da337472d9642757bd7e61cb8817fd |
|
MD5 | 71f1a0b21be32ea5b9575223579b115a |
|
BLAKE2b-256 | 916ba33d5d935e13d13c83e3f1a05612693f6a85e0ee0fff2d017ec9675570da |