(Note: this is a simple, short, non-technical introduction to File Contracts in Sia. For a more detailed and technical explanation, check Contracts).
File contracts are smart contracts contained within the Sia’s blockchain. They enable renters to use host’s free space with a well defined set of rules that will be automatically enforced without the need of actual trust between the two sides.
The renter stablishes an allowance: a pre-paid amount of Siacoin meant to pay storage and bandwidth costs for the total established duration of the contract (by default 13 weeks). This allowance gets locked in the wallet. The client software of the renter picks up 50 optimal hosts according to their scoring.
These hosts, as a guarantee of good intentions, locks an amount of Siacoins in collateral. The size of the collateral is setup manually by the host, but higher collaterals ensure a higher scoring during the hosts selection process.
The file contract is signed by the renter and the 50 hosts and is submitted to the blockchain.
A 3.9% of the renter’s allowance and a 3.9% of the host’s collateral put in the contract are paid as fees. These fees are paid to the holders of Siafunds.
The renter can upload and download his files as many times as he wants while funds remain in the allowance, paying for the bandwidth and storage costs requested by the hosts at the time the contract was formed. Host pricing updates do not affect current contracts.
Data transfer is done as a direct connection between the renter and his hosts (files are not included in the blockchain). Data is encrypted by the Twofish algorithm and stored with the redundancy algorithm Reed-Solomon among the hosts. Current target redundancy is 3x.
During the contract, the hosts must submit Proofs of Storage to the blockchain to demonstrate: a) they are online, b) they still preserve the renter’s files intact. Hosts are required an uptime of 97%.
If during the contract duration some hosts go offline, and so the redundancy drops below a certain value, new hosts will be recruited for the contract and data will be uploaded to them. Starting on Version 1.3 Capricorn, file repair works offline, meaning that the renter does not need to be online to allow the repair.
Depending on what happened during the contract window, there are different possible outcomes:
If the renter has enabled auto-renewal of contracts, some time before the expiration it will be auto-renewed. The renter needs to be online some time in advance to actually renew his contracts. Current pricing of hosts will be applied to the new contract, but if some hosts are not well scored anymore (because they are not offering competitive prices, for example) they will be replaced by new hosts.
If the contract is terminated without renewal, the files are deleted from the hosts immediately.