@requestnetwork/xdeployer
TypeScript icon, indicating that this package has built-in type declarations

1.2.0 • Public • Published

request-xdeployer

Hardhat plugin to deploy your smart contracts across multiple Ethereum Virtual Machine (EVM) chains with the same deterministic address.

What

This repo is a fork of xdeployer It enables smart contract deployment through the CREATE2 EVM opcode. CREATE2 can be used to compute in advance the address where a smart contract will be deployed. It also decorelates the contract deployment address from the user nonce.

This plugin is used by The RN library to perform some contract deployments.

Installation

npm install --save-dev request-xdeployer @nomiclabs/hardhat-ethers @openzeppelin/contracts

Or if you are using Yarn:

yarn add --dev @requestnetwork/xdeployer @nomiclabs/hardhat-ethers @openzeppelin/contracts

Note: This plugin uses the optional chaining operator (?.). Optional chaining is not supported in Node.js v13 and below.

In your hardhat.config.ts:

import "@requestnetwork/xdeployer";

Required Plugins

Environment Extensions

This plugin does not extend the environment.

Configuration

TypeScript configuration in your hardhat.config.ts:

const config: HardhatUserConfig = {
  networks: {
    mainnet: { ... }
  },
  xdeploy: {
    salt: "YOUR_SALT_MESSAGE",
    signer: "SIGNER_PRIVATE_KEY",
    networks: ["LIST_OF_NETWORKS"],
    rpcUrls: ["LIST_OF_RPCURLS"],
    gasLimit: "GAS_LIMIT",
    deployerAddress: "0x..."
  },
};

The parameter gasLimit and deployerAddress are optional. If deployerAddress is undefined the plugin will use the default deployer contract: for more information refer to the main repo The salt parameter is a random value (32 byte string) used to create the contract address. If you have previously deployed the same contract with the identical salt, the contract creation transaction will fail due to EIP-684. For more details, see also here.

Example of configuration:

xdeploy: {
  salt: "WAGMI",
  signer: process.env.PRIVATE_KEY,
  networks: ["hardhat", "rinkeby", "kovan"],
  rpcUrls: ["hardhat", process.env.RINKEBY_URL, process.env.KOVAN_URL],
  gasLimit: 1.2 * 10 ** 6,
},

To use this plugin in your code run:

const deploymentParams = {
  contract: "MyContract",
  constructorArgs: [true, 50, "example"]
}
const deploymentResult = await hre.run('xdeploy', deploymentParams)

Deployment result format:

interface IDeploymentResult {
  network: string;                // Name of the network the contract was deployed on
  contract: string;               // Name of the deployed contract
  address: string | undefined;    // Address of the newly deployed contract (if deployment successfull)
  receipt: any;                   // Receipt of the transation 
  deployed: boolean;
  error: string | undefined;      // Error if any
}

Dependents (0)

Package Sidebar

Install

npm i @requestnetwork/xdeployer

Weekly Downloads

0

Version

1.2.0

License

MIT

Unpacked Size

52.2 kB

Total Files

36

Last publish

Collaborators

  • mantisclone
  • benjlevesque
  • request-bot
  • adamdowson
  • yomarion