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 titanoboa-zksync

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

# 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.2.7.tar.gz (25.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

titanoboa_zksync-0.2.7-py3-none-any.whl (25.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: titanoboa_zksync-0.2.7.tar.gz
  • Upload date:
  • Size: 25.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for titanoboa_zksync-0.2.7.tar.gz
Algorithm Hash digest
SHA256 9bba3bae2e002818a3af8a52e55732da9fb96eed743b262488bb0fb35665cfa3
MD5 8e9bced907924a5471b3f975602e0ae2
BLAKE2b-256 30b4a9f8287270297eeb85ab290387323c0900c441c8d99b7cc534f77479d3cf

See more details on using hashes here.

Provenance

The following attestation bundles were made for titanoboa_zksync-0.2.7.tar.gz:

Publisher: release.yaml on vyperlang/titanoboa-zksync

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for titanoboa_zksync-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 a12f3d84b1033f8bbc949c067c9dd6418b701bc84d73b7f8a8c98f4f11e44b5a
MD5 90b5cf1ec5dd1081d6651398898ee8c3
BLAKE2b-256 2e8ae872de7df5abca5ad1348365a6da47c7d22947c10396d96977f7e3001d21

See more details on using hashes here.

Provenance

The following attestation bundles were made for titanoboa_zksync-0.2.7-py3-none-any.whl:

Publisher: release.yaml on vyperlang/titanoboa-zksync

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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