{"id":22930893,"url":"https://github.com/zewebdev1337/ibc-app-solidity-template","last_synced_at":"2025-04-01T17:21:41.206Z","repository":{"id":233125036,"uuid":"775688740","full_name":"zewebdev1337/ibc-app-solidity-template","owner":"zewebdev1337","description":null,"archived":false,"fork":false,"pushed_at":"2024-03-21T21:20:27.000Z","size":62,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-07T11:16:52.107Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zewebdev1337.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2024-03-21T21:20:25.000Z","updated_at":"2024-03-21T21:20:30.000Z","dependencies_parsed_at":"2024-04-19T07:15:36.512Z","dependency_job_id":null,"html_url":"https://github.com/zewebdev1337/ibc-app-solidity-template","commit_stats":null,"previous_names":["zewebdev1337/ibc-app-solidity-template"],"tags_count":0,"template":false,"template_full_name":"open-ibc/ibc-app-solidity-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Fibc-app-solidity-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Fibc-app-solidity-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Fibc-app-solidity-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zewebdev1337%2Fibc-app-solidity-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zewebdev1337","download_url":"https://codeload.github.com/zewebdev1337/ibc-app-solidity-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246679068,"owners_count":20816402,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-14T10:30:38.651Z","updated_at":"2025-04-01T17:21:41.181Z","avatar_url":"https://github.com/zewebdev1337.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# ⛓️🔗⛓️ Template for IBC enabled Solidity contracts\n\nThis repo provides a starter project to build [IBC](https://github.com/cosmos/ibc) enabled Solidity contracts that connect rollups to one another Polymer Hub, through the [vIBC core contracts](https://github.com/open-ibc/vibc-core-smart-contracts).\n\nThe repository is a _GitHub template_ repository so you can click \"Use this template\" to create your own project repository without having the entire commit history of the template.\n\n![GitHub template](./img/gh_template.png)\n\n## 📚 Documentation\n\nThere's some basic information here in the README but a more comprehensive documentation can be found in [the official Polymer documentation](https://docs.polymerlabs.org/docs/category/build-ibc-dapps-1).\n\n## 📋 Prerequisites\n\nThe repo is **compatible with both Hardhat and Foundry** development environments.\n\n- Have [git](https://git-scm.com/downloads) installed\n- Have [node](https://nodejs.org) installed (v18+)\n- Have [Foundry](https://book.getfoundry.sh/getting-started/installation) installed (Hardhat will be installed when running `npm install`)\n- Have [just](https://just.systems/man/en/chapter_1.html) installed (recommended but not strictly necessary)\n\nYou'll need some API keys from third party's:\n- [Optimism Sepolia](https://optimism-sepolia.blockscout.com/account/api-key) and [Base Sepolia](https://base-sepolia.blockscout.com/account/api-key) Blockscout Explorer API keys\n- Have an [Alchemy API key](https://docs.alchemy.com/docs/alchemy-quickstart-guide) for OP and Base Sepolia\n\nSome basic knowledge of all of these tools is also required, although the details are abstracted away for basic usage.\n\n## 🧰 Install dependencies\n\nTo compile your contracts and start testing, make sure that you have all dependencies installed.\n\nFrom the root directory run:\n\n```bash\njust install\n```\n\nto install the [vIBC core smart contracts](https://github.com/open-ibc/vibc-core-smart-contracts) as a dependency.\n\nAdditionally Hardhat will be installed as a dev dependency with some useful plugins. Check `package.json` for an exhaustive list.\n\n\u003e Note: In case you're experiencing issues with dependencies using the `just install` recipe, check that all prerequisites are correctly installed. If issues persist with forge, try to do the individual dependency installations...\n\n## ⚙️ Set up your environment variables\n\nConvert the `.env.example` file into an `.env` file. This will ignore the file for future git commits as well as expose the environment variables. Add your private keys and update the other values if you want to customize (advanced usage feature).\n\n```bash\ncp .env.example .env\n```\n\nThis will enable you to sign transactions with your private key(s). If not added, the scripts from the justfile will fail.\n\n### Configuration file\n\nThe configuration file is where all important data is stored for the just commands and automation. We strive to make direct interaction with the config file as little as possible.\n\nBy default the configuration file is stored at root as `config.json`.\n\nHowever, it is recommended to split up different contracts/projects in the same repo into different config file in case you want to switch between them.\n\nStore alternate config files in the /config directory and set\n```sh\n# .env file\nCONFIG_PATH='config/alt-config.json'\n```\nto use a different config file.\n\n### Obtaining testnet ETH\n\nThe account associated with your private key must have both Base Sepolia and Optimism Sepolia ETH. To obtain the testnet ETH visit:\n\n- [Optimism Sepolia Faucet](https://www.alchemy.com/faucets/optimism-sepolia)\n- [Base Sepolia Faucet](https://www.alchemy.com/faucets/base-sepolia)\n\n## 🏃🏽🏃🏻‍♀️ Quickstart\n\nThe project comes with a built-in dummy application called x-counter (which syncrhonizes a counter across two contracts on remote chains). You can find the contracts in the `/contracts` directory as XCounterUC.sol and XCounter.sol (the former when using the universal channel, the latter when creating a custom IBC channel).\n\n### Universal channels\n\nThe easiest way to get onboarded is to use Universal channels. A universal channel is an IBC channel where the port is owned by Polymer's Universal channel middleware contracts on each chain.\n\nWhen a user deploys a Universal channel compatible contract (this means inheriting the [UniversalChanIbcApp](./contracts/base/UniversalChanIbcApp.sol) base contract), it will be able to connect to the Universal Channel middleware, define Universal packets which will then be wrapped into an IBC packet by the Universal Channel Handler and unwrapped by its counterpart on the destination chain (rollup). The Universal channel middleware on the destination will then unwrap the IBC packet and send the data through to you application on the destination.\n\nFind out more about uinversal channels in the [documenation](https://docs.polymerlabs.org/docs/build/ibc-solidity/universal-channel).\n\nThe configuration file that comes as default in the template repository, allows to quickly send a packet by running:\n\n```sh\njust send-packet base\n```\n\nTo send a packet between the XCounterUC contract on Base Sepolia to OP Sepolia and vice versa.\n\nYou can find the universal channel middleware details [in the documentation](https://docs.polymerlabs.org/docs/build/supp-networks).\n\nCheck if the packet got through on the [Polymer IBC explorer](https://sepolia.polymer.zone/packets).\n\n### Custom IBC channel\n\nThere's also a just recipe that quickly enables to try to send packets over a custom IBC channel. Custom IBC channel require a channel hanshake to open a private IBC channel (which can take a while depending on the client latency) but then give complete control over a private IBC channel that enables fault isolation from other applications, compared to unviersal channels.\n\nTo have your application be compatible with custom IBC channels, have it inherit the [CustomChanIbcApp](./contracts/base/CustomChanIbcApp.sol) base contract.\n\nRun the following command to go through a full E2E sweep of the project, using the default XCounter.sol contract:\n\n```bash\n# Usage: just do-it\njust do-it\n```\n\nIt does the following under the hood:\n```bash\n# Run the full E2E flow by setting the contracts, deploying them, creating a channel, and sending a packet\n# Usage: just do-it\ndo-it:\n    echo \"Running the full E2E flow...\"\n    just set-contracts optimism XCounter false \u0026\u0026 just set-contracts base XCounter false\n    just deploy optimism base\n    just create-channel\n    just send-packet optimism\n    echo \"You've done it!\"\n```\n\nIt makes sure you've got the correct contracts set, deploys new instances, creates a channel and sends a packet over the channel once created.\n\n\u003e Note: by default the sim-client is used to improve latency. This is useful for iterative development and testing BUT also insecure as it involves no proofs. Make sure to move to the client **with proofs** by running another just command...\n\n```bash\n# Usage: just switch-client\njust switch-client\n```\n\nCheck if the packet got through on the [Polymer IBC explorer](https://sepolia.polymer.zone/packets).\n\n\n## 💻 Develop your custom application\n\nThe main work for you as a developer is to develop the contracts that make up your cross-chain logic.\n\nYou can use the contracts in the \"/contracts/base\" directory as base contracts for creating IBC enabled contracts that can either send packets over the universal channel or create their own channel to send packets over.\n\nA complete walkthrough on how to develop these contracts is provided in the [official Polymer documentation](https://docs.polymerlabs.org/docs/build/ibc-solidity/).\n\n## 🕹️ Interaction with the contracts\n\nWhen the contracts are ready, you can go ahead and interact with the contracts through scripts. There is a Justfile to for the most common commands, with the underlying scripts in the /scripts folder.\n\nThe `/private` folder within the scripts folder has scripts that you're unlikely to need to touch. The only scripts you'll (potentially) be interacting with are:\n\nThere's three types of default scripts in the project:\n\n- The `deploy.js` allows you to deploy your application contract. You may want to add additional deployment logic to the Hardhat script.\n- In the `/contracts` folder you'll find `arguments.js` to add your custom constructor arguments for automated deployment with the `deploy.js` script.\n- The `send-packet.js` script sends packets over an existing custom channel, and `send-universal-packet.js` is specifically for sending packets over a universal channel. You might want to add additional logic before or after sending the packet to cusotmize your application.\n\nFor most of the actions above and more, there are just recipes that combine related logic and update the configuation file in an automated way.\n\n\u003e **Note**: These are the default scripts provided. They provide the most generic interactions with the contracts to deploy, create channels and send packets. For more complicated use cases you will want to customize the scripts to your use case. See [advanced usage](#🦾-advanced-usage) for more info.\n\n### Deploy\n\nBefore deploying, make sure to update the config.json with your contract type to deploy for each of the chain you wish to deploy to.\n\n#### Set contracts to config\n\nDo this by running:\n\n```bash\n# Usage: just set-contracts [chain] [contract_type] [universal]\njust set-contracts optimism MyContract true\n```\n\nto deploy _MyContract_ artefact to the Optimism (Sepolia) chain.\n\n\u003e **IMPORTANT**: This is where you set if your contract uses universal or custom channels. Make sure this corresponds to the base contract you've inherited from when developing your application (UniversalChanIbcApp or CustomChanIbcApp).\n\n#### Constructor arguments\n\nBy default any application inheriting a base IBC application contract will need a dispatcher or universal channel handler address passed into the constructor. Obviously you might have other constructor arguments you may want to add. To still make use of the `just deploy source destination` recipe, add your arguments to the arguments.js file\n\n```javascript title=\"/contracts/arguments.js\"\nmodule.exports = {\n    \"XCounter\": [],\n    \"XCounterUC\": [],\n    // Add your contract types here, along with the list of custom constructor arguments\n    // DO NOT ADD THE DISPATCHER OR UNIVERSAL CHANNEL HANDLER ADDRESSES HERE!!!\n    // These will be added in the deploy script at $ROOT/scripts/deploy.js\n};\n```\n\n#### Finally: deploy\n\nThen run:\n\n```bash\n# Usage: just deploy [source] [destination]\njust deploy optimism base\n```\n\nwhere the script will automatically detect whether you are using custom or universal IBC channels.\n\nThe script will take the output of the deployment and update the config file with all the relevant information.\n\nBefore moving on, you'll want to check if the variables in your .env and config files line up with what is stored in the actual deployed contracts... especially when you're actively playing around with different configuration files and contracts.\n\nTo do a sanity check, run:\n```bash\n# Usage: just sanity-check\njust sanity-check\n```\n\n### Create a channel\n\nIf you're **using universal channels, channel creation is not required**. Your contract will send and receive packet data from the Universal channel handler contract which already has a universal channel to send packets over. You can directly proceed to sending (universal) packets in that case.\n\nTo create a custom channel, run:\n\n```bash\njust create-channel\n```\n\nThis creates a channel between base and optimism. Note that the **ORDER MATTERS**; if you picked optimism as the source chain (first argument) above, by default it will create the channel from optimism and vice versa.\n\nThe script will take the output of the channel creation and update the config file with all the relevant information.\n\nCheck out the [channel tab in the explorer](https://sepolia.polymer.zone/channels) to find out if the correct channel-id's related to your contracts were updated in the config.\n\n### Send packets\n\nFinally Run:\n\n```bash\n# Usage: just send-packet\njust send-packet optimism \n```\n\nto send a packet over a channel (script looks at the config's isUniversal flag to know if it should use the custom or universal packet). You can pick either optimism or base to send the packet from.\n\n## Verify, don't trust\n\nAs a starter value, the sim-client is used to improve latency. **The sim-client is useful for iterative development and testing BUT also insecure as it involves no proofs**. Make sure to move to the client **with proofs** by running another just command...\n\n```bash\n# Usage: just switch-client\njust switch-client\n```\n\nThis will use the op-stack client with proofs, making sure that the relayer is proving what is being submitted every step along the way, ensuring there's no trust assumption on the relayer.\n\nAn overview of the different clients can be found in `ibc.json`:\n```json\n{\n    \"optimism\": {\n        \"sim-client\": {\n            \"canonConnFrom\": \"connection-0\",\n            \"canonConnTo\": \"connection-1\",\n            \"universalChannel\": \"channel-10\"\n        },\n        \"op-client\": {\n            \"canonConnFrom\": \"connection-8\",\n            \"canonConnTo\": \"connection-9\",\n            \"universalChannel\": \"channel-16\"\n        }\n    },\n    \"base\": {\n        \"sim-client\" : {\n            \"canonConnFrom\": \"connection-4\",\n            \"canonConnTo\": \"connection-5\",\n            \"universalChannel\": \"channel-11\"\n        },\n        \"op-client\": {\n            \"canonConnFrom\": \"connection-10\",\n            \"canonConnTo\": \"connection-11\",\n            \"universalChannel\": \"channel-17\"\n        }\n    }\n}\n```\n\n## 🦾 Advanced usage\n\nFor advanced users, there's multiple custimizations to follow. These includes configuring the config.json manually and/or running the scripts without using just.\n\nFor example, the last action to send a packet on a universal channel could be executed with this command:\n\n```bash\nnpx hardhat run scripts/send-universal-packet.js --network base\n```\n\nTo send a universal packet from the contract specified in the config.sendUniversalPacket field in the config.\n\n## 🤝 Contributing\n\nWe welcome and encourage contributions from our community! Here’s how you can contribute.\n\nTake a look at the open issues. If there's an issue that has the _help wanted_ label or _good first issue_, those are up for grabs. Assign yourself to the issue so people know you're working on it.\n\nAlternatively you can open an issue for a new idea or piece of feedback.\n\nWhen you want to contribute code, please follow these steps:\n\n1. **Fork the Repository:** Start by forking this repository.\n2. **Apply the improvements:** Want to optimize something or add support for additional developer tooling? Add your changes!\n3. **Create a Pull Request:** Once you're ready and have tested your added code, submit a PR to the repo and we'll review as soon as possible.\n\n## 💡 Questions or Suggestions?\n\nFeel free to open an issue for questions, suggestions, or discussions related to this repository. For further discussion as well as a showcase of some community projects, check out the [Polymer developer forum](https://forum.polymerlabs.org).\n\nThank you for being a part of our community!\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzewebdev1337%2Fibc-app-solidity-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzewebdev1337%2Fibc-app-solidity-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzewebdev1337%2Fibc-app-solidity-template/lists"}