Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix ethers6 #5188

Merged
merged 4 commits into from
Oct 31, 2024
Merged

fix ethers6 #5188

merged 4 commits into from
Oct 31, 2024

Conversation

yann300
Copy link
Contributor

@yann300 yann300 commented Sep 13, 2024

And the script need to ne updated...
from deploy_with_ethers.ts:

console.log(`address: ${await result.getAddress()}`)

use getAddress.

and from the script ethers-lib.ts:

import { ethers } from 'ethers'

/**
 * Deploy the given contract
 * @param {string} contractName name of the contract to deploy
 * @param {Array<any>} args list of constructor' parameters
 * @param {Number} accountIndex account index from the exposed account
 * @return {Contract} deployed contract
 */
export const deploy = async (contractName: string, args: Array<any>, accountIndex?: number): Promise<ethers.Contract> => {    

  console.log(`deploying ${contractName}`)
  // Note that the script needs the ABI which is generated from the compilation artifact.
  // Make sure contract is compiled and artifacts are generated
  const artifactsPath = `browser/contracts/artifacts/${contractName}.json` // Change this for different path

  const metadata = JSON.parse(await remix.call('fileManager', 'getFile', artifactsPath))
  // 'web3Provider' is a remix global variable object
    
  const signer = await (new ethers.BrowserProvider(web3Provider)).getSigner(accountIndex)

  const factory = new ethers.ContractFactory(metadata.abi, metadata.data.bytecode.object, signer)
  const contract = await factory.deploy(...args)   
  // The contract is NOT deployed yet; we must wait until it is mined
  await contract.waitForDeployment()
  return contract
}

Base automatically changed from scriptrunner to master October 31, 2024 08:38
@bunsenstraat bunsenstraat merged commit eced8cd into master Oct 31, 2024
8 of 27 checks passed
@bunsenstraat bunsenstraat deleted the script-runner-ethers6 branch October 31, 2024 08:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants