Product
Introducing SSO
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
@matterlabs/hardhat-zksync-vyper
Advanced tools
Readme
Hardhat plugin that adds zkSync-specific capabilities to vyper.
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
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 |
---|---|
version | zkvyper compiler version. Default value is latest |
compilerSource | Indicates the compiler source and can be either binary. (A docker option is no longer recommended). |
compilerPath | Optional field with the path to the zkvyper binary. By default, the binary in $PATH is used. |
libraries | Define any non-inlinable libraries your contracts use as dependencies here |
optimizer | Compiler 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.
# @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
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.
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.
zkSync Era Discord server: for questions and feedback.
Follow zkSync Era on Twitter
FAQs
Hardhat plugin to compile Vyper smart contracts for the zkSync network
The npm package @matterlabs/hardhat-zksync-vyper receives a total of 7,941 weekly downloads. As such, @matterlabs/hardhat-zksync-vyper popularity was classified as popular.
We found that @matterlabs/hardhat-zksync-vyper demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
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.
Product
Streamline your login process and enhance security by enabling Single Sign-On (SSO) on the Socket platform, now available for all customers on the Enterprise plan, supporting 20+ identity providers.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.