Coder Social home page Coder Social logo

bestia-layerzero's Introduction

Upgradeable LayerZero V2 Foundry Starter Pack ๐Ÿ› ๏ธ๐Ÿš€

This repository can be cloned to quickly start building upgradeable applications on top of LayerZero V2. It includes libraries required for development, contains test setup and working multichain deployment script written in Solidity.

These are the potential advantages of using this repository instead of official LZ V2 repository:

  1. Multichain deployment script written in Solidity
  2. OpenZeppelin V4 upgradeability: OAppUpgradeable, OFTUpgradeable (vide LZ-V2/PR-#9)
  3. Native Foundry config - no NPM dependencies (vide LZ-V2/Issue-#6), no TypeScript
  4. CREATE2 by default for deterministic addresses in multichain deployment
  5. Very simple Counter example just to get started without advanced functionality

I still recommend consulting official repository of LayerZero whenever you need to bring more advanced functionality or different code examples.

Quickstart

git clone https://github.com/Kuzirashi/layerzero-starter-kit.git
cd layerzero-starter-kit
forge install

Note: If you don't have Foundry installed yet please follow installation guide.

Usage

Build

forge build

Test

forge test

Note: if you want to execute single test file you can add a flag, eg.: --match-path ./test/CounterUpgradeability.t.sol.

Deploy

Preparation:

cp .env.example .env

Fill TEST_DEPLOYER_KEY and TEST_OWNER_ADDRESS before running deployment script.

Dry run:

forge script DeployCounter -s "deployCounterTestnet(uint256, uint256)" 1 1 --force --multi

To send transactions and actually deploy just add --broadcast flag to the command above.

Note: 1 1 parameters are respectively: uint256 _counterSalt, uint256 _counterProxySalt. It affects generated addresses. If you have problem with deployment script failing try changing 1 1 to some random numbers instead. You can't deploy with the same salt twice - it fails with message: script failed: <no data>.

Note: Don't use automatic --verify flag because it doesn't seem to work.

Upgrade

Please set TEST_COUNTER_PROXY_ADDRESS in .env to make sure correct proxy is updated.

forge script UpgradeCounter -s "upgradeTestnet()" --force --multi

Add --broadcast when you're ready to send actual transactions (example tx).

Verify

Read VERIFICATION.md.

Demo deployment

Read EXISTING_DEPLOYMENT.md.

Compatibility

Tested with:

forge 0.2.0 (71d8ea5 2024-01-09T14:41:14.837767655Z)

Inspiration ๐Ÿ’ก

This repository is, to a significant extent, a compilation of other people's work. I just put these separate pieces together to achieve best developer experience possible.

LayerZero libraries and examples are based on: https://github.com/LayerZero-Labs/LayerZero-v2.

Multichain script deployment setup is heavily based on: https://github.com/timurguvenkaya/foundry-multichain by @timurguvenkaya.

LayerZero OApp Upgradeability is taken from: https://github.com/Zodomo/LayerZero-v2/tree/main by @Zodomo.

Note: Initially I have used my own implementation but I think @Zodomo version is slightly better structured. I've noticed that implementation after I created this repository.

License

MIT

bestia-layerzero's People

Contributors

e00dan avatar 0xcsmnt avatar

Watchers

 avatar

Forkers

rkdevstack

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.