15,000 USDC
View results
Submission Details
Severity: gas

Use assembly to write address storage values

Summary

[G-17] 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: /script/DeployDSC.s.sol
20 tokenAddresses = [weth, wbtc];
21 priceFeedAddresses = [wethUsdPriceFeed, wbtcUsdPriceFeed];

https://github.com/Cyfrin/2023-07-foundry-defi-stablecoin/blob/main/script/DeployDSC.s.sol#L20-L21

Support

FAQs

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