0

I want to use an account different than the default account to deploy a contract.

I'm looking for the equivalent of ethers connect() function and I can't seem to find it.

Currently deploying like so contract = await Contract.new() and I'm just looking for a way to specify the deploying account.

Does truffle have that option?

1 Answer 1

1

In Truffle when calling a transaction the last parameter has an optional dictionary with the transaction's parameters. For example something like this should work:

contract = await Contract.new(
  param1,
  ..more params..,
  { 
    from: "0xaabbccdd.....eeff",
    gas: "1234567",
  })

For more details see the documentation.

3
  • What would that look like if I want to send parameters to the contract as well? For example, instead of Contract.new(addr)
    – Roy Toledo
    Commented May 21, 2022 at 2:08
  • 1
    @RoyToledo I've edited the answer to include parameters.
    – Ismael
    Commented May 21, 2022 at 16:54
  • Nice. Even better 😉
    – Roy Toledo
    Commented May 22, 2022 at 17:04

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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