Wallet Rewards
In this guide, you’ll learn how to check Fee Pool rewards for your customers.
To check the available and collected rewards for a wallet, you can use the pendingReward
method from the Fee Pool’s smart contract.
How to Call Smart Contract?
You can interact with the Fee Pool smart contract using your preferred library, such as viem
for Node.js or React. This method will return two values:
pendingRewards
: The rewards that are available for the depositor to claim.collectedRewards
: The total amount of rewards the depositor has ever claimed.
import { createPublicClient, http } from 'viem'
import { holesky } from 'viem/chains'
const publicClient = createPublicClient({
chain: holesky,
transport: http()
})
const FEE_POOL_ADDRESS = "0xe876FF5DAe83cd04484Dd7d590b06E28Ac31F248"
const DEPOSITOR_ADDRESS = "0x1eC7fa23a8468f1F3a135BFeFe6D678E1657Ee65"
const [pendingRewards, collectedRewards] = await publicClient.readContract({
address: FEE_POOL_ADDRESS,
abi: [
{
"inputs": [
{
"internalType": "address",
"name": "depositorAddress",
"type": "address"
}
],
"name": "pendingReward",
"outputs": [
{
"internalType": "uint256",
"name": "pendingRewards",
"type": "uint256"
},
{
"internalType": "uint256",
"name": "collectedRewards",
"type": "uint256"
}
],
"stateMutability": "view",
"type": "function"
}
],
functionName: 'pendingReward',
args: [DEPOSITOR_ADDRESS]
})
console.log("pendingRewards", pendingRewards)
console.log("collectedRewards", collectedRewards)
Fee Pool Smart Contract
Here you can find the interface of pendingRewards
method in Solidity:
/**
* @notice The amount of rewards a depositor can withdraw, and all rewards they have ever withdrawn
* @dev Reverts if `depositorAddress` is not set (depositorAddress must be set).
* @param depositorAddress The depositor address
* @return pendingRewards The current amount available for withdrawal by the depositor
* @return collectedRewards The total amount ever withdrawn by the depositor
*/
function pendingReward(address depositorAddress) external view returns (
uint256 pendingRewards,
uint256 collectedRewards
);
Checking Wallet Rewards on Etherscan
If you prefer not to write code to check the rewards, you can easily do so using Etherscan. Here’s a step-by-step guide using stakefish's fee pool on Holesky.
Step 1: Open the Contract on Etherscan
Navigate to the contract on Etherscan and select the Contract tab. From there, click on Read as Proxy to view the available read methods.
Step 2: Use the pendingReward
Method
In the list of contract methods, find the pendingReward function. Input your depositor address and click Query.
Step 3: Check the Results
Once you query the method, you will see two values returned under the Query button:
- Pending rewards: The amount you can currently claim.
- Already claimed rewards: The total rewards already withdrawn.
Step 4: Convert Values from Wei to Ether
All values returned by the smart contract are in wei (1 Ether = 10¹⁸ wei). To convert the value to Ether, divide the result by 10¹⁸.
Example:
If the pendingRewards
value is 1000000000000000000
, the equivalent in Ether is 1 Ether.
Updated 2 months ago