paint-brush
Near-Zero: Using Rootstock To Build The Stablecoin Satoshi Wantedby@walo

Near-Zero: Using Rootstock To Build The Stablecoin Satoshi Wanted

by walo, the underscore.November 29th, 2024
Read on Terminal Reader

Too Long; Didn't Read

Implications of a stable, decentralized, non-fiat-pegged cryptocurrency on global trade and local governments. While Sat never sat to discuss stablecoins explicitly, what does building one on the BTC blockchain through Rootstock mean for web3?
featured image - Near-Zero: Using Rootstock To Build The Stablecoin Satoshi Wanted
walo, the underscore. HackerNoon profile picture

It’s 1305, and you’re alive in a remarkable and beautiful city on the coast of West Africa; long before tonnes of foreigners and oily waste began to drift ashore. Dropped in your hands is a big bag of cowries by your old master whom you’ve trained under for years—a gift—to ease the journey to stand on your own.


“They’re just empty shells”, he says to you, in your sing-song mother tongue. “But you decide the weight each one carries, we all do.” Ah, dreamy.


Unfortunately, it’s 2024. And each government says all the money is theirs—the biggest mistake in our history.


If you struck gold while digging in your compound, who owns it? How about in the forest?


You see, Satoshi was fed up with this control that governments demand and, saw the digital economy as the weight to counterbalance it. They “back” their fiat currencies mainly because they make & enforce the rules. It’s their world, and we should consider ourselves lucky to be in it, they think.


You know Da Rules!

But through the bold attempt known today as Bitcoin, our world slips through their grasp.


Cheating the System, Globally

As Satoshi expected, volatility is/was inevitable as adoption grows. BTC was created to serve as an alternative store of value beyond centralized regulation, but it will remain unstable until global adoption is reached.


This is not the first conversation about a global currency. The fate of money was changed forever at the Bretton Woods Conference of 1944, which replaced the GBP with the USD as our monetary reserve. (GBP had silently replaced Isaac Newton’s local-turned-global gold standard through its colonial influence)


This was a global decision made by representatives from 44 (out of 195) countries at this conference held in the USA. How did we get here?


John Maynard Keynes (English Academic Economist) had been pushing for a global currency for years. His voice was finally relevant during WWII when Europe realized the difficulties of global trade with their [former] colonies and other countries for essentials & weapons.


Since America had been instrumental in the war and had grown in global influence, Harry Dexter White (American Government Economist) pushed for the dollar standard with Keynes. And the room agreed, believing the dollar would stay pegged to gold.


Tracing the sequence of events that led us to this point is not the purpose of this piece, but this was the final thread in our entanglement. And in 1971, US President Richard Nixon crushed the Bretton Woods system by annulling the USD peg to gold at $35 per ounce.


The “Nixon shock” rug-pulled the whole world. Sounds familiar?


Oh no, betrayal. 🙄

Does the World Need Another Stablecoin?

In Satoshi’s design, temporary volatility was the tradeoff for long-term stability & trust.


Web3 was built by stacking two technologies: the blockchain and cryptocurrency, each serving the other to provide the security & decentralization builders strive for to this day.


By explaining how they both work, Satoshi made them open-source, expecting others to carry the technology further than the initial design by standing on its stacked shoulders.


The largest barrier to entry for Bitcoin is not necessarily awareness or technology. It’s the confidence that the value I store as crypto is not Schrödinger's cat. Fiat has provided less volatility in this sense, but none near zero without negative consequences.


And while there are “stable”-coins pegged to fiat currencies, they go down with them too. Old money was not based on abstractions or a flimsy trust in the government. If we were not sure the sun would shine tomorrow, we could not live.


With careful execution, a stable, decentralized, non-fiat-pegged cryptocurrency is possible.


And if its primary function is near-zero volatility, what would happen to the world if we built it on the Bitcoin blockchain, right here?


Seat belt, we’re changing gears.

All for family.

Building Requirements

  1. Defining our stablecoin
  2. Selecting our Blockchain
  3. Engineering our Smart Contract
  4. Designing for Equilibrium
  5. Deployment & Testing


Defining our Stablecoin

