Skip to content
Discussion options

You must be logged in to vote

@anasqurreshhi You're getting this error:

solidity OwnableUnauthorizedAccount(0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266)

because your deployment script uses vm.startBroadcast(), which makes all deployments and function calls originate from the broadcast signer, not from the Foundry test address.

So during tests:

  • The DSC contract is deployed by the broadcast address.

  • That broadcast address becomes the owner.

  • The test continues running as the default Foundry test account (0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266).

  • When transferOwnership is executed, the caller is not the owner, so it reverts.


Fix:

Do not broadcast when running inside tests. Only broadcast during real deployments.

Replies: 3 comments 6 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
4 replies
@anasqurreshhi
Comment options

@EngrPips
Comment options

@anasqurreshhi
Comment options

@EngrPips
Comment options

Comment options

You must be logged in to vote
2 replies
@EngrPips
Comment options

@anasqurreshhi
Comment options

Answer selected by anasqurreshhi
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