20,000 USDC
View results
Submission Details
Severity: gas
Valid

# [G-21] Use assembly to write address storage values

Summary

[G-21] Use assembly to write address storage values

By using assembly to write to address storage values, you can bypass some of these operations and lower the gas cost of writing to storage. Assembly code allows you to directly access the Ethereum Virtual Machine (EVM) and perform low-level operations that are not possible in Solidity.

example of using assembly to write to address storage values:

contract MyContract {
address private myAddress;
function setAddressUsingAssembly(address newAddress) public {
assembly {
sstore(0, newAddress)
}
}
}
file: /src/Beedle.sol
15 function _afterTokenTransfer(address from, address to, uint256 amount)

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Beedle.sol#L15

file: /src/Lender.sol
101 feeReceiver = _feeReceiver;

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/Lender.sol#L101

file: /src/utils/Ownable.sol
20 owner = _owner;

https://github.com/Cyfrin/2023-07-beedle/blob/main/src/utils/Ownable.sol#L20

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.