Metrics

  • Peg: What is it pegged to?
  • Asset Quality: What are our reserve assets?
  • Asset Liquidity: How liquid are these reserves?
  • System Conditions: What conditions make this work?
  • Market Confidence: Why should people trust it?


Peg: Commodity

Resources are the most valuable things on this planet. Money exists to trade resources—a resource-rich country can create infinite possibilities with its natural gifts.


And when resources are scarce, your money is worthless. Empty shells, just like your master promised. Money is merely a representation of the inherent & time-bound value of resources. Pegging money to money alone is the most stupid thing I ever heard, but we’ll get back to this.


Countries infiltrate other countries to seize or swindle their resources: labour, gold, oil, diamonds, pleasure—name it. Nothing of value is off-limits to power-drunk people, only the strong can protect their treasures.


Since it’s clear that the real value is in resources, we dare not peg our near-zero volatility stablecoin to the USD.


This coin must be commodity-backed.


Verify this.

Asset Quality: Easily Verified

The gold standard was triggered by Isaac Newton as Master of the Mint. His job was to keep the coins in circulation at the specified weight & quality.


By standardizing the gold coins—Britain’s sovereign commodity, Newton brought a modular system to the British economy because of the nature of gold. It’s everywhere, divisible and acceptable even if not minted.


Britain’s standard gold coin was the guinea: each containing (in today’s units) 8.3 grams of 22-carat gold, equivalent to 1.05 pounds sterling.


This British pound was abstract, merely representing & quantifying all the different qualities of gold they traded. Think of it like a unit. Units help us convert properties by highlighting their relationships.


So if you brought new gold into circulation, Newton’s team standardized it. They did the same to foreign and old gold coins in circulation too, so the British people could trust the money—without having to trust each other or the government.


The GBP standardized transactions in real-time, while Newton worked to standardize the coins in circulation to ease trade. Coins in circulation became the same weight, purity & design, reducing the need for verification.


The highest asset quality of any commodity-based monetary standard is one that is easily verified.


Our commodity’s value must be easily verified, with a clear potential for future exchange. Low risk.


Asset Liquidity: Light & Essential

The two crucial factors that make a stablecoin are Liquidity & Collateral. If everything in existence is energy in motion, then:


Liquidity is kinetic energy: The measure of value available for instant trade.

Collateral is potential energy: The measure of value available for future trade.


We just discussed collateral. But when you give someone money as payment, you get the resources—the real value, and they hold only the money. This is a risk because there’s always the potential to lose value by holding the money.


If you held $1 for 25 years, it most likely will not get you the same things it could before, for example.


Because of this risk of losing value by saving money, currencies are backed up by tangible collateral (resources) to give users the confidence that Schrödinger hasn’t set them up. *coughs in Nixon*


This exchange pegs the value of the collateral to A value of the currency. But if the “measure of value available for instant trade“ aka Liquidity drops, so will the value of the coin.


But if liquidity stays high, people will be too busy exchanging resources to worry about risk, even though it’s always there.


Liquidity is how easy it is to get your money out of a system when you need it.


Assuming there are enough resources to back up our abstract money (there usually aren’t), this ease depends on how willing the market is to swap with you for those resources.


Fundamentally, every unit of currency you have represents physical resources.


Our stablecoin must be light & essential: built on commodities people can’t do without, and be easy to manage.


System Conditions

After several rug-pulls and devaluations of various cryptocurrencies, the next stage of web3 is pretty clear.


We want our coin to fill this vacuum successfully. For it to be a stable, decentralized, non-fiat-pegged cryptocurrency, we’ve looked at our past monetary failures and successes.


We know it has to be pegged to a commodity that is essential, light, and easy to verify. Can you think of any ideas?


For the sake of this piece, I’ll bring up a bizarre example so it’ll stick better. Nuclear warheads will be our Commodity. Haha, stay with me.


The record from early this year is about 12,121 units in existence. They never tell us the real number. Our smart contract will be based on the condition that the number of warheads deployed will always = 0.


We don’t want them used anywhere again. Essential.


While it’s an opportunity for a demonstration of blockchain technology to maintain “world peace”, the likelihood of all governments agreeing to share the real-time data is slim. They want the advantage of surprise. Not Light.


For our code, should we just assume it was light and we had that data published on a blockchain?


