Skip to content

Commit

Permalink
Use inline assembly sstore(0, caller()) to store the contract deplo…
Browse files Browse the repository at this point in the history
…yer's address (i.e., msg.sender) in the `owner` slot (0).
  • Loading branch information
imsoso committed Nov 5, 2024
1 parent 1b15ab2 commit 1686953
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion solidity-scripting/src/W4D3/MyWallet.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@ contract MyWallet {

constructor(string memory _name) {
name = _name;
owner = msg.sender;

assembly {
sstore(0, caller())
}
}

function transferOwnership(address _addr) public auth {
Expand Down

0 comments on commit 1686953

Please sign in to comment.