0

In the "Deploy & run Transactions" section of remix.ethereum.org I can change the account before I deploy a contract - and the selected account is the owneer of the deployed contract. That's fine. But in the "File Explorer" section I cannot select, with which account a (ethers) script is running. msg.sender of a script is always the first account of the "Deploy & run Transactions" section. How can I change the sender address?

1
  • Show us some code and config, when u send a transaction you can change ‚from‘, or maybe use connect(<signer>)
    – Majd TL
    Commented Dec 5, 2021 at 15:53

1 Answer 1

2

@Majd TL, Thanks for the hint. My mistake: I was looking for a setting in remix. In fact, the solution is within the script. Instead of:

const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner()

... i can use e.g.

const signer = (new ethers.providers.Web3Provider(web3Provider)).getSigner(2) 

... to make the third account to msg.sender address.

Doc: https://docs.ethers.io/v4/cookbook-providers.html

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.