Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Consistent Address Deployment Across Networks #132

Merged
merged 8 commits into from
Apr 23, 2024

Conversation

kingster-will
Copy link

Description

Overview

This PR introduces an update to the smart contract deployment process using Foundry and the CREATE3. By deploying a standalone Create3Deployer contract on networks (e.g., Sepolia), we enable Foundry to execute actual transactions through Create3Deployer, and ensuring that contracts are deployed at the same deterministic addresses.

Key Features

  • Consistent Address Across Chains: Supports deploying contracts at the same address across all chains by using the same salt value derived from a provided seed. This ensures uniformity and predictability of contract addresses on various networks.
  • Enhanced Deployment Script: The deployment script now accepts a seed argument. This seed is used to generate the salt for the Create3 deployment, ensuring that using the same seed on different chains will deploy contracts to the same address.

Motivation

Previously, deploying smart contracts using Foundry with the Create3 library faced verification issues on testnets due to the absence of actual deployment transactions. This PR resolves this issue by ensuring that each deployment involves a real transaction on the blockchain.

Additional Benefits

This update not only fixes the verification issue but also enhances the flexibility and control we have over the deployment process. It allows for seamless address changes without sacrificing consistency across multiple chains.

Usage

Deploy contracts by running the deployment script with a specific seed:

forge script script/foundry/deployment/Main.s.sol:Main <seed value e.g. 8> --sig "run(uint256)" --fork-url <rpc url> -vvvv --broadcast  --verify

This command will ensure that the same contract addresses are used across different networks, provided the same seed is used.

Test Plan

  • Deploy on Sepolia testnet and verified all contracts.
  • Repeat deployment using the same seed on different networks and verify the addresses match.

Related Issue

Closes #131

Note

This PR also include the change in another PR #115 of licensing hook, will rebase after the PR#115 merged.

Copy link

@LeoHChen LeoHChen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please rebase after previous PR merged. Changes in this PR lgtm.

@jdubpark
Copy link

Appreciate the thorough PR readme!

@kingster-will kingster-will merged commit 972c201 into storyprotocol:main Apr 23, 2024
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Smart Contracts Not Actually Deployed using Create3 with Foundry to Network
4 participants