Socket
Socket
Sign inDemoInstall

@matterlabs/hardhat-zksync-vyper

Package Overview
Dependencies
338
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @matterlabs/hardhat-zksync-vyper

Hardhat plugin to compile Vyper smart contracts for the zkSync network


Version published
Weekly downloads
11K
increased by13.5%
Maintainers
1
Created
Weekly downloads
 

Readme

Source

hardhat-zksync-vyper 🚀

Hardhat plugin that adds zkSync-specific capabilities to vyper.

Era Logo

📥 Installation

To install hardhat-zksync-vyper plugin, run:

npm install -D @matterlabs/hardhat-zksync-vyper

or

yarn add -D @matterlabs/hardhat-zksync-vyper @nomiclabs/hardhat-vyper

🔧 Setup

Scaffold a new project

Use the zkSync Era cli to set up a project.

npx zksync-cli@latest create project greeter-vyper-example --template hardhat_vyper cd greeter-vyper-example

Update the hardhat.config.ts file with:

import "@matterlabs/hardhat-zksync-vyper";

const config: HardhatUserConfig = {
  zkvyper: {
    version: "latest", // Uses latest available in https://github.com/matter-labs/zkvyper-bin/
    settings: {
      // compilerPath: "zkvyper", // optional field with the path to the `zkvyper` binary.
      libraries: {}, // optional. References to non-inlinable libraries
      optimizer: {
        mode: '3' // optional. 3 by default, z to optimize bytecode size
        fallback_to_optimizing_for_size: false, // optional. Try to recompile with optimizer mode "z" if the bytecode is too large
      },
      experimental: {
        dockerImage: '', // deprecated
        tag: ''   // deprecated
      },
    },
  },
  ...
🔧 properties📄 Description
versionzkvyper compiler version. Default value is latest
compilerSourceIndicates the compiler source and can be either binary. (A docker option is no longer recommended).
compilerPathOptional field with the path to the zkvyper binary. By default, the binary in $PATH is used.
librariesDefine any non-inlinable libraries your contracts use as dependencies here
optimizerCompiler optimizations mode: 3 (default), fallback_to_optimizing_for_size: false (default) recommended for most projects.
dockerImage(deprecated) option used to identify the name of the compiler docker image.

Learn more about compiling libraries.

Create a simple vyper contract

The zkSync Era cli generates a contracts folder which includes a Greeter.sol contract.

  • Delete Greeter.sol from the contracts/ directory.
  • Add the equivalent Greeter.vy Vyper contract:
# @version ^0.3.3

greeting: constant(String[100]) = "Hello, World!"

@external
@view
def greet() -> String[100]:
    return self.greeting

Compile the contract

yarn hardhat compile

Create deployment script

First update the use-greeter.ts script, supplied by the CLI in the deploy/ directory by importing contract from correct location.

import * as ContractArtifact from "../artifacts-zk/contracts/Greeter.vy/Greeter.json";

Add private key to environment variables

Remove example from the .env.example file and add your private key to .

Deploy the contract

yarn hardhat deploy-zksync --script deploy-greeter.ts

Output

You should see something like this:

Running deploy function for the Greeter contract
The deployment is projected to cost 0.000135806 ETH
constructor args:0x000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000000094869207468657265210000000000000000000000000000000000000000000000
Greeter was deployed to 0x7CDF8A4334fafE21B8dCCe70487d6CBC00183c0d

📝 Documentation

In addition to the hardhat-zksync-vyper, zkSync's Era website offers a variety of resources including:

Guides to get started: Learn how to start building on zkSync Era.
Hardhat zkSync Era plugins: Overview and guides for all Hardhat zkSync Era plugins.
Hyperscaling: Deep dive into hyperscaling on zkSync Era.

🤝 Contributing

Contributions are always welcome! Feel free to open any issue or send a pull request.

Go to CONTRIBUTING.md to learn about steps and best practices for contributing to zkSync hardhat tooling base repository.

🙌 Feedback, help and news

zkSync Era Discord server: for questions and feedback.
Follow zkSync Era on Twitter

Happy building! 👷‍♀️👷‍♂️

Keywords

FAQs

Last updated on 26 Feb 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc