How to use the hardhat.ethers.getContractFactory function in hardhat

To help you get started, we’ve selected a few hardhat 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 cosmos / gravity-bridge / solidity / tests_mainnet_fork / uniswap-logic.ts View on Github external
gravity,
    testERC20,
    checkpoint: deployCheckpoint,
  } = await deployContracts(gravityId, validators, powers, powerThreshold);

  // First we deploy the logic batch middleware contract. This makes it easy to call a logic
  // contract a bunch of times in a batch.
  const SimpleLogicBatchMiddleware = await ethers.getContractFactory(
    "SimpleLogicBatchMiddleware"
  );
  const logicBatch = (await SimpleLogicBatchMiddleware.deploy()) as SimpleLogicBatchMiddleware;
  // We set the ownership to gravity so that nobody else can call it.
  await logicBatch.transferOwnership(gravity.address);

  // Then we deploy the actual logic contract.
  const TestUniswapLiquidityContract = await ethers.getContractFactory(
    "TestUniswapLiquidity"
  );
  const logicContract = (await TestUniswapLiquidityContract.deploy(
    uniswap_router_address
  )) as TestUniswapLiquidity;
  // We set its owner to the batch contract.
  await logicContract.transferOwnership(logicBatch.address);


  let logic_contract_balance_start = await usdc_eth_lp.balanceOf(logicContract.address)


  console.log(`Logic Contract Balance ${logic_contract_balance_start}`);


  // Transfer out to Cosmos, locking coins
github cosmos / gravity-bridge / solidity / tests_mainnet_fork / uniswap-logic.ts View on Github external
// ========================
  const signers = await ethers.getSigners();
  const gravityId = ethers.utils.formatBytes32String("foo");
  // This is the power distribution on the Cosmos hub as of 7/14/2020
  let powers = examplePowers();
  let validators = signers.slice(0, powers.length);
  const powerThreshold = 6666;
  const {
    gravity,
    testERC20,
    checkpoint: deployCheckpoint,
  } = await deployContracts(gravityId, validators, powers, powerThreshold);

  // First we deploy the logic batch middleware contract. This makes it easy to call a logic
  // contract a bunch of times in a batch.
  const SimpleLogicBatchMiddleware = await ethers.getContractFactory(
    "SimpleLogicBatchMiddleware"
  );
  const logicBatch = (await SimpleLogicBatchMiddleware.deploy()) as SimpleLogicBatchMiddleware;
  // We set the ownership to gravity so that nobody else can call it.
  await logicBatch.transferOwnership(gravity.address);

  // Then we deploy the actual logic contract.
  const TestUniswapLiquidityContract = await ethers.getContractFactory(
    "TestUniswapLiquidity"
  );
  const logicContract = (await TestUniswapLiquidityContract.deploy(
    uniswap_router_address
  )) as TestUniswapLiquidity;
  // We set its owner to the batch contract.
  await logicContract.transferOwnership(logicBatch.address);