We’d then include an oracle in our smart contract because it’s a real-world scenario that affects us directly.


Market Confidence

Market confidence in this coin would be low because government participation is unlikely, so we can’t test the blockchain. And if the data was available, would you really want to know if it was headed your way?


"Sorry guys, there's one headed your way right now."

So let’s try again.


This time, we’ll focus on triggering our smart contract when there’s a nuclear launch attempt instead of our imminent doom.


Combining satellite imaging and the work of organizations that track nuclear weapons & publish their data, we can create comprehensive data to work with. We’ll turn this data into one or two simple, useful metrics to feed our blockchain, achieving public accessibility without compromising security.


First, we’ll go a step further and combine the satellite & open-source data with real-world events using AI to create our first metric: the Fear Index.


It would be a part of the smart contract but not a consequential factor in calculating the main condition—a nuclear launch attempt. It would serve as a pulse check for leaders, but more importantly, it would give people something to gnaw on.


This is important for preventing the coin from becoming volatile due to panic. Instead of telling us to calm down, we’ll quantify our fears.

"We’re this scared right now, guys."


Fear is contagious, so we’ll quarantine it. But this index is not enough on its own.


Beside it, will be the Calm Index, a metric based on satellite imaging & field data alone to say, we haven’t recorded any attempts using our best sources. Ideally, this Calm Index will remain stagnant if there are no attempts to activate or launch one, keeping the coin stable when much worse happens to fiat during wars.


Our coin’s value will remain fixed to the number of warheads remaining vs the number of warheads fired. Not the attempts.


This means we’d have to fire all of them to make the coin volatile.

Sensational.


Now, let’s see our blockchain.


Selecting our Blockchain

When I started working on this, I asked all my web3 nerd friends if they could build a stablecoin on the BTC blockchain assuming they had a reliable peg. The consensus?


It’s possible but difficult.


It seems Rootstock hasn’t become as popular as it should be yet. Though web3 tech evolves beyond Satoshi’s vision, the buck still stops at the coin made of bits, the Bitcoin.


Each new phase of web3 takes us back to the drawing board. Its blockchain is an untapped resource and Rootstock is the taproot. Why build a stablecoin on any other chain?


To keep this article brief, I described our stablecoin project to the Perplexity AI. Then I asked for the metrics for a high-quality blockchain and the metrics the project needs.


It scored high for each of these, which you can plug into your AI to verify yourself:


  • Security: Does it give us peace of mind?
  • Scalability: Does it easily & quickly handle high volumes of transactions?
  • Cost-Effectiveness: Does it save us gas fees?
  • Interoperability: Is it compatible with other blockchains, dApps & DeFi apps + services?


Then I asked it to tell me if Rootstock could do the job. The short answer is yes. It’s a very useful Bitcoin sidechain, including the possibility of liquidity options from DeFi apps when designing our infrastructure.



Engineering our Smart Contract

  • Minting Conditions
  • Peg Mechanism
  • Initial Supply
  • Gas Fees



Coin Name: KOINONIA

Ticker: KONKONB-LO

Blockchain: Rootstock/Bitcoin

Minting Conditions: Unlimited, if for the past 365 days, the number of nuclear warhead fire ATTEMPTS daily / the number of warheads FIRED daily > 0.

Peg Mechanism: Conditional value; the number of nuclear warheads FIRED daily = 0.

Initial Supply: Number of warheads x 10^(Duration of 1st nuclear weapon agreement in years) = 12,121 x 10^25

Gas Fees: Let’s build the code.


I wrote it in Solidity, including one for our hypothetical oracle. Next, we’ll compile it into bytecode using Hardhat.


Here are our programs:


// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;

interface IOracle {
    function getAttemptedFires() external view returns (uint256);
    function getActualFires() external view returns (uint256);
}

