Reference inputs are a solution to Cardano's on-chain data publishing problem. Currently, the only way that Cardano smart contracts can receive input datum is from transaction outputs. In Cardano's EUTXO model these are single use. This creates a concurrency problem. Only one script can spend and read the output and then it does not have any obligation to re-post that datum as a new transaction output.
The only way to resolve this issue currently is via off-chain coordination. That goes against decentralization principles.
Fortunately, <u>CIP-31 reference inputs</u> provide the ability to reference the output of a Cardano transaction without having to spend it. This will allow for a data publication model where datum can be read many times by multiple smart contracts without the requirement to consume the publishing transaction. This will greatly simplify the ability for oracles to publish data on-chain for use by Cardano smart contracts.
CIP-31 functionality will be introduced by IOG in the <u>June Vasil hard fork</u>. The Cardano community will be well-served by an exemplar implementation. <u>MLabs</u> and <u>Orcfax</u> are uniquely positioned to design a CIP-31 reference implementation. Both teams have use for this new reference inputs functionality in their projects. They want to share their design choices and tooling with the Cardano open source development community as a Software Development Toolkit (<u>SDK</u>) written in Javascript.
The SDK will be released under <u>MIT</u> license. Documentation will be released under <u>Creative Commons</u> license. The SDK will contain a sample Plutus smart contract for a stop-loss order that is triggered using an oracle data feed.
The ability to consume smart contract data as reference inputs, without having to spend transaction data, will be a major design upgrade for the Cardano smart contract ecosystem.
MLabs will use its well-respected Cardano infrastructure engineering expertise to develop a best-practice reference implementation with a Javascript SDK. It will be used to create a Cardano oracle that publishes off-chain data as CIP-31 reference inputs to an exemplar smart contract that consumes this data on-chain.
The Orcfax project will use this design pattern and SDK for its Cardano oracle implementation. The tooling and documentation will be a valuable resource in the Cardano open-source ecosystem for all developers tackling the input of off-chain data to Cardano smart contracts.
RISK 1: The introduction of CIP-31 (and supporting CIP-32, CIP-33) is delayed by IOG.
STRATEGY: This feature is a top priority for IOG to make Cardano a competitive L1 so delays are very unlikely. Reference inputs have been publicly announced by the IOG delivery manager for June release and CIP-31 related issues and PRs on Github are active and advanced. Even if it is delayed, this Reference Inputs SDK project can progress on Testnet.
RISK 2: The project introduces insecure code onto Cardano Mainnet.
STRATEGY: This project will not be creating a production Mainnet implementation. It will create as-is development tools that will be tested on Cardano Testnet and released, without liability, under open-source MIT license. When Orcfax pushes its infrastructure to Cardano Mainnet it will engage a third-party security audit. It is recommended that all risk-averse Cardano projects do the same.
RISK 3: The complexity and scope of smart contract use cases makes it difficult to chose a generic example.
STRATEGY: The most well-known implementation of oracles in the blockchain space is crypto-currency exchange rate feeds. We'll create an exemplar Plutus smart contract that sets a stop-loss order at a specific BTC/ADA price. We'll trigger that script when the oracle publishes the matching data. The design pattern adopted to implement this use case can form the basis of many other types of interactive oracle-based smart contracts that Cardano developers will need to implement.