A live application on the Ethereum blockchain: A case study
This post will apply what we’ve learned from Preethi Kasireddy’s post (also see here) to a real application on the Ethereum blockchain, Power Ledger. It’s one thing to read the details that go into transactions, but it’s another thing to see it in the context of a live project.
Power Ledger: A Synopsis
Power Ledger is building a peer-to-peer marketplace for renewable energy.
This will allow “prosumers” (people who consume and produce electricity) to buy and sell units of energy. Imagine that you have solar panels installed on your roof; you could sell whatever excess capacity to your neighbors, with or without government or state-owned enterprises, intermediary (note: in most countries, energy is still highly regulated).
Notably, Power Ledger is attempting to build a platform of applications instead of a single business model, targeting just one product. Thus, they want their applications to be interoperable in their ecosystem and scale globally. These ambitions have a direct consequence for the design of their platform, namely a dual-token (POWR and Sparkz), dual-blockchain set-up (public Ethereum blockchain and private blockchain — Ecochain; there is plan to fully transition to fully using Ethereum, once it’s consensus algorithm transitions to proof-of-stake).
Although Power Ledger’s platform is designed to host many applications, for the purpose this article, we will focus on their primary app that enables peer-to-peer (p2p) energy trading (for other applications, see here and their whitepaper).
How does Power Ledger work?
In a regulated market, an ‘Application Host’ (i.e., the utility company, state-enterprise or other existing energy company) would onboard prosumers/consumers into the Power Ledger platform in two steps: Step #1) Buy POWR tokens off an exchange (note: early on, Power Ledger will also gift Application Hosts POWR tokens to encourage them to use and contribute to the platform); Step #2) Escrow the POWR tokens in a smart contract for Sparkz token. These Sparkz tokens would then be used to facilitate energy buying/selling between prosumers and consumers. Application Hosts need to have enough POWR tokens to generate enough Sparkz to satisfy transaction demands. Prosumers can trade electricity (kWh) for Sparkz token from consumers. In a regulated environment, prosumers/consumers could redeem their Sparkz tokens for cash from the Application Host.
The POWR token is an ERC-20 platform protocol token that can be bought/traded from any exchange, just like any other cryptocurrency. The Sparkz token is a transaction token pegged to the lowest denomination of a local currency in any geographic area; it’s used to facilitate energy transactions in a particular jurisdiction (e.g., 1 Sparkz = 1 Australian cent; 1 Sparkz = 1 Thai baht). The Sparkz token is used to maintain a steady exchange rate in local market electricity prices and cannot be traded in a typical cryptocurrency exchange.
Initially, Power Ledger only had the Sparkz token, which would have been enough to protect users from price volatility in the cryptocurrency markets. However, because Power Ledger has global ambitions for their platform, they needed an additional token. The POWR protocol tokens serve as an entry point into the Power Ledger platform — something they hope will be a global ecosystem, while Sparkz transaction tokens serve as usage tokens for any local market.
How about in a deregulated market, how exactly can I trade Sparkz?
In deregulated markets, there is no Application Host. Prosumers and consumers are free to buy POWR tokens from any cryptocurrency exchange to convert to Sparkz for energy trading themselves. Without a central intermediary, users will have to escrow POWR tokens in smart contracts and return any unspent Sparkz to the smart contract to recover POWR before cashing out.
Consumers (and prosumers) would acquire POWR, escrow in a smart contract for a number of Sparkz token. The combination of POWR (in escrow) and Sparkz tokens means that consumers have access to the Power Ledger trading platform to buy electricity from prosumers who can, in turn, receive Sparkz and later trade it for POWR before cashing out.
Power Ledger hopes to convey that by using their platform people are at greater liberty to choose which energy producer to support, thus more closely aligning their choices to reflect their values for clean, sustainable energy.
Moreover, Power Ledger has developed smart meters which records to the blockchain, at regular intervals, how much electricity a user has produced or consumed. The Power Ledger platform will direct payments to different users based on this information; prosumers are expected to get higher prices for each unit of energy generated (instead of having government tariffs be deducted from their payment). Finally, prosumers receive payment instantly, rather than having to wait weeks/months.
Does Power Ledger facilitate the actual electricity transfer?
At a base level, electricity generated from solar panels would flow back to the grid. In regulate environments, the power grid is controlled by utility companies. All transactions are settled on the Power Ledger platform, but the utility company will reimburse cash for Sparkz. In a deregulated environment, prosumers and consumers trade directly.
In both scenarios, power generated flows back to the grid, so consumers can receive power from a number of different sources, but direct funds to certain producers, based on the readings from the smart meter that Power Ledger records into the blockchain at regular intervals.
Why does Power Ledger need a token?
First, let’s establish why a public blockchain is needed. The same way bitcoin represented a trust-less innovation for financial transactions, Power Ledger is attempting to create a trust-less platform for energy transactions. In other words, without a public blockchain, prosumers and consumers would have to rely on a central intermediary, but instead of a bank, it’s a utility company (or a state-owned enterprise).
An alternative question could be: why aren’t people buying/selling energy units from each other right now? In short, the answer is trust (i.e., how many units of electricity are really being sold to me? how do I know you’re selling at market rates? how do I know i’m getting electricity to be sold?) and in a regulated environment, the utility company would eliminate this problem of trust. But, we know central intermediaries come with their own set of problems.
Once it’s established that Power Ledger wants to create a trust-less platform for energy transaction, they are faced with another problem — how do you get a user base to adopt a network at the beginning? (i.e., chicken before the egg) This is the other innovation Bitcoin brought into the world — the model to incentivize early network adoption.
So perhaps that explains why Power Ledger has one token, but why two?
The aforementioned ambitions of Power Ledger to create a platform at global scale is one of the reasons why there are two coins. The first coin, would incentivize earlier adopters. Power Ledger could do this in a number of ways including allowing users to pre-purchase electricity at discounted rates, by hosting token generation events (TGE) or by gifting tokens. The second coin, would be needed to allow prosumers and consumers of a particular jurisdiction to exchange energy, while being shielded from the price volatility that affects most cryptocurrencies.
This is essentially the role of Sparkz and POWR. The former (Sparkz) was the initial token devised by Power Ledger. Pegged to the local currency, it allows users to settle energy transactions without subject to price volatility. But because Power Ledger wants to facilitate energy transactions across multiple countries, without having to create a local token for every country. Because Sparkz are pegged to a local currency, it couldn’t be traded across jurisdiction. It needs a token that could be transferred across borders, while also giving people access to all application on it’s platform. POWR plays this role.
Thus, Power Ledger’s dual-token model fuels trust-less energy transaction, but also helps it scale globally.
Where do blockchains come in? Specifically, Ethereum?
Previously, we learned that to keep things simple, Ethereum could be thought of as having two types of accounts and two types of transactions (i.e., message calls and contract creation). In the context of Power Ledger, we can see both types at work.
First, in order to gain access to the Power Ledger platform, either an Application Host (regulated market) or regular users (prosumer/consumer) must exchange for POWR tokens on an exchange. Some amount of Ether or ETH (Ethereum’s native currency) and will use it to buy POWR tokens. This transaction is between two externally owned accounts (i.e., Application Host/prosumer/consumer’s wallet and the Exchange’s wallet) is basically a value transfer (i.e., some value of ETH gets exchanged for some value of POWR).
However, what makes Ethereum unique is its smart contract functionality, which comes into play once POWR is placed in escrow for Sparkz to allow energy exchange.
Here’s how that process would play out (conceptually):
First, a contract creating transaction is initialized; this involves setting the contract account’s state, including the: nonce (set to zero), account balance, storageRoot (set to empty) and codeHash (set as hash of empty string).
Then, the (smart) contract account would be created by running the init code. But before that it’s important to remember that even executing the init code requires gas. If it executes successfully, a final contract-creation cost is paid (i.e., storage cost proportional to size contract’s code).
Finally, if the smart contract is successfully created, any unspent gas will be returned to the original external account who initialized the process (e.g., Account Host in regulated markets; Prosumers/consumers in deregulated markets).
Bear in mind, this was simply the creation of the smart contract (referred as a smart bond in Power Ledger parlance). Once it’s been created, Sparkz need to be stored in the contract, waiting to be exchanged for POWR. Moreover, the smart contract must be programmed to release the POWR tokens once Sparkz are returned.
An additional instance of smart contract usage on the Power Ledger Platform is centered around what is called an “Asset Germination Event”. Here, POWR token holders can participate in asset ownership by submitting tokens to an Asset Germination Smart contract to own a % of the asset and it’s income distribution (see white paper for details).
While the above examples illustrate how the Power Ledger Platform transacts on the public Ethereum blockchain, it also has additional transactions with its private blockchain (EcoChain) such as storing metered energy usage data from prosumers and consumers at regular intervals for more efficient allocation of resources.
These are just a few examples of how the Power Ledger Platform will democratize power and energy exchange using the Ethereum blockchain.
Power Ledger Review [Video]
Power Ledger Review [Article]