Skip to main content

Examples

AdaStream

AdaStream Example

AdaStream - Decentralized File Hosting Incentivised via Cardano Ada Payments

This project is a Cardano implementation of the BitStream protocol by Robin Linus.

Original paper: BitStream: Decentralized File Hosting Incentivised via Bitcoin Payments

TL;DR

  • Alice wants to buy a file from Bob.
  • Bob encrypts the file with a random key and sends it to Alice.
  • Bob creates a bond contract on Cardano with a collateral and a commitment to the key and the file.
  • Alice pays Bob for the file via a HTLC (Hash Time Lock Contract), using Cardano or Bitcoin Lightning Network.
  • Alice decrypts the file with the key from the HTLC or takes the money back after the timeout.
  • If Bob cheats, Alice can prove it and get the collateral from the bond contract.
  • Bob can withdraw the collateral by revealing the key.

The project includes a bond contract and a HTLC contract for a fair exchange of files for ADA.

It's a CLI tool and a REST API server that allows you to create a bond contract, pay for a file, and decrypt it.

It has a set of tests that check the contract logic and its execution costs.

PreImage Validator

PreImage Validator

Minting Policy

MintingPolicy