Skip to content

Latest commit

 

History

History
57 lines (35 loc) · 3.12 KB

details.md

File metadata and controls

57 lines (35 loc) · 3.12 KB

Paratii Contracts

Registry

The Registry.sol contract is a simple key-value store on the blockchain that holds Paratii general settings. In particular, this is the place where the addresses of the deployed Paratii contracts are stored.

For example, the following call will get the address of the ParatiiToken contract:

let paratiiRegistery = paratii.contracts.Registry
paratiiRegistry.getAddress('ParatiiToken')

The Registry is an Ownable contract, and contains simple setters and getters for several solidity types:

Registry.setAddress('Users', '0x12345') // can only be called by the owner of the contract instance
Registry.setUint('a-useful-constant', 99999)
Registry.getUint('a-useful-constant') // will return 99999

ParatiiToken

ParatiiToken.sol is an ERC20 token contract and contains the balances of all Paratii account holders.

paratiToken.balanceOf('0x123') // will return the balance of the given address

SendEther

SendEther.sol is a simple wrapper contract that can be used to send Ether, and will log an event so that the Paratii ecosystem can pick up on it.

Avatar

Avatar.sol is a contract that can send and receive ETH and other ERC20 tokens. It is controlled by a number of whitelisted addresses.

erc20Token = 0x12345667
Avatar.transferFrom(erc20Token, fromAddress, toAddress, amount) // will fail because you are not whitelisted
Avatar.addToWhitelist(0x22222222)
Avatar.transferFrom(erc20Token, fromAddress, toAddress, amount, { from: 0x22222222}) // sender is 0x2222, whihc is in the whitelist
Avatar.transfer(toAddress, amount) // transfer some ether to toAddress

Users

A registry with information about users.

Videos

Videos.sol: contains information about videos: their IPFS hash, its owner, and the price. The idea is that this contract only contains essential information: is that additional data (duration, license, descriptions, etc etc) can be stored in IPFS.

Store

The Store is the place to buy Videos. Buying a video in the videostroe will register your purchase, and split the money your are sending between the owner of the video and the Paratii Store.sol: The Videostore is the place where videos can be bought/sold. To do this, the user must initiate two transactions:

  • the client calls ParatiiToken.approve(Avatar.address, price_of_video) to allows the Avatar to transfer the price_of_video. (For small transactions, this can be done transparently)
  • the client calls Store.buyVideo(videoId), triggering a number of steps:
    • the price of the video will be transfered to the Avatar
    • an event will be logged that the video is unlocked for this user
    • records the purchase of a video on within the Users allowing the new owner to like/dislike the video
    • a part of the price will be transfered (immediately?) to the owner, other goes tot he redistrubtion pool. (In the first iteration, we can give all money to thee owner)