Code Monkey home page Code Monkey logo

zksync's Introduction

Hello World! ๐Ÿ‘‹

๐Ÿ“Š Stats

Top Langs

Stats

๐Ÿ‘จ๐Ÿปโ€๐Ÿ’ป Languages and Tools:

Python Django Flask FastApi Docker Postgresql WEB3

๐Ÿ”— Socials

Telegram

zksync's People

Contributors

czbag avatar shampoowoo avatar

Stargazers

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

Watchers

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

zksync's Issues

about sendRawTransaction

can't 100% ensure this is one issue, but when i change the code from txn_hash = web3.eth.sendRawTransaction(signed_txn) to txn_hash = web3.eth.sendRawTransaction(signed_txn.rawTransaction), it's working fine.

(helpful suggestion) Add Relay.link Bridge

  1. Add relay.py file tomodules folder and paste this code:
from loguru import logger
import aiohttp

from utils.gas_checker import check_gas
from utils.helpers import retry
from .account import Account

CHAIN_IDS = {
    'Ethereum': 1,
    'Optimism': 10,
    'Arbitrum': 42161,
    'Base': 8453,
    'Zora': 7777777
}


class Relay(Account):
    def __init__(self, account_id: int, private_key: str, proxy: str | None = None) -> None:
        super().__init__(account_id=account_id, private_key=private_key, proxy=proxy, chain="zksync")
        self.proxy = f"http://{proxy}" if proxy else None

    async def get_info(self, dest_chain_id: int, amount: int) -> tuple[str, int, str]:
        'return (address_to, amount_wei, tx_data)'
        json_data = {
            'destinationChainId': dest_chain_id,
            'originChainId': 324, # zksync-era chain id
            'source': "relay.link",
            'txs': [{
                'data': '0x',
                'to': self.address,
                'value': amount
            }],
            'user': self.address
        }
        headers = {
            "Accept": "application/json",
            "Content-Type": "application/json",
            "Host": "api.relay.link",
            "Origin": "https://www.relay.link",
        }
        async with aiohttp.ClientSession() as session:
            async with session.post(
                'https://api.relay.link/execute/call',
                headers=headers,
                json=json_data,
                proxy=self.proxy
            ) as response:
                if response.status != 200:
                    raise Exception(f'Relay response error: CODE - {response.status} | RESP - {await response.text()}')
                data = (await response.json())['steps'][0]['items'][0]['data']
        return self.w3.to_checksum_address(data['to']), int(data['value']), data['data']
            
    @check_gas
    @retry
    async def bridge(self, dest_chain: str, amount: float) -> None:
        dest_chain_id = CHAIN_IDS[dest_chain]

        address_to, amount_send_wei, data = await self.get_info(dest_chain_id, int(amount * 10**18))

        logger.info(f'[{self.account_id}][{self.address}] Bridging via Relay - {amount:.5f} ETH ZkSync Era -> ' + 
                    f'{amount:.5f} ETH {dest_chain} | Cost: {amount_send_wei/10**18:.5f} ETH')
        
        tx_data = await self.get_tx_data(amount_send_wei) | {'to': address_to, 'data': data}

        signed_txn = await self.sign(tx_data)
        txn_hash = await self.send_raw_transaction(signed_txn)
        await self.wait_until_tx_finished(txn_hash.hex())

  1. Add to modules_settingsy file this code:
async def relay_bridge(account_id, key, proxy):
    '''
    Make bridge from zksync-era via Relay.link
    Available chains: 'Ethereum', 'Optimism', 'Arbitrum', 'Base', 'Zora'
    '''

    amount = 0.000001

    chain = 'Arbitrum'

    relay = Relay(account_id, key, proxy)
    await relay.bridge(chain, amount)

  1. Add to def get_module() in main.py file this code:
result = questionary.select(
        "Select a method to get started",
        choices=[
            ...
            Choice("52) MultiApprove", multi_approve),
            Choice("53) Make bridge on Relay", relay_bridge),
            Choice("54) Check transaction count", "tx_checker"),
            Choice("55) Exit", "exit"),
        ],
        ...

  1. Enjoy

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.