contract KOINONIA {
    string public name = "KOINONIA";
    string public symbol = "KONKONB-LO";
    uint8 public decimals = 25; // Set to 25 decimals
    uint256 public totalSupply;
    address public owner;

    uint256 public yearlyCap; // Maximum tokens that can be minted in a year
    uint256 public mintedThisYear; // Tokens minted in the current year
    uint256 public currentYear; // Current year as a timestamp
    IOracle public oracle; // Reference to the oracle contract

    mapping(address => uint256) public balances;

    event Minted(address indexed to, uint256 amount);
    
    constructor(uint256 _yearlyCap, address _oracleAddress) {
        owner = msg.sender;
        yearlyCap = _yearlyCap * 10 ** uint256(decimals); // Set yearly cap
        currentYear = block.timestamp / 365 days; // Initialize current year
        oracle = IOracle(_oracleAddress); // Set the oracle address
        totalSupply = 12_121 * (10 ** 25); // Initial supply based on nuclear warheads
        balances[owner] = totalSupply; // Assign initial supply to owner
    }

    // Function to mint new tokens
    function mint(uint256 amount) external {
        // Check if we need to reset for a new year
        uint256 newYear = block.timestamp / 365 days;
        
        if (newYear > currentYear) {
            currentYear = newYear; // Update to new year
            mintedThisYear = 0; // Reset minted count for the new year
        }

        // Get data from oracle
        uint256 attemptedFires = oracle.getAttemptedFires();
        uint256 actualFires = oracle.getActualFires();

        require(attemptedFires > actualFires, "Condition not met: More actual fires than attempts");

        // Calculate allowed minting based on attempted vs actual fires
        uint256 allowedMinting = (attemptedFires - actualFires) * 10 ** uint256(decimals); // Example calculation

        require(mintedThisYear + amount <= allowedMinting, "Yearly cap exceeded");
        
        totalSupply += amount * 10 ** uint256(decimals); // Increment total supply
        balances[owner] += amount * 10 ** uint256(decimals); // Increment owner's balance
        
        mintedThisYear += amount * 10 ** uint256(decimals); // Increment the minted count
        emit Minted(owner, amount * 10 ** uint256(decimals)); // Emit event for minting
    }

    // Function to check balance of an address
    function balanceOf(address account) external view returns (uint256) {
        return balances[account];
    }
}


And for the Oracle, which will get data from the same sources as our Fear & Calm Indexes.


// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;

contract Oracle {
    uint256 private attemptedFires;
    uint256 private actualFires;

    function updateFires(uint256 _attemptedFires, uint256 _actualFires) external {
        // Only allow authorized users to update these values (implement access control)
        attemptedFires = _attemptedFires;
        actualFires = _actualFires;
    }

    function getAttemptedFires() external view returns (uint256) {
        return attemptedFires;
    }

    function getActualFires() external view returns (uint256) {
        return actualFires;
    }
}


Gas Fees Estimation

  1. Deployment Cost:
    • Estimated at around 200,000 - 300,000 gas units.

    • Assuming a gas price of 30 gwei, this would cost approximately:


      250,000 gas × 30 gwei ≈ $15 USD


  2. Mint Function Call Cost:
    • Each call could cost approximately 50,000 - 100,000 gas units, leading to a cost of about:


      75,000 gas × 30 gwei ≈$ 4.50 USD


I can hardly write code but with AI this was possible. I fed Perplexity this data in the flux and asked for cost optimisation & estimation.



Designing for Equilibrium

  • Future Updates
  • Commodity Value
  • Market Sentiment, Manipulation & Regulations
  • Resources over everything: Pressure on the USA to stay relevant.
  • Condition Backing: Commodity price, Capped insurance per wallet with more for more investment, X% lockdowns, Stability tenure guarantee (unlimited minting)


Future Updates

To allow for future updates, we would add a proxy contract like so:


// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;

contract Proxy {
    address public implementation;
    address public owner;

    constructor(address _implementation) {
        implementation = _implementation;
        owner = msg.sender; // Set the deployer as the owner
    }

    function upgrade(address newImplementation) external {
        require(msg.sender == owner, "Not authorized");
        implementation = newImplementation;
    }

    fallback() external payable {
        (bool success, ) = implementation.delegatecall(msg.data);
        require(success, "Delegatecall failed");
    }
}


To ensure that the contract works with the proxy, we’ll make a slight mod:


// SPDX-License-Identifier: GPL-3.0
pragma solidity >=0.8.0 <0.9.0;

interface IOracle {
    function getAttemptedFires() external view returns (uint256);
    function getActualFires() external view returns (uint256);
}