github OffchainLabs / arbitrum / packages / arb-bridge-peripherals / scripts / deploy_token_bridge_l2.ts View on Github external
const main = async () => {
  const accounts = await ethers.getSigners()
  const StandardArbERC20 = await ethers.getContractFactory('StandardArbERC20')
  const StandardArbERC777 = await ethers.getContractFactory('StandardArbERC777')

  const standardArbERC20Logic = await StandardArbERC20.deploy()
  await standardArbERC20Logic.deployed()
  console.log(`erc20 logic at ${standardArbERC20Logic.address}`)

  const standardArbERC777Logic = await StandardArbERC777.deploy()
  await standardArbERC777Logic.deployed()
  console.log(`erc777 logic at ${standardArbERC777Logic.address}`)

  // const ProxyAdmin = await ethers.getContractFactory('ProxyAdmin')
  // const proxyAdmin = await ProxyAdmin.deploy()
  // await proxyAdmin.deployed()
  // console.log("Admin proxy deployed to", proxyAdmin.address)

  const UpgradeableBeacon = await ethers.getContractFactory('UpgradeableBeacon')
github cosmos / gravity-bridge / solidity / test-utils / index.ts View on Github external
export async function deployContracts(
  gravityId: string = "foo",
  validators: Signer[],
  powers: number[],
  powerThreshold: number,
  opts?: DeployContractsOptions
) {
  const TestERC20 = await ethers.getContractFactory("TestERC20A");
  const testERC20 = (await TestERC20.deploy()) as TestERC20A;

  const Gravity = await ethers.getContractFactory("Gravity");

  const valAddresses = await getSignerAddresses(validators);

  const checkpoint = makeCheckpoint(valAddresses, powers, 0, gravityId);

  const gravity = (await Gravity.deploy(
    gravityId,
    powerThreshold,
    valAddresses,
    powers
  )) as Gravity;

  await gravity.deployed();

  return { gravity, testERC20, checkpoint };
}
github OffchainLabs / arbitrum / packages / arb-bridge-peripherals / scripts / deploy_token_bridge_l1.ts View on Github external
const main = async () => {
  const accounts = await ethers.getSigners()

  const inboxAddress =
    process.env.INBOX_ADDRESS || '0xD71d47AD1b63981E9dB8e4A78C0b30170da8a601'

  if (inboxAddress === '' || inboxAddress === undefined)
    throw new Error('Please set inbox address! INBOX_ADDRESS')

  const EthERC20Bridge = await ethers.getContractFactory('EthERC20Bridge')

  if (
    deployments.buddyDeployer === '' ||
    deployments.standardArbERC20 === '' ||
    deployments.standardArbERC777 === ''
  )
    throw new Error("Deployments.json doesn't include the necessary addresses")

  const maxSubmissionCost = 0
  const gasPrice = 0
  const maxGas = 100000000000
  const ethERC20Bridge = await EthERC20Bridge.deploy()

  console.log('EthERC20Bridge logic deployed to:', ethERC20Bridge.address)
  const l2Provider = new providers.JsonRpcProvider(
    'https://kovan4.arbitrum.io/rpc'
github OffchainLabs / arbitrum / packages / arb-bridge-peripherals / scripts / deploy_token_bridge_l1.ts View on Github external
const ArbTokenBridge = (
    await ethers.getContractFactory('ArbTokenBridge')
  ).connect(l2Signer)

  const arbTokenBridge = await ArbTokenBridge.deploy()
  console.log('L2 ArbBridge logic deployed to:', arbTokenBridge.address)
  await arbTokenBridge.deployed()

  const L1TransparentUpgradeableProxy = await ethers.getContractFactory(
    'TransparentUpgradeableProxy'
  )
  const L2TransparentUpgradeableProxy = (
    await ethers.getContractFactory('TransparentUpgradeableProxy')
  ).connect(l2Signer)

  const L1ProxyAdmin = await ethers.getContractFactory('ProxyAdmin')
  const L2ProxyAdmin = (await ethers.getContractFactory('ProxyAdmin')).connect(
    l2Signer
  )
  console.log('Deploying l1ProxyAdmin:')

  const l1ProxyAdmin = await L1ProxyAdmin.deploy()
  console.log('L1 proxy admin at', l1ProxyAdmin.address)
  await l1ProxyAdmin.deployed()

  const ethERC20BridgeProxy = await L1TransparentUpgradeableProxy.deploy(
    ethERC20Bridge.address,
    l1ProxyAdmin.address,
    '0x'
  )
  await ethERC20BridgeProxy.deployed()
github OffchainLabs / arbitrum / packages / arb-bridge-eth / scripts / deploy.ts View on Github external
export default async function deploy_contracts(): Promise<
  Record
> {
  const OneStepProof = await ethers.getContractFactory('OneStepProof')
  const OneStepProof2 = await ethers.getContractFactory('OneStepProof2')
  const OneStepProofHash = await ethers.getContractFactory('OneStepProofHash')
  const ChallengeFactory = await ethers.getContractFactory('ChallengeFactory')
  const NodeFactory = await ethers.getContractFactory('NodeFactory')
  const Rollup = await ethers.getContractFactory('Rollup')
  const RollupCreatorNoProxy = await ethers.getContractFactory(
    'RollupCreatorNoProxy'
  )

  const oneStepProof = await OneStepProof.deploy()
  logDeploy('OneStepProof', oneStepProof)
  const oneStepProof2 = await OneStepProof2.deploy()
  logDeploy('OneStepProof2', oneStepProof2)
  const oneStepProof3 = await OneStepProofHash.deploy()
  logDeploy('OneStepProofHash', oneStepProof3)

  const challengeFactory = await ChallengeFactory.deploy([
    oneStepProof.address,
    oneStepProof2.address,
    oneStepProof3.address,
github OffchainLabs / arbitrum / packages / arb-bridge-eth / scripts / deploy.ts View on Github external
export default async function deploy_contracts(): Promise<
  Record
> {
  const OneStepProof = await ethers.getContractFactory('OneStepProof')
  const OneStepProof2 = await ethers.getContractFactory('OneStepProof2')
  const OneStepProofHash = await ethers.getContractFactory('OneStepProofHash')
  const ChallengeFactory = await ethers.getContractFactory('ChallengeFactory')
  const NodeFactory = await ethers.getContractFactory('NodeFactory')
  const Rollup = await ethers.getContractFactory('Rollup')
  const RollupCreatorNoProxy = await ethers.getContractFactory(
    'RollupCreatorNoProxy'
  )

  const oneStepProof = await OneStepProof.deploy()
  logDeploy('OneStepProof', oneStepProof)
  const oneStepProof2 = await OneStepProof2.deploy()
  logDeploy('OneStepProof2', oneStepProof2)
  const oneStepProof3 = await OneStepProofHash.deploy()
  logDeploy('OneStepProofHash', oneStepProof3)
github OffchainLabs / arbitrum / packages / arb-bridge-eth / scripts / deploy.ts View on Github external
export default async function deploy_contracts(): Promise<
  Record
> {
  const OneStepProof = await ethers.getContractFactory('OneStepProof')
  const OneStepProof2 = await ethers.getContractFactory('OneStepProof2')
  const OneStepProofHash = await ethers.getContractFactory('OneStepProofHash')
  const ChallengeFactory = await ethers.getContractFactory('ChallengeFactory')
  const NodeFactory = await ethers.getContractFactory('NodeFactory')
  const Rollup = await ethers.getContractFactory('Rollup')
  const RollupCreatorNoProxy = await ethers.getContractFactory(
    'RollupCreatorNoProxy'
  )

  const oneStepProof = await OneStepProof.deploy()
  logDeploy('OneStepProof', oneStepProof)
  const oneStepProof2 = await OneStepProof2.deploy()
  logDeploy('OneStepProof2', oneStepProof2)
  const oneStepProof3 = await OneStepProofHash.deploy()
  logDeploy('OneStepProofHash', oneStepProof3)

  const challengeFactory = await ChallengeFactory.deploy([
    oneStepProof.address,