Skip to content

Patronum-Labs/foundry-vyper

Repository files navigation

Foundry x Vyper Template GitHub Repo stars

Template repository for getting started quickly with Vyper using a Foundry project.

Star this project on GitHub to make it reach more developers.

Setup

Click Use this template on GitHub to create a new repository with this repo as the initial state.

🌀 Dependencies

You will need the following dependencies:

Installation

For direct local use, use the following Forge command to create a new project (replace project with your project name):

forge init --template https://github.com/Patronum-Labs/foundry-vyper <project>

Project Structure

├── src/
│   └── Greeting.vy              # Vyper contract
├── test/
│   └── Greeting.t.sol           # Solidity tests for the Vyper contract
├── script/
│   └── Greeting.s.sol           # Deployment scripts
├── interfaces/
│   └── IGreeting.sol            # Interfaces for the contracts
└── foundry.toml

Directory Explanations

  • src/: This is where your Vyper contracts are located.
  • test/: This is where you write Solidity tests for your Vyper contracts.
  • script/: This is where you write scripts to deploy your contracts.
  • interfaces/: This is where you create interfaces for the contracts you want to test or use in scripts.

Compiling Vyper Contracts

To compile a Vyper contract, use the following command:

vyper src/Greeting.vy

Make sure you have Vyper version 0.4.0 or higher:

vyper --version
> 0.4.0+commit.e9db8d9

Testing

To run tests, use the following command:

forge test

Deployment

To deploy your contracts using the script, you need to add PRIVATE_KEY in the .env file.

Then run the deployment script with the following command (replace <YOUR_RPC> with a link to an RPC provider):

forge script script/Greeting.s.sol:GreetingScript --rpc-url <YOUR_RPC> --broadcast

Acknowledgments

This repository is inspired by and uses code from the following projects:

We are grateful to the authors and contributors of these projects for their valuable work and inspiration.

Debugging

  • The Vyper deployer originally used the python command. In this repository, it has been changed to python3 for simplicity. If you encounter any issues running the tests, try switching back to python.
  • If vyper --version returns a version lower than 0.4.0, please refer to the Vyper installation documentation. (If you experience issues with pip, try running python3 -m pip install vyper==0.4.0)