Unofficial Python Client for the OP-Stack
Project description
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
# Create a node provider for each chain
provider_l1 = Web3.HTTPProvider("https://eth-mainnet.g.alchemy.com/v2/<your-alchemy-key>")
provider_l2 = 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(l1_chain_id=1, # Ethereum Mainnet
l2_chain_id=10, # 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.2.0.tar.gz
(13.2 kB
view hashes)
Built Distribution
Close
Hashes for optimism_python-0.2.0-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | a66f07dc4d46e04095471a74c58a3affd110a6da82f4b3291f4b5b84cc5f8219 |
|
MD5 | aec0647900c9da3440a6e1383545ef28 |
|
BLAKE2b-256 | b44e4bf876657c5ba10f79c27ffa4b6223ea3499317d335c3d083bfc5f5b8634 |