Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimism-Python: Unofficial Python Client for the OP-Stack

License

Notifications You must be signed in to change notification settings

rafalum/optimism-python

Repository files navigation

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)

About

Optimism-Python: Unofficial Python Client for the OP-Stack

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

AltStyle によって変換されたページ (->オリジナル) /