npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

rain-x-deploy

v1.0.26

Published

Package to deploy rain-protocol contracts across chains

Downloads

32

Readme

Rain Cross Network Deploy

Utility to deploy Rain Protocol Contracts to EVM based Networks. The dependency provides you with a way to get the transaction data for contract deployment of a particular Rain Contract which you can submit via a signer .

Installation

npm install rain-x-deploy

Usage

import import (ESM, TypeScript):

import {getContractDeployTxData, DISpair, RainNetworks } from "rain-x-deploy"

Get Transaction Data for Contract Deployment

You can then encode this data inside a transaction object and submit the transaction . If you intend to use it with frontend library like React or Svelte :

Deploy Rain Contracts :

To deploy rain contracts use getContractDeployTxData :

import {getContractDeployTxData, DISpair, RainNetworks } from "rain-x-deploy"  
import { ethers } from "ethers"; 

const deployContract = async () => {
    if(!window.ethereum) alert("Provider not injected")  
    
    //Initialize provider
    const provider = new ethers.providers.Web3Provider(window.ethereum) 
    
    // Get the signer
    const signer = await provider.getSigner()  
    
    // DISpair contracts of the originating network
    const fromDIS: DISpair = {
      interpreter:'0x24035b15e908551a2e1b4f435384d9485766d296',
      store:'0xd28543743f017045c9448ec6d82f5568a0f26918',
      deployer:'0x32ba42606ca2a2b91f28ebb0472a683b346e7cc7'
     }  
     
     // DISpair contracts of the target network
     const toDIS: DISpair = {
        interpreter : '0xeBEA638926F7BA49c0a1808e0Ff3B6d78789b153' ,
        store : '0xB92fd23b5a9CBE5047257a0300d161D449296C03' , 
        deployer : '0x34a81e8bc3e2420efc8ae84d35045c0326b00bdc'
     } 
     // Get contract deployment tx data for target network
     const txData = await getContractDeployTxData(
        RainNetworks.Mumbai, // originating network
        fromDIS, // DISpair originating network
        toDIS, // DISpair target network
        "0xacf6069f4a6a9c66db8b9a087592278bbccde5c3" //Origin contract address to x-deploy
      )
    
    // Submit the transaction
    await signer.sendTransaction({
      data :txData
    })
}

In case the originating and target networks are same(meaning you are simply trying to clone a contract on the network) you can pass the same DISpair as fromDIS and toDIS.

Eg :

const DISpair = {
    interpreter : '0xeBEA638926F7BA49c0a1808e0Ff3B6d78789b153' ,
    store : '0xB92fd23b5a9CBE5047257a0300d161D449296C03' , 
    deployer : '0x34a81e8bc3e2420efc8ae84d35045c0326b00bdc'
} 

// Pass the same DIS as origin and target to clone the contract.
 const txData = await getContractDeployTxData(
    RainNetworks.Ethereum, // originating network
    DISpair, 
    DISpair, 
    "0xce0a4f3e60178668c89f86d918a0585ca80e0f6d" //Origin contract address to x-deploy
  )

Deploy RainterpreterExpressionDeployer

To deploy RainterpreterExpressionDeployer use getDeployerDeployTxData :

const fromDIS = {
      interpreter:'0x24035b15e908551a2e1b4f435384d9485766d296',
      store:'0xd28543743f017045c9448ec6d82f5568a0f26918',
      deployer:'' // Empty string for deployer
   }   

const toDIS = {
    interpreter : '0xeBEA638926F7BA49c0a1808e0Ff3B6d78789b153' ,
    store : '0xB92fd23b5a9CBE5047257a0300d161D449296C03' , 
    deployer : '' // Empty string for deployer
   }

const txData = await getDeployerDeployTxData(
    RainNetworks.Mumbai, // Originating network
    fromDIS, // Originating network DIS
    toDIS, // Target network DIS
    "0x32ba42606ca2a2b91f28ebb0472a683b346e7cc7" // Deployer address from originating network
  ) 

Supported Networks

You can deploy contracts to any of the following networks by importing RainNetworks enum.

export enum RainNetworks{
    Mumbai = 'mumbai' ,
    Polygon = 'polygon',
    Ethereum = 'ethereum'
} 

Get network for chain Id .

const fromNetwork = getRainNetworkForChainId(80001) // For Mumbai 
const toNetwork = getRainNetworkForChainId(137) // For Polygon