Tracking crypto staking rewards can be difficult. With assets spread across different wallets, chains, and exchanges, manually consolidating data is a messy, time-consuming process. This makes it tedious and hard to accurately track performance or make informed decisions.
This free Crypto Staking Rewards Calculator Google Sheets Template is designed to solve this problem. It automatically calculates your true effective APY from various advertised rates, projects future earnings, and analyzes your performance in real-time using live crypto market data powered by the CoinGecko API. Whether you’re staking major assets like Solana and Ethereum or long-tail on-chain tokens, this template gives you a clean, visual way to calculate your staking rewards, track its performance, and make smarter compounding decisions..webp)
What Are Crypto Staking Rewards and Why Should You Track Them?
Crypto staking rewards are the earnings you receive for participating in a blockchain’s security and operations. In networks that use a Proof of Stake (PoS) consensus mechanism, you lock up your cryptocurrency, a process called staking, to help validate transactions and secure the network. In return for this service, the network compensates you with rewards, similar to earning interest in a traditional savings account.
Tracking these rewards is crucial for several reasons:
-
Performance Monitoring: Tracking allows you to calculate the actual Annual Percentage Yield (APY) on your staked assets. For example, if you’re staking Solana (SOL), your rewards are paid in SOL. The value of those rewards fluctuates with the market, and only by tracking both the quantity of SOL received and its price over time can you understand your true return on investment.
-
Compounding Strategy: Visualizing your earnings helps you make informed decisions about compounding. By seeing how re-staking your rewards impacts your total holdings, you can build a more effective strategy for exponential growth.
Prerequisites
Before you start, ensure the following requirements are met to use the template effectively:
-
CoinGecko API key: A CoinGecko API key is required to fetch live crypto prices. The free Demo API key is sufficient to get started, while a Pro plan offers higher rate limits for more frequent data refreshes. You can follow our guide to get your free Demo API key.
-
Google Account: You’ll need a Google account to open, copy, and use the template in Google Sheets. This allows you to save your own version and enable Apps Script for live data connections.
How to Use the Free Staking Rewards Tracker Google Sheets Template
This section provides a step-by-step guide on how to set up the template. Follow these instructions to add your CoinGecko API key, customize your coin list, set up automatic data refreshes, and log your first staking position.
Setting up the CoinGecko API Key in Google Sheets
First, connect the template to your CoinGecko API key. To do this, navigate to the “Read Me” sheet, this is your configuration page for API settings.
-
Open the “Read Me” sheet.
-
In cell A20, specify your subscription level as Demo or Pro.
-
In cell B20, paste your CoinGecko API key.
Once entered, the key is automatically recognized by all live queries across your workbook. You don’t need to modify any formulas manually.
Setting up Automatic Data Refreshes
Now that the API credentials are added to the spreadsheet, you can configure it to refresh the data automatically. Go to Extensions > Apps Script, then click the Triggers icon (shaped like a clock) on the left sidebar.
Clicking “+ Add Trigger” will open up a modal for you to configure the following settings:
-
Choose which function to run: triggerAutoRefresh
-
Choose which deployment should run: Head
-
Select event source: Time-driven
-
Select type of time based trigger: Minutes timer
-
Select minute interval: Every 5 or 10 minutes (note: anything less than this may not be useful, as results are cached)
Depending on your preferred frequency, you may also toggle between Hour timer, Day timer, or Week timer.
After saving, the script will run automatically at your specified interval, keeping your crypto data up-to-date. Keep in mind that more frequent refreshes will consume your API call credits faster. If you run into rate limits, consider upgrading to a paid API plan for higher call credits and rate limits.
Adding Coins to the Template
The template tracks the top 250 coins by default. To track other assets, such as specific on-chain tokens, you must add them manually in the Add Coins sheet. The information required depends on whether the asset is listed on CoinGecko or is an on-chain token tracked on GeckoTerminal.
For Coins found on CoinGecko, set the Source to CoinGecko and enter its API ID. You can find the API ID on any individual coin page on the CoinGecko website.
For Onchain Tokens, set the Source to GeckoTerminal, select the Network ID (for example, bsc for BNB Chain), and enter the Token Contract Address. To find the Network ID and Token Contract Address, head to the individual token page on GeckoTerminal:
-
The Network ID is found in the URL path (e.g., bsc in https://www.geckoterminal.com/bsc/pools/0xaead6bd31dd66eb3a6216aaf271d0e661585b0b1)
-
Token Contract Address for the base token is listed in the pool details.
After adding assets, the template automatically runs the data fetch using your configured API key.
You can manually refresh the data by reloading the sheet or pressing Ctrl + R to trigger a new API call through ImportJSON.
Your newly added assets will appear in the “Available Coins” sheet, starting from row 252, directly below the default Top 250 list. Once added, you only need to register a coin once for it to remain available for logging in your Staking Log. If a coin doesn’t appear, verify Source, CoinGecko ID, Network ID, and Token Contract Address, then refresh.
Logging Your Staking Positions
Once the template is set up, you can start recording your positions in the Staking Log sheet. This is where you will log every new staking action’s lifecycle to accurately monitor your portfolio’s performance and value over time.
When starting a new position, fill in the initial staking details like the Stake Date, Staked Qty, and the platform’s advertised Staking Rate. The Stake Status will automatically show as active. When you are ready to close the position, return to that same row to enter the Unstake Date and the Unstaked Price (the asset’s price on the day you unstaked). The sheet will then automatically calculate your realized profit for that position.
Analyzing the Staking Rewards Dashboard
Once your positions are logged, head to the Staking Rewards Dashboard Sheet to review your performance. All charts and summary tables automatically update whenever a new position is added or when live market data refreshes. The dashboard will automatically recalculate and display your most recent realized and unrealized profit or loss, portfolio analytics, and future growth projections.
The sheet provides a comprehensive overview of your staking portfolio and is split into two main sections:
-
Staking Rewards Dashboard: This provides a snapshot of your overall staking health. It separates your active and historical performance to show how your earnings change over time and which assets have been most profitable.
-
Balance Overview: A performance chart that visualizes your cumulative profit over time. It starts at zero and grows as you close positions and record realized gains, with a final point showing your total unrealized profit to date.
-
Holding’s Distribution: A pie chart that visually breaks down your total active staking portfolio. It shows the percentage allocation of each cryptocurrency you are staking based on their current dollar value.
-
Staking Coins Analytics: A summary table of all your closed positions. It details the final Position Value, net profit/loss and total holding duration, providing a clear history of your performance.
-
-
Staking Rewards Calculator: This is an interactive projection tool for strategic planning on a single asset. To generate a projection, navigate to Row 5 (from Column “N” onwards) and input the required parameters. You will need to select an active coin, the staking platform, and the hold duration (e.g., Year, Month). The dashboard will then calculate the projected results.
-
Final Projected Quantity: Based on the specified duration of hold and the effective APY rate for the specific staking platform, the scorecard will display the final projected quantity for the respective asset at the end of the projected date.
-
Projected Value in USD (Based on current price): The dashboard then provides the valuation of the projected quantity based on the current price of the asset as well as the net profit.
-
Automated Projection Table: The dashboard instantly generates a week-by-week forecast for the selected coin or token with an Active position. It shows the projected growth in your total coin quantity and its potential future dollar value. This forecast is based on the average Effective APY for the specified coin and staking platform. This helps you visualize future earnings and make informed decisions about your staking strategy.
-
Creating a Crypto Staking Rewards Calculator in Google Sheets
Creating a crypto staking rewards calculator in Google Sheets involves three main components: a live data source for fetching crypto prices, a structured log for recording all staking positions, and an automated dashboard for calculating performance.
To build one, you would need to integrate these components:
-
Live Crypto Market Data: Live prices are essential for real-time valuations. This can be achieved by using Google Apps Script to pull data from the CoinGecko API. This method allows you to retrieve data for a vast range of crypto assets directly into your sheet and set up automatic data refreshes using time-based triggers.
-
Structured Staking Log: You need a dedicated sheet to record every staking position. This log should include clear fields for the stake date, coin, quantity, staking rate (APR or APY), and compounding frequency. This structured data forms the foundation for all automated calculations.
-
Dynamic Analysis Dashboard: Create a dashboard that automatically aggregates and visualizes your log data. This typically involves using pivot tables and charts to create summary tables for active and closed positions, track cumulative profits, and project future earnings from active stakes.
How to Pull Real-Time Crypto Market Data into Google Sheets?
You can get or pull real-time crypto data in Google Sheets by creating custom functions with Google Apps Script that fetches data directly from CoinGecko API.
Step 1: Create an ImportJSON Script
First, create the main function that will fetch and parse the data.
Open your Google Sheet and navigate to ‘Extensions’ and select ‘Apps Script’ – a new tab will appear.
On the left panel, select ‘< > Editor’ and add a new script using the ‘+’ button. Copy and paste the following importJSON script, and save the script as ‘ImportJSON’. This importJSON script is a versatile one that will allow you to import data in many different ways.
/**
* Imports a JSON feed and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create
* a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in
* the JSON feed. The remaining rows contain the data.
* * By default, data gets transformed so it looks more like a normal data import. Specifically:
*
* – Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values
* of the rows representing their parent elements.
* – Values longer than 256 characters get truncated.
* – Headers have slashes converted to spaces, common prefixes removed and the resulting text converted to title case.
*
* To change this behavior, pass in one of these values in the options parameter:
*
* noInherit: Don’t inherit values from parent elements
* noTruncate: Don’t truncate values
* rawHeaders: Don’t prettify headers
* noHeaders: Don’t include headers, only the data
* allHeaders: Include all headers from the query parameter in the order they are listed
* debugLocation: Prepend each value with the row & column it belongs in
*
* For example:
*
* =ImportJSON(“http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json”, “/feed/entry/title,/feed/entry/content”,
* “noInherit,noTruncate,rawHeaders”)
* * @param {url} the URL to a public JSON feed
* @param {query} a comma-separated list of paths to import. Any path starting with one of these paths gets imported.
* @param {parseOptions} a comma-separated list of options that alter processing of the data
* @customfunction
*
* @return a two-dimensional array containing the data, with the first row containing headers
**/
function ImportJSON(url, query, parseOptions) {
return ImportJSONAdvanced(url, null, query, parseOptions, includeXPath_, defaultTransform_);
}
/**
* Imports a JSON feed via a POST request and returns the results to be inserted into a Google Spreadsheet. The JSON feed is
* flattened to create a two-dimensional array. The first row contains the headers, with each column header indicating the path to
* that data in the JSON feed. The remaining rows contain the data.
*
* To retrieve the JSON, a POST request is sent to the URL and the payload is passed as the content of the request using the content
* type “application/x-www-form-urlencoded”. If the fetchOptions define a value for “method”, “payload” or “contentType”, these
* values will take precedent. For example, advanced users can use this to make this function pass XML as the payload using a GET
* request and a content type of “application/xml; charset=utf-8”. For more information on the available fetch options, see
* https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app . At this time the “headers” option is not supported.
* * By default, the returned data gets transformed so it looks more like a normal data import. Specifically:
*
* – Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values
* of the rows representing their parent elements.
* – Values longer than 256 characters get truncated.
* – Headers have slashes converted to spaces, common prefixes removed and the resulting text converted to title case.
*
* To change this behavior, pass in one of these values in the options parameter:
*
* noInherit: Don’t inherit values from parent elements
* noTruncate: Don’t truncate values
* rawHeaders: Don’t prettify headers
* noHeaders: Don’t include headers, only the data
* allHeaders: Include all headers from the query parameter in the order they are listed
* debugLocation: Prepend each value with the row & column it belongs in
*
* For example:
*
* =ImportJSON(“http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json”, “user=bob&apikey=xxxx”,
* “validateHttpsCertificates=false”, “/feed/entry/title,/feed/entry/content”, “noInherit,noTruncate,rawHeaders”)
* * @param {url} the URL to a public JSON feed
* @param {payload} the content to pass with the POST request; usually a URL encoded list of parameters separated by ampersands
* @param {fetchOptions} a comma-separated list of options used to retrieve the JSON feed from the URL
* @param {query} a comma-separated list of paths to import. Any path starting with one of these paths gets imported.
* @param {parseOptions} a comma-separated list of options that alter processing of the data
* @customfunction
*
* @return a two-dimensional array containing the data, with the first row containing headers
**/
function ImportJSONViaPost(url, payload, fetchOptions, query, parseOptions) {
var postOptions = parseToObject_(fetchOptions);
if (postOptions[“method”] == null) {
postOptions[“method”] = “POST”;
}
if (postOptions[“payload”] == null) {
postOptions[“payload”] = payload;
}
if (postOptions[“contentType”] == null) {
postOptions[“contentType”] = “application/x-www-form-urlencoded”;
}
convertToBool_(postOptions, “validateHttpsCertificates”);
convertToBool_(postOptions, “useIntranet”);
convertToBool_(postOptions, “followRedirects”);
convertToBool_(postOptions, “muteHttpExceptions”);
return ImportJSONAdvanced(url, postOptions, query, parseOptions, includeXPath_, defaultTransform_);
}
/**
* Imports a JSON text from a named Sheet and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create
* a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in
* the JSON feed. The remaining rows contain the data.
* * By default, data gets transformed so it looks more like a normal data import. Specifically:
*
* – Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values
* of the rows representing their parent elements.
* – Values longer than 256 characters get truncated.
* – Headers have slashes converted to spaces, common prefixes removed and the resulting text converted to title case.
*
* To change this behavior, pass in one of these values in the options parameter:
*
* noInherit: Don’t inherit values from parent elements
* noTruncate: Don’t truncate values
* rawHeaders: Don’t prettify headers
* noHeaders: Don’t include headers, only the data
* allHeaders: Include all headers from the query parameter in the order they are listed
* debugLocation: Prepend each value with the row & column it belongs in
*
* For example:
*
* =ImportJSONFromSheet(“Source”, “/feed/entry/title,/feed/entry/content”,
* “noInherit,noTruncate,rawHeaders”)
* * @param {sheetName} the name of the sheet containg the text for the JSON
* @param {query} a comma-separated lists of paths to import. Any path starting with one of these paths gets imported.
* @param {options} a comma-separated list of options that alter processing of the data
*
* @return a two-dimensional array containing the data, with the first row containing headers
* @customfunction
**/
function ImportJSONFromSheet(sheetName, query, options) {
var object = getDataFromNamedSheet_(sheetName);
return parseJSONObject_(object, query, options, includeXPath_, defaultTransform_);
}
/**
* An advanced version of ImportJSON designed to be easily extended by a script. This version cannot be called from within a
* spreadsheet.
* * Imports a JSON feed and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create
* a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in
* the JSON feed. The remaining rows contain the data.
*
* The fetchOptions can be used to change how the JSON feed is retrieved. For instance, the “method” and “payload” options can be
* set to pass a POST request with post parameters. For more information on the available parameters, see
* https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app .
*
* Use the include and transformation functions to determine what to include in the import and how to transform the data after it is
* imported.
*
* For example:
*
* ImportJSON(“http://gdata.youtube.com/feeds/api/standardfeeds/most_popular?v=2&alt=json”,
* new Object() { “method” : “post”, “payload” : “user=bob&apikey=xxxx” },
* “/feed/entry”,
* “”,
* function (query, path) { return path.indexOf(query) == 0; },
* function (data, row, column) { data[row][column] = data[row][column].toString().substr(0, 100); } )
*
* In this example, the import function checks to see if the path to the data being imported starts with the query. The transform
* function takes the data and truncates it. For more robust versions of these functions, see the internal code of this library.
*
* @param {url} the URL to a public JSON feed
* @param {fetchOptions} an object whose properties are options used to retrieve the JSON feed from the URL
* @param {query} the query passed to the include function
* @param {parseOptions} a comma-separated list of options that may alter processing of the data
* @param {includeFunc} a function with the signature func(query, path, options) that returns true if the data element at the given path
* should be included or false otherwise.
* @param {transformFunc} a function with the signature func(data, row, column, options) where data is a 2-dimensional array of the data
* and row & column are the current row and column being processed. Any return value is ignored. Note that row 0
* contains the headers for the data, so test for row==0 to process headers only.
*
* @return a two-dimensional array containing the data, with the first row containing headers
* @customfunction
**/
function ImportJSONAdvanced(url, fetchOptions, query, parseOptions, includeFunc, transformFunc) {
var jsondata = UrlFetchApp.fetch(url, fetchOptions);
var object = JSON.parse(jsondata.getContentText());
return parseJSONObject_(object, query, parseOptions, includeFunc, transformFunc);
}
/**
* Helper function to authenticate with basic auth informations using ImportJSONAdvanced
*
* Imports a JSON feed and returns the results to be inserted into a Google Spreadsheet. The JSON feed is flattened to create
* a two-dimensional array. The first row contains the headers, with each column header indicating the path to that data in
* the JSON feed. The remaining rows contain the data.
*
* The fetchOptions can be used to change how the JSON feed is retrieved. For instance, the “method” and “payload” options can be
* set to pass a POST request with post parameters. For more information on the available parameters, see
* https://developers.google.com/apps-script/reference/url-fetch/url-fetch-app .
*
* Use the include and transformation functions to determine what to include in the import and how to transform the data after it is
* imported.
*
* @param {url} the URL to a http basic auth protected JSON feed
* @param {username} the Username for authentication
* @param {password} the Password for authentication
* @param {query} the query passed to the include function (optional)
* @param {parseOptions} a comma-separated list of options that may alter processing of the data (optional)
*
* @return a two-dimensional array containing the data, with the first row containing headers
* @customfunction
**/
function ImportJSONBasicAuth(url, username, password, query, parseOptions) {
var encodedAuthInformation = Utilities.base64Encode(username + “:” + password);
var header = {headers: {Authorization: “Basic ” + encodedAuthInformation}};
return ImportJSONAdvanced(url, header, query, parseOptions, includeXPath_, defaultTransform_);
}
/** * Encodes the given value to use within a URL.
*
* @param {value} the value to be encoded
* * @return the value encoded using URL percent-encoding
*/
function URLEncode(value) {
return encodeURIComponent(value.toString());
}
/**
* Adds an oAuth service using the given name and the list of properties.
*
* @note This method is an experiment in trying to figure out how to add an oAuth service without having to specify it on each
* ImportJSON call. The idea was to call this method in the first cell of a spreadsheet, and then use ImportJSON in other
* cells. This didn’t work, but leaving this in here for further experimentation later.
*
* The test I did was to add the following into the A1:
* * =AddOAuthService(“twitter”, “https://api.twitter.com/oauth/access_token”,
* “https://api.twitter.com/oauth/request_token”, “https://api.twitter.com/oauth/authorize”,
* “<my consumer key>”, “<my consumer secret>”, “”, “”)
*
* Information on obtaining a consumer key & secret for Twitter can be found at https://dev.twitter.com/docs/auth/using-oauth
*
* Then I added the following into A2:
*
* =ImportJSONViaPost(“https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=fastfedora&count=2”, “”,
* “oAuthServiceName=twitter,oAuthUseToken=always”, “/”, “”)
*
* I received an error that the “oAuthServiceName” was not a valid value. [twl 18.Apr.13]
*/
function AddOAuthService__(name, accessTokenUrl, requestTokenUrl, authorizationUrl, consumerKey, consumerSecret, method, paramLocation) {
var oAuthConfig = UrlFetchApp.addOAuthService(name);
if (accessTokenUrl != null && accessTokenUrl.length > 0) {
oAuthConfig.setAccessTokenUrl(accessTokenUrl);
}
if (requestTokenUrl != null && requestTokenUrl.length > 0) {
oAuthConfig.setRequestTokenUrl(requestTokenUrl);
}
if (authorizationUrl != null && authorizationUrl.length > 0) {
oAuthConfig.setAuthorizationUrl(authorizationUrl);
}
if (consumerKey != null && consumerKey.length > 0) {
oAuthConfig.setConsumerKey(consumerKey);
}
if (consumerSecret != null && consumerSecret.length > 0) {
oAuthConfig.setConsumerSecret(consumerSecret);
}
if (method != null && method.length > 0) {
oAuthConfig.setMethod(method);
}
if (paramLocation != null && paramLocation.length > 0) {
oAuthConfig.setParamLocation(paramLocation);
}
}
/** * Parses a JSON object and returns a two-dimensional array containing the data of that object.
*/
function parseJSONObject_(object, query, options, includeFunc, transformFunc) {
var headers = new Array();
var data = new Array();
if (query && !Array.isArray(query) && query.toString().indexOf(“,”) != -1) {
query = query.toString().split(“,”);
}
// Prepopulate the headers to lock in their order
if (hasOption_(options, “allHeaders”) && Array.isArray(query))
{
for (var i = 0; i < query.length; i++)
{
headers[query[i]] = Object.keys(headers).length;
}
}
if (options) {
options = options.toString().split(“,”);
}
parseData_(headers, data, “”, {rowIndex: 1}, object, query, options, includeFunc);
parseHeaders_(headers, data);
transformData_(data, options, transformFunc);
return hasOption_(options, “noHeaders”) ? (data.length > 1 ? data.slice(1) : new Array()) : data;
}
/** * Parses the data contained within the given value and inserts it into the data two-dimensional array starting at the rowIndex.
* If the data is to be inserted into a new column, a new header is added to the headers array. The value can be an object,
* array or scalar value.
*
* If the value is an object, it’s properties are iterated through and passed back into this function with the name of each
* property extending the path. For instance, if the object contains the property “entry” and the path passed in was “/feed”,
* this function is called with the value of the entry property and the path “/feed/entry”.
*
* If the value is an array containing other arrays or objects, each element in the array is passed into this function with
* the rowIndex incremeneted for each element.
*
* If the value is an array containing only scalar values, those values are joined together and inserted into the data array as
* a single value.
*
* If the value is a scalar, the value is inserted directly into the data array.
*/
function parseData_(headers, data, path, state, value, query, options, includeFunc) {
var dataInserted = false;
if (Array.isArray(value) && isObjectArray_(value)) {
for (var i = 0; i < value.length; i++) {
if (parseData_(headers, data, path, state, value[i], query, options, includeFunc)) {
dataInserted = true;
if (data[state.rowIndex]) {
state.rowIndex++;
}
}
}
} else if (isObject_(value)) {
for (key in value) {
if (parseData_(headers, data, path + “/” + key, state, value[key], query, options, includeFunc)) {
dataInserted = true;
}
}
} else if (!includeFunc || includeFunc(query, path, options)) {
// Handle arrays containing only scalar values
if (Array.isArray(value)) {
value = value.join();
}
// Insert new row if one doesn’t already exist
if (!data[state.rowIndex]) {
data[state.rowIndex] = new Array();
}
// Add a new header if one doesn’t exist
if (!headers[path] && headers[path] != 0) {
headers[path] = Object.keys(headers).length;
}
// Insert the data
data[state.rowIndex][headers[path]] = value;
dataInserted = true;
}
return dataInserted;
}
/** * Parses the headers array and inserts it into the first row of the data array.
*/
function parseHeaders_(headers, data) {
data[0] = new Array();
for (key in headers) {
data[0][headers[key]] = key;
}
}
/** * Applies the transform function for each element in the data array, going through each column of each row.
*/
function transformData_(data, options, transformFunc) {
for (var i = 0; i < data.length; i++) {
for (var j = 0; j < data[0].length; j++) {
transformFunc(data, i, j, options);
}
}
}
/** * Returns true if the given test value is an object; false otherwise.
*/
function isObject_(test) {
return Object.prototype.toString.call(test) === ‘[object Object]’;
}
/** * Returns true if the given test value is an array containing at least one object; false otherwise.
*/
function isObjectArray_(test) {
for (var i = 0; i < test.length; i++) {
if (isObject_(test[i])) {
return true;
}
}
return false;
}
/** * Returns true if the given query applies to the given path.
*/
function includeXPath_(query, path, options) {
if (!query) {
return true;
} else if (Array.isArray(query)) {
for (var i = 0; i < query.length; i++) {
if (applyXPathRule_(query[i], path, options)) {
return true;
}
}
} else {
return applyXPathRule_(query, path, options);
}
return false;
};
/** * Returns true if the rule applies to the given path.
*/
function applyXPathRule_(rule, path, options) {
return path.indexOf(rule) == 0;
}
/** * By default, this function transforms the value at the given row & column so it looks more like a normal data import. Specifically:
*
* – Data from parent JSON elements gets inherited to their child elements, so rows representing child elements contain the values
* of the rows representing their parent elements.
* – Values longer than 256 characters get truncated.
* – Values in row 0 (headers) have slashes converted to spaces, common prefixes removed and the resulting text converted to title
* case.
*
* To change this behavior, pass in one of these values in the options parameter:
*
* noInherit: Don’t inherit values from parent elements
* noTruncate: Don’t truncate values
* rawHeaders: Don’t prettify headers
* debugLocation: Prepend each value with the row & column it belongs in
*/
function defaultTransform_(data, row, column, options) {
if (data[row][column] == null) {
if (row < 2 || hasOption_(options, “noInherit”)) {
data[row][column] = “”;
} else {
data[row][column] = data[row-1][column];
}
}
if (!hasOption_(options, “rawHeaders”) && row == 0) {
if (column == 0 && data[row].length > 1) {
removeCommonPrefixes_(data, row);
}
data[row][column] = toTitleCase_(data[row][column].toString().replace(/[/_]/g, ” “));
}
if (!hasOption_(options, “noTruncate”) && data[row][column]) {
data[row][column] = data[row][column].toString().substr(0, 256);
}
if (hasOption_(options, “debugLocation”)) {
data[row][column] = “[” + row + “,” + column + “]” + data[row][column];
}
}
/** * If all the values in the given row share the same prefix, remove that prefix.
*/
function removeCommonPrefixes_(data, row) {
var matchIndex = data[row][0].length;
for (var i = 1; i < data[row].length; i++) {
matchIndex = findEqualityEndpoint_(data[row][i-1], data[row][i], matchIndex);
if (matchIndex == 0) {
return;
}
}
for (var i = 0; i < data[row].length; i++) {
data[row][i] = data[row][i].substring(matchIndex, data[row][i].length);
}
}
/** * Locates the index where the two strings values stop being equal, stopping automatically at the stopAt index.
*/
function findEqualityEndpoint_(string1, string2, stopAt) {
if (!string1 || !string2) {
return -1;
}
var maxEndpoint = Math.min(stopAt, string1.length, string2.length);
for (var i = 0; i < maxEndpoint; i++) {
if (string1.charAt(i) != string2.charAt(i)) {
return i;
}
}
return maxEndpoint;
}
/** * Converts the text to title case.
*/
function toTitleCase_(text) {
if (text == null) {
return null;
}
return text.replace(/wS*/g, function(word) { return word.charAt(0).toUpperCase() + word.substr(1).toLowerCase(); });
}
/** * Returns true if the given set of options contains the given option.
*/
function hasOption_(options, option) {
return options && options.indexOf(option) >= 0;
}
/** * Parses the given string into an object, trimming any leading or trailing spaces from the keys.
*/
function parseToObject_(text) {
var map = new Object();
var entries = (text != null && text.trim().length > 0) ? text.toString().split(“,”) : new Array();
for (var i = 0; i < entries.length; i++) {
addToMap_(map, entries[i]);
}
return map;
}
/** * Parses the given entry and adds it to the given map, trimming any leading or trailing spaces from the key.
*/
function addToMap_(map, entry) {
var equalsIndex = entry.indexOf(“=”);
var key = (equalsIndex != -1) ? entry.substring(0, equalsIndex) : entry;
var value = (key.length + 1 < entry.length) ? entry.substring(key.length + 1) : “”;
map[key.trim()] = value;
}
/** * Returns the given value as a boolean.
*/
function toBool_(value) {
return value == null ? false : (value.toString().toLowerCase() == “true” ? true : false);
}
/**
* Converts the value for the given key in the given map to a bool.
*/
function convertToBool_(map, key) {
if (map[key] != null) {
map[key] = toBool_(map[key]);
}
}
function getDataFromNamedSheet_(sheetName) {
var ss = SpreadsheetApp.getActiveSpreadsheet();
var source = ss.getSheetByName(sheetName);
var jsonRange = source.getRange(1,1,source.getLastRow());
var jsonValues = jsonRange.getValues();
var jsonText = “”;
for (var row in jsonValues) {
for (var col in jsonValues[row]) {
jsonText +=jsonValues[row][col];
}
}
Logger.log(jsonText);
return JSON.parse(jsonText);
}
Step 2: Create the autoRefresh Script
Next, create a helper script that will allow the data to refresh automatically.
Create a second Apps Script by clicking on the ‘+’ button. Copy the code below and paste it into the script editor, saving it as ‘autoRefresh’ – this will allow your sheet to automatically refresh at fixed intervals.
function getRandomInt(min, max) {
min = Math.ceil(min);
max = Math.floor(max);
return Math.floor(Math.random() * (max – min + 1)) + min;
}
Step 3: Call the Function in Your Sheet
With the scripts saved, you can now use the =IMPORTJSON() function in any cell.
-
Construct your CoinGecko API request URL.
-
Enter the formula into your desired cell, replacing the placeholder URL with your own.
For example, to get market data for the top 100 coins, your formula would look like this:
=ImportJSON("https://api.coingecko.com/api/v3/coins/marketsvs_currency=usd&order=market_cap_desc&per_page=250&page=1&sparkline=false&price_change_percentage=24h&x_cg_demo_api_key=YOUR_API_KEY_HERE","/id,/name,/current_price,/market_cap,/market_cap_rank,/price_change_percentage_24h,/market_cap_change_24h,/market_cap_change_percentage_24h,/price_change_percentage_24h_in_currency","noTruncate")Creating a Crypto Staking Log Sheet in Google Sheets
To calculate your staking performance, you need a complete record of every position. A ‘Staking Log’ sheet is crucial for recording all your staking activities in one place, serving as the database that powers all automated calculations like effective APY, total rewards, and projected earnings.
For your log to work, each entry must include:
-
Stake Date
-
Coin
-
Staked Qty
-
Average entry price (USD)
-
Rate Type (APY or APR)
-
Staking Rate
-
Compounding Frequency
-
Staking Platform
-
Unstaked Date
-
Unstaked Price
Creating a Crypto Staking Reward Analysis Dashboard in Google Sheets
After logging your positions, create a dashboard to analyze your performance. This dashboard will use formulas to calculate key metrics and charts to visualize your staking rewards and portfolio growth.
To build an effective analysis dashboard, you will need to implement several core Google Sheets functions and calculation formulas:
Essential Google Sheets Functions
-
SUMIFS: Calculates totals based on specific conditions, such as the total rewards earned from a specific coin or the total value staked on a specific platform.
-
AVERAGE: Finds the average staking duration or the average effective APY across all your positions.
-
COUNTIFS: Counts the number of positions that meet given criteria. This is essential for tracking your total number of active vs. closed stakes.
-
INDEX + MATCH: Used to dynamically reference live market data. This combination looks up the current price of each coin from your ‘Available Coins’ sheet and links it to your staking log for real-time valuations.
-
FILTER / QUERY: These functions are used to create separate summary tables (e.g., ‘Active’ and ‘Closed’) by dynamically pulling data from a main log based on a position’s status.
Calculation Logic
With the functions above, you can compute the primary metrics needed to assess your performance:
-
Effective APY: Build logic to convert an advertised APR into a standardized APY by factoring in the ‘Compounding Frequency’ (e.g., daily, weekly, monthly).
-
Projected Rewards (Active): Estimate the total future quantity of a coin by applying the calculated ‘Effective APY’ to the ‘Staked Qty’ over the ‘Hold Duration’.
-
Unrealized Profit: Calculate the current dollar value of active positions by multiplying the current quantity (staked + projected rewards) by the live market price.
-
Realized Profit: Calculate the final profit or loss in dollar terms by taking the total value at unstaking (Unstaked Qty * Unstaked Price) and subtracting the initial stake’s value.
-
Balance Overview: Use a running total of all ‘Realized Profit’ from your closed positions to track historical performance.
These metrics can then be used to power your dashboard’s charts and summary tables, giving you an immediate visual summary of your staking performance and future projections.
Common Issues & Fixes
If you encounter errors or missing data while using the crypto staking rewards calculator, here are a few common issues and how to resolve them quickly.
-
API Rate Limit (Error 429) This happens when the free CoinGecko Demo API hits its request limit. Wait a few minutes before refreshing again, or switch to a Pro API key for uninterrupted updates. If you receive other error codes, refer to the full list of CoinGecko API status codes to troubleshoot them.
-
Missing or Incorrect Coin Data If a coin’s data doesn’t appear after refreshing:
-
Check that the Coin ID or Contract Address in the AddCoins sheet is correct.
-
Make sure the Source and Network ID fields are filled in properly.
-
Refresh again after fixing the entry.
-
-
API Key or Endpoint Issues If your API key isn’t connecting or you’re seeing Error 401 or Error 403:
-
Confirm your API key and subscription level (demo or pro) are entered correctly in the Read Me sheet.
-
Ensure there are no extra spaces or formatting errors in the key.
-
-
Script Refresh Delays If the data doesn’t refresh automatically, make sure your Apps Script trigger is active:
-
Go to “Extensions” > “Apps Script” > “Triggers.gs”.
-
Confirm that the “triggerAutoRefresh” function is scheduled to run every hour (or your preferred interval).
-
You can also manually click on “Run”, to force an immediate data refresh.
-
Further Enhancements
You can further enhance this crypto staking rewards calculator template to better suit your analysis style. Here are a few ideas that leverage other CoinGecko API endpoints:
-
Fetch Historical Price Data
Pull Historical Prices for specific coins for more in-depth performance analysis. You can follow our guide on how to pull crypto historical data in Google Sheets and visualize long-term trends. -
Add OHLC (Open, High, Low, Close) Data
If you want more granular price insights, consider fetching OHLC data for each coin. Check out our step-by-step guide on how to pull crypto OHLC data into Google Sheets. -
Add a Crypto Portfolio Tracker
This staking rewards tracker shares many core components with a full crypto portfolio tracker. You can expand its functionality to monitor all your holdings, both staked and liquid assets held across multiple wallets and exchanges, by following our guide on how to create a crypto portfolio tracker in Google Sheets. -
Create a Crypto Exit Strategy Planner
Just as this template helps you project future staking rewards, a crypto exit strategy planner can help you plan for future market movements. Consider building one to add profit-taking and stop-loss levels for your liquid assets. Check out our step-by-step guide on how to build a crypto exit strategy planner in Google Sheets. -
Build a Crypto Tax Calculator
Since staking rewards can be taxable events, keeping a clean record with this template is a great first step. You can also use the data from your staking log to calculate capital gains using a dedicated crypto tax calculator. For a complete guide, see our article on how to create a crypto tax calculator in Google Sheets.
Conclusion
A staking rewards tracker is one of the most effective tools for understanding your true performance and optimizing your compounding strategy. This free Crypto Staking Rewards Calculator Google Sheets Template, powered by the CoinGecko API, provides a simple yet powerful way to log all your staking positions and analyze your performance. Because it’s built in Google Sheets, your tracker is accessible online across all your devices, ensuring you can manage your staking portfolio anytime, anywhere.
The integrated dashboard gives you a clear snapshot of your active positions and historical earnings, while the Dynamic Staking Projection Tool helps you forecast future growth and make informed compounding decisions.
Consider subscribing to a paid API plan if you require more frequent data updates, higher call credits, or access to exclusive endpoints beyond the Demo API’s limits.
Download Your Free Template ⬇️