curl --request POST \
--url https://api.example.com/eth_call{
"result": {}
}Get total amount of FEN staked across all validators
curl --request POST \
--url https://api.example.com/eth_call{
"result": {}
}0x0000000000000000000000000000000000001000 (FenineSystem)0x635c8637 (no parameters)curl -X POST https://rpc.fene.app \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"method": "eth_call",
"params": [{
"to": "0x0000000000000000000000000000000000001000",
"data": "0x635c8637"
}, "latest"],
"id": 1
}'
Network Health Dashboard
async function getNetworkHealthMetrics() {
const totalStake = await contract.methods.totalNetworkStake().call();
const validators = await contract.methods.getActiveValidators().call();
const constants = await web3.getContractConstants();
// Get circulating supply (example - adjust to your token)
const totalSupply = web3.utils.toWei('1000000000', 'ether'); // 1B tokens
const stakeRatio = (BigInt(totalStake) * 100n) / BigInt(totalSupply);
const avgStakePerValidator = BigInt(totalStake) / BigInt(validators.length);
return {
totalStaked: web3.utils.fromWei(totalStake, 'ether') + ' FEN',
activeValidators: validators.length,
maxValidators: constants.maxValidators,
networkUtilization: ((validators.length / constants.maxValidators) * 100).toFixed(1) + '%',
stakeRatio: stakeRatio.toString() + '%',
avgStakePerValidator: web3.utils.fromWei(avgStakePerValidator.toString(), 'ether') + ' FEN'
};
}
Calculate Network Security
async function calculateNetworkSecurity() {
const totalStake = await contract.methods.totalNetworkStake().call();
const validators = await contract.methods.getActiveValidators().call();
// Get individual validator stakes
const validatorStakes = await Promise.all(
validators.map(async (vaAddr) => {
const info = await contract.methods.getValidatorInfo(vaAddr).call();
return BigInt(info.totalStake);
})
);
// Sort descending
validatorStakes.sort((a, b) => a > b ? -1 : 1);
// Calculate Nakamoto coefficient (how many validators needed for 33% attack)
let cumulativeStake = 0n;
let nakamotoCoefficient = 0;
const attackThreshold = BigInt(totalStake) * 33n / 100n;
for (const stake of validatorStakes) {
cumulativeStake += stake;
nakamotoCoefficient++;
if (cumulativeStake >= attackThreshold) break;
}
return {
totalStake: web3.utils.fromWei(totalStake, 'ether'),
validatorCount: validators.length,
nakamotoCoefficient,
securityLevel: nakamotoCoefficient >= 7 ? 'High' : nakamotoCoefficient >= 4 ? 'Medium' : 'Low',
largestValidatorPct: (Number(validatorStakes[0] * 100n / BigInt(totalStake))).toFixed(2) + '%'
};
}
Track Staking Growth
async function trackStakingGrowth() {
const currentStake = await contract.methods.totalNetworkStake().call();
// Store in database or localStorage
const timestamp = Date.now();
const stakeEntry = {
timestamp,
totalStake: currentStake,
feneAmount: parseFloat(web3.utils.fromWei(currentStake, 'ether'))
};
// Get historical data (from your storage)
const history = JSON.parse(localStorage.getItem('stakeHistory') || '[]');
history.push(stakeEntry);
// Keep last 30 days
const thirtyDaysAgo = timestamp - (30 * 24 * 60 * 60 * 1000);
const recentHistory = history.filter(entry => entry.timestamp > thirtyDaysAgo);
localStorage.setItem('stakeHistory', JSON.stringify(recentHistory));
// Calculate growth
if (recentHistory.length > 1) {
const oldestStake = recentHistory[0].feneAmount;
const growth = ((stakeEntry.feneAmount - oldestStake) / oldestStake) * 100;
console.log(`30-day growth: ${growth.toFixed(2)}%`);
}
return recentHistory;
}
Calculate Staking Rewards Pool
async function estimateRewardsPool() {
const totalStake = await contract.methods.totalNetworkStake().call();
// Assuming 5% annual inflation distributed to stakers
const annualInflationRate = 0.05;
const totalSupply = web3.utils.toWei('1000000000', 'ether'); // 1B
const annualRewards = BigInt(totalSupply) * BigInt(Math.floor(annualInflationRate * 100)) / 100n;
const dailyRewards = annualRewards / 365n;
const epochRewards = dailyRewards / 144n; // ~144 epochs per day at 200 blocks
return {
totalStaked: web3.utils.fromWei(totalStake, 'ether'),
annualRewards: web3.utils.fromWei(annualRewards.toString(), 'ether'),
dailyRewards: web3.utils.fromWei(dailyRewards.toString(), 'ether'),
perEpochRewards: web3.utils.fromWei(epochRewards.toString(), 'ether'),
estimatedAPY: (annualInflationRate * 100).toFixed(2) + '%'
};
}
async function getComprehensiveNetworkStats() {
// Get all data in parallel
const [totalStake, validators, currentBlock, constants] = await Promise.all([
contract.methods.totalNetworkStake().call(),
contract.methods.getActiveValidators().call(),
web3.eth.getBlockNumber(),
web3.getContractConstants()
]);
// Calculate epoch info
const currentEpoch = Math.floor(currentBlock / constants.blockEpoch);
const blocksUntilNextEpoch = constants.blockEpoch - (currentBlock % constants.blockEpoch);
// Get validator details
const validatorDetails = await Promise.all(
validators.map(va => contract.methods.getValidatorInfo(va).call())
);
const totalDelegators = validatorDetails.reduce(
(sum, info) => sum + parseInt(info.stakerCount), 0
);
return {
network: {
totalStake: web3.utils.fromWei(totalStake, 'ether') + ' FEN',
activeValidators: validators.length,
maxValidators: constants.maxValidators,
totalDelegators
},
epoch: {
current: currentEpoch,
blocksUntilNext: blocksUntilNextEpoch,
estimatedTimeUntilNext: (blocksUntilNextEpoch * 3 / 60).toFixed(1) + ' minutes'
},
staking: {
minValidatorStake: web3.utils.fromWei(constants.minValidatorStake, 'ether') + ' FEN',
minDelegatorStake: web3.utils.fromWei(constants.minDelegatorStake, 'ether') + ' FEN',
avgStakePerValidator: web3.utils.fromWei(
(BigInt(totalStake) / BigInt(validators.length)).toString(),
'ether'
) + ' FEN'
}
};
}