contract KOINONIA {
    string public name = "KOINONIA";
    string public symbol = "KONKONB-LO";
    uint8 public decimals = 25; // Set to 25 decimals
    uint256 public totalSupply;
    address public owner;

    uint256 public yearlyCap; // Maximum tokens that can be minted in a year
    uint256 public mintedThisYear; // Tokens minted in the current year
    uint256 public currentYear; // Current year as a timestamp
    IOracle public oracle; // Reference to the oracle contract

    mapping(address => uint256) public balances;

    event Minted(address indexed to, uint256 amount);
    
    constructor(uint256 _yearlyCap, address _oracleAddress) {
        owner = msg.sender;
        yearlyCap = _yearlyCap * 10 ** uint256(decimals); // Set yearly cap
        currentYear = block.timestamp / 365 days; // Initialize current year
        oracle = IOracle(_oracleAddress); // Set the oracle address
        totalSupply = 12_121 * (10 ** 25); // Initial supply based on nuclear warheads
        balances[owner] = totalSupply; // Assign initial supply to owner
    }

    // Function to mint new tokens
    function mint(uint256 amount) external {
        // Check if we need to reset for a new year
        uint256 newYear = block.timestamp / 365 days;
        
        if (newYear > currentYear) {
            currentYear = newYear; // Update to new year
            mintedThisYear = 0; // Reset minted count for the new year
        }

        // Get data from oracle
        uint256 attemptedFires = oracle.getAttemptedFires();
        uint256 actualFires = oracle.getActualFires();

        require(attemptedFires > actualFires, "Condition not met: More actual fires than attempts");

        // Calculate allowed minting based on attempted vs actual fires
        uint256 allowedMinting = (attemptedFires - actualFires) * 10 ** uint256(decimals); // Example calculation

        require(mintedThisYear + amount <= allowedMinting, "Yearly cap exceeded");
        
        totalSupply += amount * 10 ** uint256(decimals); // Increment total supply
        balances[owner] += amount * 10 ** uint256(decimals); // Increment owner's balance
        
        mintedThisYear += amount * 10 ** uint256(decimals); // Increment the minted count
        emit Minted(owner, amount * 10 ** uint256(decimals)); // Emit event for minting
    }

    // Function to check balance of an address
    function balanceOf(address account) external view returns (uint256) {
        return balances[account];
    }
}


Through this proxy contract, we can update things. The number of nuclear warheads is more likely to increase over time. We can add new units for them, and make other necessary modifications without messing up our systems or causing inconveniences.


Commodity Value

The condition for our Asset Quality was that it would be easy to verify. For Asset Liquidity, it was that it would be built on commodities people can’t do without, and be easy to manage.


Since such activity is typically kept under wraps, we first benefit by increasing our involvement a little more in our family’s survival. If adopted, we tie all our fates together to create a raft that stays afloat, and a third leg that even fiat can lean on.


Nuclear weapons are very expensive. And if they aren’t used to wage war, they can be recycled to serve nuclear plants and projects. The risk of the collateral losing value is quite low. Instead of representing only pain, these are valuable earth minerals that we’ll always need, as is our human nature.


The more positive attention is directed to nuclear weapons in their potential state by turning them into cryptocurrency collateral, the harder it’ll be to deploy them. Their value will also increase beyond their destructive potential.


This is where web3 shines best, giving us the tools to change the energy states of the physical world in our consciousness.


Perhaps such changes will reduce the need for the nuclear stalemate we use to keep the peace. The challenges towards achieving this are great, but a wise man once said,


“Where the willingness is great, the difficulty cannot be great”


Remember that this topic is just an example to guide your understanding of what it takes for us to achieve this stablecoin, and its ripple effects.


Because its value is condition-based, it wouldn’t depend on the US dollar, whose value comes from the trust in the government.


It couldn’t operate in a bubble but exist in its dimension while interacting with each currency natively.


So 1 Koinonia = 1 nuclear potential,

which could be linked to [Amount of] energy output from [Radioactive Material] source for [Amount of] load conditions.


The local price of energy could then be used as the bureau de change, where you store some of your money as energy in the form of KONKONB-LO. Worth it, yeah?


Market Sentiment, Manipulation & Regulations

