Deep Dive: Switchboard
Connecting the blockchain to the real world
Remember this visual from the early 1900s? This is a telephone switchboard. Back in the day, you couldn’t just dial up your friend’s number and connect in seconds. First, you call a telephone network operator, they would receive your call by plugging one end of the lead into the switchboard. Then, depending on which city you wanted to call in to, the operator plugs in the other end of the lead into the corresponding destination node, completing the circuit. Once your call was done, the operator would disconnect both leads and start the process all over again.
For almost a century, this is how information travelled across the world - cavernous rooms of operators manning complex floor-to-ceiling switchboards and connecting input nodes to the right output nodes at a frenetic pace.
Today’s topic of exploration, the aptly-named Switchboard wants to be the ubiquitous data platform for the Solana blockchain, enabling any developer to bring data from the real world and feed it into the various apps and protocols that require it.
Inputs 🤝 Outputs.
Before we dive deeper into the mechanics of the platform, it’s important to understand why Switchboard is so fundamental to the Solana dev ecosystem.
A Supercomputer Without an Internet Connection
Blockchains are incredible systems - Distributed ledgers that maintain a record of transactions as a single source of immutable truth. Whatever happens on the blockchain stays on the blockchain. Be it a transaction or an agreement, everything is recorded, searchable, and verifiable.
Smart contracts, layered onto the blockchain make the system even more explosive. It makes money programmable. Two parties can enter into agreements without a middleman and trust that it will be executed once the set conditions are met.
However, the blockchain is sort of like a supercomputer with no internet connection.
It is disconnected from the real world. While it has infinite knowledge and a historic record of what happens on the chain, it is oblivious to anything outside of it.
The blockchain is unaware of what the weather is, what the price of Apple stock is, or how much the Nasdaq moves over a given time scale or even who won the IPL (though it can almost always be certain it wasn’t RCB).
It exists in its own world. Immutable but isolated.
Oracles are data feeds that relay information from the outside world onto the blockchain.
The data can be anything that developers find valuable enough to bring to the blockchain - stock prices, weather information, sports results, TV guide times, movie cast lists.
Here’s an example of how oracles work.
Imagine you want to place bets with your friend on the winner of the next F1 race in Azerbaijan. She’s a Verstappen fan but you like Lando’s gutsy driving.
So you build a simple contract on Solana that holds both your deposits in escrow and then transfers the winnings to either party once the race is done. However, the contract doesn’t know the results of the race. So it needs to fetch the race results via an oracle.
And voilà! The race ends. Lando scores a shock victory over Verstappen and the smart contract delivers your winnings automatically.
Emboldened by your gambling prowess, you proceed to make another bet. For the next race in Canada, you believe that not only will Lando win again but the weather will be extremely hot and temperatures will touch an all-time high of 30 degrees Celsius.
You use the same smart contract but now you input data from two different oracles to execute the program - one which tracks the results of the race and another which tracks the local weather of Montreal.
While I do not condone degen bets on the weather, the obvious utility of oracles becomes evident. Layer in millions of data feeds and you can create a decentralized and trustless betting platform for almost anything.
My 3 Favourite Use-Cases for Oracles
Other than betting platforms and prediction markets, here are 3 of my favourite applications of oracles in the real world.
Price Feeds for DeFi - All DeFi applications need live market data to execute their financial smart contracts. Oracles provide full market coverage in a real-time, aggregated and untampered format.
Supply Chain Automation - For warehouses that track inventory using IoT devices, Oracles can upload sensor data to the blockchain and trigger smart contract payouts to suppliers as soon as new inventory is received. Once inventory is over, an oracle can trigger the smart contract to replenish stock.
Drone Imagery in Construction - Drones are fast becoming the default way to monitor progress on construction sites. With drone maps that understand how fast construction is progressing and an oracle to input the data on-chain, smart contracts could automate payouts from banks or master builders to contractors at pre-defined completion stages. Drones 🤝 blockchains = single verifiable source of truth for any infrastructure project in the world.
How Does Switchboard Work?
The 3 core tenets of the platform are,
Principle I: Be community-driven.
Principle II: Democratize decentralized data.
Principle III: Build robust and secure data pipelines.
Switchboard Principle I: Be Community Driven
Community is at the heart of the network. Switchboard outlines clear roles and responsibilities for each of its constituents with defined incentives that reward them as the network gets stronger. The creators believe that the best way to minimise failure and bad-actor risk is giving everyone skin in the game. If the network loses, so do its players.
Who are the players in the network?
At the centre of it all is the DAO
The democratic DAO has various governance roles but its primary role is simple - vote on which data feeds get to be added on to the Switchboard network. DAO members can suggest two types of changes,
Protocol proposals that suggest changes to the architecture of the Switchboard network like adding new oracles, changing voting structures, or membership rules.
Queue proposals that suggest changes to individual oracle parameters like how much money an oracle needs to stake in order to join the network (to be explained further along) or how to deal with oracles that continually output incorrect data.
Then come the Curators
Curators go out into the internet and find data sources that they believe to be relevant to developers and submit them to the Switchboard network.
Since the Curator’s findings are the bedrock of this data pipeline between the outside world and the Solana blockchain, Switchboard encourages them to find multiple redundant data sources. The network, even at its base layer, is never reliant on any one source, i.e one single point of failure.
Switchboard makes it super easy for anyone to provide a new data source to its with an open-source reference implementation.
Incentive - If a Curator’s data source is utilised by the network, they receive a percentage of the fees generated.
Like an army of ants with a hive mind, this pushes the community to constantly curate stronger data sources with multiple redundancies.
And finally, we have the Publishers
Once enough data sources are compiled in the registry, it is the Publisher’s job to create a signal from this noise, i.e a data feed.
Each job corresponds to a data endpoint that must be parsed, cleaned and then converted into a standard format, like an integer value. Next, these jobs are compiled and the median value is calculated and outputted to the network, which results in the data feed - an aggregated layer of multiple data sources that produce a median result.
Publishers also decide how often the data feed is refreshed - certain feeds like crypto prices require frequent updates so exchanges can always reflect live prices, other feeds may only require updates every couple of days or so. Publishers also provide the initial funding for the feed and submit it to the DAO for approval.
Incentive - Publishers receive a percentage of the fees generated from their data feeds.
Developers also have the freedom to build a private data feed that does not require DAO approval.
How does the DAO approve a new data feed?
If the new data feed has a low refresh rate that does not stress the performance of the network, it is automatically granted permission to join the network. If the data feed is heavy and may cause delays, the DAO may reject it.
How does the Oracle publish data on-chain?
When a request is made, the oracle runs the jobs defined by the publisher, calculates the median value of all job responses and publishes the result on the Solana blockchain.
Once a select number of oracles reply back to the request, a final result is computed again by pulling the median value of all oracle responses. Repeated aggregation of multiple data sources ensures that the output is never dependent on any one source and never has one single failure point.
How does the network update data feeds?
As we will see in the next section, Switchboard provides the option of updating data feeds at customizable intervals depending on the use case. The network uses something called a ‘Crank’ to jumpstart the system
When a crank is pulled, the network goes into refresh mode and searches for any feeds that need updating. If outdated feeds are located, the crank initiator is rewarded. If not, the initiator’s transaction will fail.
How do network participants get paid?
Any protocol requesting data from the Switchboard network must pay a pre-defined price every time it uses the utility. That fee is distributed amongst the network participants who contributed to the published data.
Switchboard Principle II: Democratize Decentralized Data
A founding principle of the Switchboard network is to democratise the ability to procure, organise and deploy data onto the blockchain and most importantly, earn from its usage.
Switchboard treats data feeds as public utilities and expects the community to govern, iterate and also maintain them. As certain feeds invariably become more popular, the maintenance cost should be spread across the Dapps accessing it. This minimises the economic burden for users while ensuring a longer shelf life for the feed.
Data Feeds for Dummies: How to Become a Publisher and Create Your First Feed
Head over to Publisher | Switchboard and you can build your first data feed in under 60 seconds and also deploy it on-chain! It’s super easy to use and almost feels like a no-code drag and drop builder rather than a scary terminal.
Access the Devnet if this is your first go and you just want to test things out. You will need to connect your preferred Solana wallet to get started.
The site already has a few popular collections like NFT floor prices and crypto prices uploaded and ready to use. For purposes of brevity, let’s use one of these to create our data feed.
Once I’ve selected my collection, I can just add the data sources (jobs) I need into my cart.
The publisher also gives me the option to switch individual jobs on or off or toggle entire jobs off all at once. It is incredibly easy to customise the collection as you see fit.
Once you reach checkout, you can now add some configurations to your data feed on whether you need it to be updated or not. All these inputs also affect the price (seen at the bottom of the screen).
Automatic Updates - If selected, this option adds your data feed to the ‘crank’ (remember? the crank is the network’s refresh button) which just means that your feed will be updated at regular intervals.
Update Intervals - Determines how often and how long you want the feed updated.
Variance Threshold - Each data feed contains an escrow account that rewards oracles on each successful update. This threshold prescribes the % change needed before oracles return a new result to the chain. If the % change is low, the result is not updated, the oracle is not paid, and the feed saves money.
Force Report Period - The maximum amount of time after which data is considered stale.
Complete the transaction on the final checkout page and your data feed is created, ready to be used across the blockchain!
If you want to build a custom data feed instead, here’s a handy guide from Switchboard on how to do so.
Switchboard Principle III: Secure and Robust Data Pipelines
The blockchain is (largely) tamper-proof. However, since smart contracts often rely on price oracles from the Switchboard network to execute, there’s a real danger of bad actors meddling with data feeds and misfiring these contracts at prices advantageous to the attackers.
Here’s how Switchboard protects the data running through its pipes.
Repeated Aggregation of Data - When a protocol requests the price of SOL in USD for example, Switchboard has already aggregated the data at multiple layers from numerous different sources. The median value of the aggregated sources is the final output reported. This way, if one or even multiple data sources are hijacked or fail, the oracle is not affected and still outputs the accurate price.
Staking and Slashing - Oracles must deposit a certain amount of capital to participate in the network. This is basically the network’s insurance policy against bad actors. Once a data request is made by a protocol, several oracles respond to answer it. If their responses are close to the median value, they are remunerated accordingly. If an oracle reports a price that is abnormally far off from the median, a portion of their staked capital is slashed.
With this mechanism, the community ensures that oracles always act in the best interest of the network.
Deciding on the staking amount required from oracles is a fine balancing act - too low and attackers can take over the queue, too high and oracles can decide that operating on Switchboard is unfeasible.
Each data feed also keeps an account of successful and failed responses. If it returns too many incorrect or failed responses, it is booted from the system.
Round Robin-ing - Assigning data fees to oracles is never static on the Switchboard network. Oracles are switched (no pun intended) around with corresponding data feeds in a round-robin. The intervals of this change also vary so it’s hard to predict for any attacker which feeds and oracles to hijack.
“Most tech companies are building cars. We’re building roads.”
Patrick Collison, the CEO of Stripe, once famously stated that he viewed Stripe not as a tech company competing for user mindshare but as an infrastructure provider for a core utility of the internet - payments.
Much in the same way, Switchboard isn’t just another protocol. It’s essential tooling for the Solana Blockchain.
The blockchain cannot exist in solitary, it needs real-world data to unlock use cases that we haven’t even dreamt of yet. Games, lending, prediction markets, insurance, supply chain - every application will need oracles. And the best thing that we can hope for is that oracles themselves become public utilities. Free from centralised control, anyone must be able to build on top of them. We cannot afford to repeat the mistakes of web2 and silo data in walled gardens for the benefit of the few.
If we were to expand our time horizons even further, it is also completely possible that oracles and the blockchain fundamentally change how society receives its information.
Today, our news flows through biased media houses and opportunistic social feeds that only serve popular news, not the truth. As we move from this world of fiat information to cryptoinformation, where all news is verified through aggregated data feeds and stamped onto the blockchain, oracle platforms like Switchboard will become even more essential.
Not just for the blockchain but for the human race.