@0xsequence/deployer 中文文档教程

发布于 3年前 浏览 23 项目主页 更新于 3年前

@0xsequence/deployer

通过 CREATE2 使用通用部署器部署合约,允许合约在任何 EVM 链上具有相同的地址。

UniversalDeployer 适用于 Web 浏览器和 Nodejs。

有关详细信息,请参阅 0xsequence 项目页面

How to use

  1. yarn add @0xsequence/deployer
  2. Import UniversalDeployer into script
  3. Create UniversalDeployer instance
  4. Deploy contracts

如果需要在同一条链上部署同一个合约的多个实例,可以传递一个instance 编号。 如果没有传递,则默认实例编号为 0。

...
import { UniversalDeployer } from '@0xsequence/deployer'

const provider = new Web3Provider(web3.currentProvider)
const universalDeployer = new UniversalDeployer(network.name, provider)

const main = async () => {
  await universalDeployer.deploy('Factory', FactoryFactory)
  await universalDeployer.deploy('MainModuleUpgradable', MainModuleUpgradableFactory)
  await universalDeployer.deploy('GuestModule', GuestModuleFactory)

  prompt.start(`writing deployment information to ${network.name}.json`)
  await universalDeployer.registerDeployment()

  // or, await universalDeployer.getDeployment()

  prompt.succeed()
}

main()

您还可以显式传递交易参数:

...

const main = async () => {
  await universalDeployer.deploy('WalletFactory', FactoryFactory, {gasLimit: 1000000} )
  await universalDeployer.deploy('MainModuleUpgradable', MainModuleUpgradableFactory, {gasPrice: new BigNumber(10).pow(9)})
}

License

License: MIT

版权所有 (c) 2018 年至今 Horizo​​n Blockchain Games Inc.

@0xsequence/deployer

Deploy contracts using a universal deployer via CREATE2, allowing contracts to have the same address on any EVM chain.

UniversalDeployer works in both Web Browsers and Nodejs.

For more info, see 0xsequence project page.

How to use

  1. yarn add @0xsequence/deployer
  2. Import UniversalDeployer into script
  3. Create UniversalDeployer instance
  4. Deploy contracts

An instance number can be passed if multiple instance of the same contract need to be deployed on the same chain. The default instance number is 0, if none is passed.

...
import { UniversalDeployer } from '@0xsequence/deployer'

const provider = new Web3Provider(web3.currentProvider)
const universalDeployer = new UniversalDeployer(network.name, provider)

const main = async () => {
  await universalDeployer.deploy('Factory', FactoryFactory)
  await universalDeployer.deploy('MainModuleUpgradable', MainModuleUpgradableFactory)
  await universalDeployer.deploy('GuestModule', GuestModuleFactory)

  prompt.start(`writing deployment information to ${network.name}.json`)
  await universalDeployer.registerDeployment()

  // or, await universalDeployer.getDeployment()

  prompt.succeed()
}

main()

You can also pass transaction parameters explicitly :

...

const main = async () => {
  await universalDeployer.deploy('WalletFactory', FactoryFactory, {gasLimit: 1000000} )
  await universalDeployer.deploy('MainModuleUpgradable', MainModuleUpgradableFactory, {gasPrice: new BigNumber(10).pow(9)})
}

License

License: MIT

Copyright (c) 2018-present Horizon Blockchain Games Inc.

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文