0

I have a custom proxy. Writing a deployment script for Buidler. Know how to do something in Truffle but not sure how to do the equivalent in Buidler.

Truffle

let testContract = await deployer.deploy(TestContract);
let customProxy = await deployer.deploy(CustomProxy, testContract.address, <param>);
let testContractCast = await TestContract.at(customProxy.address);

Buidler

let testContract = await deployContract(wallet, TestContract);
let customProxy = await deployContract(wallet, CustomProxy, [testContract.address, <param>])
let testContractCast = ???
0

I haven't tried this, but it should work according to the documentation. Please let us know if it does indeed work.

As described in https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ethers#environment-extensions, the buidler-ethers plugin adds a getContractAt object to the ethers object.

What that means for you would be

  1. Install the plugin if not yet done.
$ npm install --save-dev @nomiclabs/buidler-ethers 'ethers@^5.0.0'

And add the following statement to your buidler.config.js:

usePlugin("@nomiclabs/buidler-ethers");
  1. Now you can use it in your script:
const myEthersContract = await ethers.getContractAt(nameOrAbi, atAddress);
4
  • i'm getting a function selector was not recognized and there's no fallback function error when I do this. Buidler thinks i'm linking up with the proxy abi even though i need to use the implementation contract ABI @markus – Michael C Oct 14 '20 at 19:01
  • @MichaelC are you using TestContract.abi for the nameOrAbi ? – Markus - soliditydeveloper.com Oct 14 '20 at 20:12
  • yes, TestContract.abi – Michael C Oct 14 '20 at 20:24
  • the issue was that i was using the receive keyword instead of the fallback keyword in my proxy – Michael C Oct 14 '20 at 22:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.