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.
-
Download the latest binary from the zkvyper-bin repository and rename it as zkvyper
.
-
On Linux/macOS, mark the binary as executable:
chmod a+x <path to file>
-
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.
-
Download era-test-node
from latest Release
-
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>")
boa_zksync.set_zksync_fork("<rpc_url>")
boa_zksync.set_zksync_test_env()
In JupyterLab or Google Colab:
import boa, boa_zksync
from boa.integrations.jupyter import BrowserSigner
boa_zksync.set_zksync_browser_env()
boa.env.set_chain_id(324)
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()
boa.loads("contract source code", *constructor_args)
contract = boa.load("path/to/contract.vy", *constructor_args)
deployer = boa.loads_partial("source code")
deployer.deploy(*constructor_args)
deployer.at(address)
deployer = boa.loads_partial("source code")
deployer.deploy(*constructor_args)
deployer.at(address)
boa.eval("source code")
Limitations
# pragma optimize gas
is not supported by Zksync