How to use the ethers.ContractFactory function in ethers

To help you get started, we’ve selected a few ethers examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github leapdao / solEVM-enforcer / test / helpers / utils.js View on Github external
Utils.deployContract = async function (truffleContract, ...args) {
  // wait for RPC
  while (true) {
    try {
      await Utils.provider.getBlockNumber();
      break;
    } catch (e) {
      // ignore
    }
    await new Promise((resolve) => setTimeout(resolve, 100));
  }

  let _factory = new ethers.ContractFactory(
    truffleContract.abi,
    truffleContract.bytecode,
    Utils.wallets[0]
  );
  const contract = await _factory.deploy(...args, Utils.txOverrides);

  await contract.deployed();
  return contract;
};
github ChainSafe / ChainBridge / on-chain / evm-contracts / scripts / deploy_local.js View on Github external
async function deployEmitter() {
    try {
        // Create an instance of a Contract Factory
        let factory = new ethers.ContractFactory(EmitterContract.abi, EmitterContract.bytecode, wallet);

        // Deploy
        let contract = await factory.deploy();

        // The address the Contract WILL have once mined
        console.log("[Emitter] Contract address: ", contract.address);

        // The transaction that was sent to the network to deploy the Contract
        console.log("[Emitter] Transaction Hash: ", contract.deployTransaction.hash);

        // The contract is NOT deployed yet; we must wait until it is mined
        await contract.deployed();

        // Done! The contract is deployed.
        // EMITTER_ADDRESS = contract.address;
    } finally {
github unlock-protocol / unlock / docker / development / deploy-locks.js View on Github external
async function setUpERC20Token(provider, recipients) {
  let wallet = await provider.getSigner(0)

  let factory = new ethers.ContractFactory(
    testErc20Token.abi,
    testErc20Token.bytecode,
    wallet
  )

  let testERC20 = await factory.deploy({ gasLimit: 6000000 })
  await testERC20.deployed()

  // Once deployed, let's mint some for the recipients
  // This is required because the ERC20 Locks check the supply
  await recipients.map(async recipient => {
    console.log(`MINTING ${ERC20_MINT_AMOUNT} FOR ${recipient}`)
    await testERC20.mint(
      recipient,
      ethers.utils.parseUnits(ERC20_MINT_AMOUNT, 18),
      {
github ChainSafe / ChainBridge / on-chain / evm-contracts / scripts / cli / cmd / deployment.js View on Github external
async function deployERC20Handler(cfg) {
    const handlerFactory = new ethers.ContractFactory(ERC20HandlerContract.abi, ERC20HandlerContract.bytecode, cfg.mainWallet);
    const erc20MintableFactory = new ethers.ContractFactory(ERC20MintableContract.abi, ERC20MintableContract.bytecode, cfg.mainWallet);
    const handlerContract = await handlerFactory.deploy(constants.BRIDGE_ADDRESS);
    const erc20MintableContract = await erc20MintableFactory.deploy();

    console.log("[ERC20 Handler] Contract address: ", handlerContract.address);
    console.log("[ERC20 Handler] Transaction Hash: ", handlerContract.deployTransaction.hash);

    console.log("[ERC20 Token] Contract address: ", erc20MintableContract.address);
    console.log("[ERC20 Token] Transaction Hash: ", erc20MintableContract.deployTransaction.hash);
}
github smartcontractkit / chainlink / integration / apocalypse / index.js View on Github external
async function deployOracle(wallet, nonce, { linkTokenAddress }) {
    let oracleFactory = new ethers.ContractFactory(oracleJson.compilerOutput.abi, oracleJson.compilerOutput.evm.bytecode, wallet)
    let oracle = await oracleFactory.deploy(linkTokenAddress, { gasPrice: ethers.utils.parseUnits('50', 'gwei') })
    await oracle.deployed()
    return oracle
}
github smartcontractkit / chainlink / integration / apocalypse / scenarios / lib / contracts.js View on Github external
async function deployFluxAggregator(
  wallet,
  nonce,
  { linkTokenAddress, paymentAmount, timeout },
) {
  let description = ethers.utils.formatBytes32String('xyzzy')
  let fluxAggregatorFactory = new ethers.ContractFactory(
    fluxAggregatorJson.compilerOutput.abi,
    fluxAggregatorJson.compilerOutput.evm.bytecode.object,
    wallet,
  )
  let fluxAggregator = await fluxAggregatorFactory.deploy(
    linkTokenAddress,
    paymentAmount,
    timeout,
    2,
    description,
    {
      gasPrice: ethers.utils.parseUnits('50', 'gwei'),
    },
  )
  await fluxAggregator.deployed()
  return fluxAggregator
github smartcontractkit / chainlink / integration / apocalypse / scenarios / lib / contracts.js View on Github external
async function deployOracle(wallet, nonce, { linkTokenAddress }) {
  let oracleFactory = new ethers.ContractFactory(
    oracleJson.compilerOutput.abi,
    oracleJson.compilerOutput.evm.bytecode,
    wallet,
  )
  let oracle = await oracleFactory.deploy(linkTokenAddress, {
    gasPrice: ethers.utils.parseUnits('50', 'gwei'),
  })
  await oracle.deployed()
  return oracle
}