Skip to main content

A Zksync plugin for the Titanoboa Vyper interpreter

Project description

titanoboa-zksync

A Zksync plugin for the Titanoboa Vyper interpreter

Installation

First install the following dependencies, depending on your system:

Google Colab

For Google Colab: The following dependencies should be downloaded automatically.

Zkvyper Compiler

We use the era-compiler-vyper a.k.a. zkvyper: to compile Vyper code to ZkSync-compatible bytecode.

  1. Download the latest binary from the zkvyper-bin repository and rename it as zkvyper.

  2. On Linux/macOS, mark the binary as executable: chmod a+x <path to file>

  3. On macOS, the binary may need to have its quarantine attribute cleared: xattr -d com.apple.quarantine <path to file>

Then, make sure this is available in your system PATH.

ZkSync Node

If you want to test with forks or a local test node, you will need to install the ZkSync era-test-node.

  1. Download era-test-node from latest Release

  2. Extract the binary and mark as executable:

    tar xz -f era_test_node.tar.gz -C /usr/local/bin/
    chmod +x /usr/local/bin/era_test_node
    

Then, make sure this is available in your system PATH.

Install the plugin

Finally, install the package:

pip install git+https://github.com/DanielSchiavini/titanoboa-zksync.git@main

Usage

The usage of this plugin is similar to the original Titanoboa interpreter.

Configuring the environment

In Python:

import boa_zksync

boa_zksync.set_zksync_env("<rpc_url>")  # use RPC
boa_zksync.set_zksync_fork("<rpc_url>")  # fork from the mainnet
boa_zksync.set_zksync_test_env()  # run a local test node

In JupyterLab or Google Colab:

import boa, boa_zksync
from boa.integrations.jupyter import BrowserSigner

# use the browser signer and RPC:
boa_zksync.set_zksync_browser_env()  # use the browser signer and RPC
boa.env.set_chain_id(324)  # Set the chain ID to the ZkSync network

# use the browser signer and a custom RPC:
boa_zksync.set_zksync_env("<rpc_url>")
boa.env.set_eoa(BrowserSigner())

Interacting with the network

import boa, boa_zksync

constructor_args, address = [], "0x1234..."

boa_zksync.set_zksync_test_env()  # configure the environment, see previous section

# Compile a contract from source file
boa_zksync.ZksyncDeployer.create_compiler_data("source code")

# Load a contract from source code and deploy
boa.loads("contract source code", *constructor_args)

# Load a contract from file and deploy
contract = boa.load("path/to/contract.vy", *constructor_args)

# Load a contract from source file but don't deploy yet
deployer = boa.loads_partial("source code")
deployer.deploy(*constructor_args)  # Deploy the contract
deployer.at(address) # Connect a contract to an existing address

# Load a contract from source file but don't deploy yet
deployer = boa.loads_partial("source code")
deployer.deploy(*constructor_args)  # Deploy the contract
deployer.at(address) # Connect a contract to an existing address

# Run the given source code directly
boa.eval("source code")

Limitations

  • # pragma optimize gas is not supported by Zksync

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

titanoboa_zksync-0.1.0.tar.gz (20.9 kB view details)

Uploaded Source

Built Distribution

titanoboa_zksync-0.1.0-py3-none-any.whl (20.6 kB view details)

Uploaded Python 3

File details

Details for the file titanoboa_zksync-0.1.0.tar.gz.

File metadata

  • Download URL: titanoboa_zksync-0.1.0.tar.gz
  • Upload date:
  • Size: 20.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.0 CPython/3.12.4

File hashes

Hashes for titanoboa_zksync-0.1.0.tar.gz
Algorithm Hash digest
SHA256 2930ee15b362bf1dc56642971a1441ac58f912b1b4a12a17b0eaf186ba9a823f
MD5 58425242ca213a9015c8ad95d9758c95
BLAKE2b-256 555ea6fa2be4c5d78135fcae37e5400288de53a72cbb8bb0d0a54e0892c800f4

See more details on using hashes here.

File details

Details for the file titanoboa_zksync-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for titanoboa_zksync-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a5da4fd3a2f37175fb6158203fe9a0217e747f88e7d3a7ec0212e8a204f5cfb4
MD5 fa9c6097dc3ecf1c1c3bc8f9222b2c7f
BLAKE2b-256 220e2920cd7941d867b9248f7cd59240c783df7c1404915b991ba4a66e2abd32

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page