-
Hi I was wondering how to pass contructor values into a constructor. For example, my contract constructor looks like:
In ethers I would do like this:
I saw there is also the method attach() but when to use attach? |
Beta Was this translation helpful? Give feedback.
Answered by
zemse
Jul 27, 2021
Replies: 1 comment
-
You need to pass constructor arguments only while deploying a contract. You can refer to ContractFactory docs. const factory = new ContractFactory(Exchange.abi, Exchange.bytecode, signer)
// Deploy an instance of the contract passing in constructor arguments
contract = await factory.deploy(_token);
contract.address // address of the deployed contract Once you deploy a contract, you get the But if you already have deployed a contract and have an address of the deployed contract (
Does that help? |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
ricmoo
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You need to pass constructor arguments only while deploying a contract. You can refer to ContractFactory docs.
Once you deploy a contract, you get the
contract
object like above.But if you already have deployed a contract and have an address of the deployed contract (
contract.address
), that's when you have two ways:new ethers.Contract
code that you mentioned to get thecontract
object.factory.attach
.Does that help?