Skip to content

reason: 'Contract with a Signer cannot override from', #3327

Answered by ricmoo
AmazingAng asked this question in Q&A
Discussion options

You must be logged in to vote

This is very intentional.

A contract attached to a Signer performs all its operations (including reads) as that Signer. This prevents mistakes from accidentally passing in from for a request and getting a result that would not reflect that Signer.

A contract connected to a provider has no strong attachment to a specific account, so it allows overriding it.

Another method I would recommend is using contract.connect(fromAddress).transfer.staticCall(…). This highlights the value of locking in a Signer; the instance returned from contract.connect(fromAddress) can now be passed to another function which accepts a Contract object, and all operations performed by that function would “creep” outs…

Replies: 3 comments 7 replies

Comment options

You must be logged in to vote
3 replies
@AmazingAng
Comment options

@ricmoo
Comment options

@AmazingAng
Comment options

Answer selected by AmazingAng
Comment options

You must be logged in to vote
3 replies
@zemse
Comment options

zemse Dec 12, 2022
Collaborator

@Haianh9999
Comment options

@zemse
Comment options

zemse Dec 14, 2022
Collaborator

Comment options

You must be logged in to vote
1 reply
@Haianh9999
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants
Converted from issue

This discussion was converted from issue #3326 on September 02, 2022 19:00.