GithubHelp home page GithubHelp logo

rafalum / optimism-python Goto Github PK

View Code? Open in Web Editor NEW
16.0 2.0 0.0 103 KB

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

License: MIT License

Python 100.00%
blockchain ethereum layer2 op-stack optimism-l2 python

optimism-python's Introduction

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

๐Ÿšง DISCLAIMER: 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

# 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_id_l1=1,          # Ethereum Mainnet
                                chain_id_l2=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)

optimism-python's People

Contributors

rafalum avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

optimism-python's Issues

ERC20 deposits and withdrawls

๐Ÿš€ Feature Description

Adds the capability to deposit and withdraw ERC20 tokens through the CrossChainMessenger.

๐Ÿ“ Detailed Explanation

Currently, only deposits and withdrawls of ETH are possible. This feature will allow one to deposit an ERC20 token from the L1 to the L2 and withdraw an ERC20 token from L2 to L1. The interaction should be equivalent to the Optimism SDK as presented in this tutorial.

๐ŸŽฏ Acceptance Criteria

  • User can send a supported ERC20 token from L1 to L2 (referred to as deposit)
  • User can send a supported ERC20 token from L2 to L1 (referred to as withdrawl)

bleu wants to contribute to optimism-python

hey @rafalum I'm curious if you're looking for external contributions to bring this Python SDK to feature-parity with the TS one. @bleu-fi has applied to an Optimism Mission to work on a Python SDK but feels like we should contribute to your package instead of starting from scratch.

BTW I followed you on Twitter, if you prefer we can chat there via DMs or in another channel you prefer.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.