totalNetworkStake
curl --request POST \
--url https://api.example.com/eth_callimport requests
url = "https://api.example.com/eth_call"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/eth_call', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/eth_call",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/eth_call"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/eth_call")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/eth_call")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"result": {}
}eth_* Methods
totalNetworkStake
Get total amount of FEN staked across all validators
POST
eth_call
totalNetworkStake
curl --request POST \
--url https://api.example.com/eth_callimport requests
url = "https://api.example.com/eth_call"
response = requests.post(url)
print(response.text)const options = {method: 'POST'};
fetch('https://api.example.com/eth_call', options)
.then(res => res.json())
.then(res => console.log(res))
.catch(err => console.error(err));<?php
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_URL => "https://api.example.com/eth_call",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "POST",
]);
$response = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
if ($err) {
echo "cURL Error #:" . $err;
} else {
echo $response;
}package main
import (
"fmt"
"net/http"
"io"
)
func main() {
url := "https://api.example.com/eth_call"
req, _ := http.NewRequest("POST", url, nil)
res, _ := http.DefaultClient.Do(req)
defer res.Body.Close()
body, _ := io.ReadAll(res.Body)
fmt.Println(string(body))
}HttpResponse<String> response = Unirest.post("https://api.example.com/eth_call")
.asString();require 'uri'
require 'net/http'
url = URI("https://api.example.com/eth_call")
http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
request = Net::HTTP::Post.new(url)
response = http.request(request)
puts response.read_body{
"result": {}
}Overview
Queries the FenineSystem contract to get the total amount of FEN staked across all validators in the network. This includes both validator self-stakes and delegator stakes.Contract Call Details
address
required
0x0000000000000000000000000000000000001000 (FenineSystem)bytes
required
Function selector:
0x635c8637 (no parameters)Response
uint256
Total staked amount in wei
Examples
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
}'
const Web3 = require('web3');
const web3 = new Web3('https://rpc.fene.app');
// Method 1: Direct call
const result = await web3.eth.call({
to: '0x0000000000000000000000000000000000001000',
data: '0x635c8637'
}, 'latest');
const totalStake = web3.eth.abi.decodeParameter('uint256', result);
console.log('Total network stake:', web3.utils.fromWei(totalStake, 'ether'), 'FEN');
// Method 2: Using contract (recommended)
const abi = JSON.parse(await web3.getSystemContractABI());
const contract = new web3.eth.Contract(
abi,
'0x0000000000000000000000000000000000001000'
);
const totalStake = await contract.methods.totalNetworkStake().call();
console.log('Total network stake:', web3.utils.fromWei(totalStake, 'ether'), 'FEN');
const { ethers } = require('ethers');
const provider = new ethers.JsonRpcProvider('https://rpc.fene.app');
const abiJson = await provider.send('fenine_getSystemContractABI', []);
const abi = JSON.parse(abiJson);
const contract = new ethers.Contract(
'0x0000000000000000000000000000000000001000',
abi,
provider
);
const totalStake = await contract.totalNetworkStake();
console.log('Total network stake:', ethers.formatEther(totalStake), 'FEN');
from web3 import Web3
w3 = Web3(Web3.HTTPProvider('https://rpc.fene.app'))
# Direct call
result = w3.eth.call({
'to': '0x0000000000000000000000000000000000001000',
'data': '0x635c8637'
}, 'latest')
total_stake = w3.codec.decode(['uint256'], result)[0]
print(f'Total network stake: {Web3.from_wei(total_stake, "ether")} FEN')
Use Cases
Network Health Dashboard
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
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
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
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) + '%'
};
}
Network Statistics
Combine with other methods for comprehensive stats: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'
}
};
}
Related Methods
getActiveValidators
Get list of active validators
getCurrentEpoch
Get current epoch number
getContractConstants
Get network parameters
⌘I