Code Monkey home page Code Monkey logo

x-ballot-nft's Introduction

Template for IBC enabled Soldity contracts

This repo provides a starter project to build IBC enabled Solidity contracts that connect rollups to one another Polymer Hub, through the vIBC core contracts.

The repo is compatible with both Hardhat and Foundry development environments.

Find more information on building with (v)IBC and Polymer in the Polymer documentation.

Install dependencies

To compile your contracts and start testing, make sure that you have all dependencies installed.

From the root directory run:

forge install

to install the vIBC core smart contracts as a dependency.

Again from root, run:

npm install

to install some node modules as dependencies, specifically when you want to use Hardhat.

Set up your environment variables

In the .env file (you'll find it as .env.example), add your private key(s) and rename to drop the "example" in the filename. The dispatcher addresses should be correct but you could use custom ones if required.

Next, check the config.json file. This is where a lot of the parameters you need to deploy, create channels and send packets are stored.

When using the default scripts, those fields will be mostly auto-populated. Only the contract types in the deploy field must be updated when you write your own contracts.

Run the scripts

There's three types of scripts in the project:

  • deploy.js and deploy-config.js allow you to deploy your application contract
  • create-channel.js and create-channel-config.js creates a channel
  • send-packet.js sends packets over an existing custom channel, and send-universal-packet.js is specifically for sending packets over a universal channel

For every script you'll find a field in the config.json!!

Deploy

Run:

# format node scripts/deploy-config.js [source] [destination] [universal-channel-bool]
node scripts/deploy-config.js optimism base true

for an application that will use a universal channel, or:

# or 
node scripts/deploy-config.js optimism base false

for an application that uses custom channels.

To deploy instances of the contracts on optimism as the source and base as the destination chains. (You can also switch the order)

Also this script will take the output of the deployment and update the config file with all the relevant information.

Create a channel

If 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.

To create a custom channel, run:

node scripts/create-channel-config.js

To create 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.

Also this script will take the output of the channel creation and update the config file with all the relevant information.

Check out the channel tab in the explorer to find out if the correct channel-id's related to your contracts were updated in the config.

Send packets

Finally Run:

npx hardhat run scripts/send-universal-packet.js --network optimism

to send a packet over a universal channel. You can pick either optimism or base to send the packet from.

Or run:

npx hardhat run scripts/send-packet.js --network optimism

to send a packet over a custom channel. You can pick either optimism or base to send the packet from.

NOTE Make sure to align the --network flag value to be compatible with your config values either on optimism or base.

x-ballot-nft's People

Contributors

tmsdkeys avatar

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.