The existence of this our sample “near-zero” stablecoin might shock initially as an existential threat to any anarchist, cybercriminal or government, but we introduce the energy discussion to calm them down.


Some might dare to deploy the warheads to fluctuate the currency. After all, they could aim for a place where nobody lives, they might think.


But we can quickly identify the source with our tech and begin to take economic sanctions against those responsible. Because its value is based on what happens today, our coin could return to stability as soon as the next day, if it shakes.


There will also be fail safes to ensure people can get some money out, but not all of it. The only way to keep our coin volatile is to keep firing nuclear weapons daily, and that's no machine gun.


For this hypothetical coin to succeed, we’ll need to keep talking about it, poking holes in it, growing it and building our trust in it.


We’d need to expect some negative sentiment upfront and change people’s perspectives by doing good work.



But without international support, it can’t reach its full potential. I’ll finish this—but first; how do we test our code in a controlled environment?



Deploying & Testing on Rootstock

We compile our contract to begin testing.


This means exporting it as a folder containing the Solidity source code (.sol file) and the compiled code JSON files of your bytecode (the binary version), ABI (Application Binary Interface) & other metadata.


Next, deploying using deployment tools like Rootstock CLI, Hardhat, JavaScript libraries (like Web3.js), or wallets like MetaMask. Once we link the tool to the folder, we can create & broadcast our transaction on the blockchain.


We have the estimates for gas fees, and each tool used (above) comes with instructions to initiate the transaction. Once that’s complete, we’ll receive our contract address, live on the Rootstock TestNET Explorer.


Each transaction sent to this address carries a packet of data carrying our instructions to the Rootstock sidechain. With it, we get all the benefits of the Bitcoin blockchain + advanced smart contracts like this.


This is our playground, and over time we see if our plan works before we move on to the mainnet.


Rootstock provided its Docs library & Developer courses for help.


Not so bad, hey? Let’s talk about Quency-Quences.



Consequences of A Near-Zero Volatility Stablecoin

An Easy Self-Government

This type of powerful stablecoin could even end up replacing governments completely if enough projects develop to fund practical solutions for involved communities instead of say, a mathematical solution like Satoshi designed in Bitcoin. But hold on, we like Math.


Our coin is protected by Satoshi’s web of its complexities + the relevance of the problem it solves to the global community.


While this sort of power costs significant autonomy from local and otherwise governments, it pays back with stability to reserve their fiat—if they’re wise enough to see the benefits. Societies that embrace technology govern better.


It’s quite similar to the GBP handing over the office of serving as the global fiscal reserve to Britain after it had exhausted its savings in “World” War. More like the Northern War if you ask me. Nobody asked our opinion on it, instead conscripted our labour AND economy.


After much warcraft, Rome learned to keep trading with Africa regardless.


More Dynamic Equilibrium

Did you ever wonder why Nixon would kill the peg?


US wanted to expand its influence. Do you know where the world is today because of this drive?


Now whoever is in that presidency bears the sole responsibility for the economic fate of the world.


“Bet on us”, Nixon said.

And through their position, America worked tirelessly to secure the resources of other governments.


In a sense, it’s patriotic. In another, war is patriotic;

they'll say they’re fighting to preserve their patrimony (freedom), even by taking the patrimony (resources) of others.


You having a stronger currency than theirs means they need you more, so they make excuses for their actions to hold on to power.


Relinquishing some of this power to such a stablecoin would make their jobs (looting and/or farming) much easier, while energy-rich African countries get another market to show their mettle, potentially causing unprecedented shifts in their cash flow.


Would they willingly invest in a stablecoin pegged to weaker currencies in their position?


To save your currency, they’ll tell you to, “make better deals with us and trade more within your system.” For us at the mercy of their wars, these deals have wrecked us through their swindling and infiltration.


Our trust in the US dollar is not earning. We lose precious resources to their economic practices for stressful power. In our neighborhood, China is packing out our lithium this time.


Oil & lithium are small resources in all the possibilities of energy. Why tie a knot once if it’s stronger twice?


To live is to rebel. Every day, we live in rebellion against death. Find satisfaction in your rebellion.


Like those gladly risking their lives for glory, there’s a lot you’re equally capable of if you accept some risk.


Do you see yourself holding such a coin?