0/5
## Solution: Last Deposit Block To get the last block that the user deposited, we need to call the `RocketStorage` contract. First, return the value from `rStorage.getUint` ```solidity return rStorage.getUint(); ``` Next, we need to figure out what key we need to pass in, by looking at the `rETH` contract. Inside of the `rETH` contract, in the `_beforeTokenTransfer` function, the following line of code: ```solidity uint256 lastDepositBlock = getUint(key); ``` gets the last block that the user deposited. The code to compute the key is above: ```solidity bytes32 key = keccak256(abi.encodePacked("user.deposit.block", from)); ``` Let's copy this line of code and paste it into our code. Now, change the `from` address to `user`: ```solidity keccak256(abi.encodePacked("user.deposit.block", user)); ``` The code should look like this: ```solidity return rStorage.getUint( keccak256(abi.encodePacked("user.deposit.block", user)) ); ``` Now let's execute the test. The function that we're testing is called `test_getLastDepositBlock`. The command is: ```bash forge test --fork-url $FORK_URL --match-path test/exercise-swap-rocket-pool.sol --match-test test_getLastDepositBlock -vvv ``` The test should now pass.
A beginner's guide to retrieving the last deposit block in a Solidity smart contract. The lesson covers understanding how to retrieve the last deposit block using the RocketStorage contract and how to implement the logic in the RocketPool contract.
Previous lesson
Previous
Next lesson
Next
Give us feedback
Course Overview
About the course
Rocket Pool rETH staking, yield mechanisms, trading options, and contract architecture
How to distribute rewards and calculate rETH/ETH exchange rate
How to acquire and redeem rETH
Integrating rETH into DeFi protocols like AAVE V3
How to how to create leveraged ETH positions using rETH
How to provide rETH as liquidity to Balancer and Aura
Getting the USD price of rETH using Rocket Pool NAV oracle
Re-staking with EigenLayer
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 12, 2025
Stay in the loop with the latest Rocket Pool updates and connect with over 5,000 developers in the community.
Solidity Developer
Rocket Pool rETH IntegrationDuration: 4min
Duration: 48min
Duration: 57min
Duration: 30min
Duration: 7min
Duration: 23min
Duration: 6min
Course Overview
About the course
Rocket Pool rETH staking, yield mechanisms, trading options, and contract architecture
How to distribute rewards and calculate rETH/ETH exchange rate
How to acquire and redeem rETH
Integrating rETH into DeFi protocols like AAVE V3
How to how to create leveraged ETH positions using rETH
How to provide rETH as liquidity to Balancer and Aura
Getting the USD price of rETH using Rocket Pool NAV oracle
Re-staking with EigenLayer
DeFi Developer
$75,000 - $200,000 (avg. salary)
Smart Contract Engineer
$100,000 - $150,000 (avg. salary)
Web3 developer
$60,000 - $150,000 (avg. salary)
Smart Contract Auditor
$100,000 - $200,000 (avg. salary)
Blockchain Financial Analyst
$100,000 - $150,000 (avg. salary)
Web3 Developer Relations
$85,000 - $125,000 (avg. salary)
Last updated on May 12, 2025
Testimonials
Read what our students have to say about this course.
Chainlink
Chainlink
Gustavo Gonzalez
Solutions Engineer at OpenZeppelin
Francesco Andreoli
Lead Devrel at Metamask
Albert Hu
DeForm Founding Engineer
Radek
Senior Developer Advocate at Ceramic
Boidushya
WalletConnect
Idris
Developer Relations Engineer at Axelar