Skip to content

Commit

Permalink
Use inline assembly sstore(0, _addr) to update the owner slot (0)…
Browse files Browse the repository at this point in the history
… with the new address `_addr`.
  • Loading branch information
imsoso committed Nov 5, 2024
1 parent 1686953 commit 0b28b29
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion solidity-scripting/src/W4D3/MyWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ contract MyWallet {
function transferOwnership(address _addr) public auth {
require(_addr != address(0), "New owner is the zero address");
require(owner != _addr, "New owner is the same as the old owner");
owner = _addr;
assembly {
sstore(0, _addr)
}
}
}

0 comments on commit 0b28b29

Please sign in to comment.