<commit_before># Smart Contract - send me my EZchip T-shirt
**Table of Contents**
- [Introduction](## Introduction)
- [Smart contracts](## Smart contracts)
- [The contract](## The contract)
- [Installation](## Installation)
- [How to run](## How to run)
- [FAQ](## FAQ)
- [Disclaimer](## Disclaimer)

## Introduction
We demonstrate how to use [Ethereum](http://ethereum.org/) smart contracts platform to make an agreement between two parties.
In the agreement the first party *pays* in exchange for a (physical) mail delivery from the second party.
The *payment* is done with Ethereum crypto-currency ([ETH](http://coinmarketcap.com/currencies/ethereum/)). See [USD-ETH exchange rate](http://coinmarketcap.com/currencies/ethereum/)).
In addition, upon a successful delivery, a special (virtual) token, "The king of returning shirts", is assigned to the sender. The token serves as a certificate that indicates the sender name and it also tradable. That is, the sender may trade the certificate in exchange to ethers (ETHs).

**For the purpose of this demonstration we use _testnet_  ethers that have no value what so ever. The certificate resides over the _testnet_ network, and as a consequence there is no guarantee that it will last forever.**

## Smart contracts
*Smart contracts* are account holding objects on the ethereum blockchain. They contain code functions and can interact with other contracts, make decisions, store data, and send ether to others. Contracts are defined by their creators, but their execution, and by extension the services they offer, is provided by the ethereum network itself. They will exist and be executable as long as the whole network exists, and will only disappear if they were programmed to self destruct.

**TL;DR: a smart contract is an immutable and _unstoppable_ piece of software that can pay money**
## The contract
The contract code is deposit in [post_contract.sol](https://github.com/yaronvel/smart_contracts/blob/master/post_contract.sol). The interesting functionality resides in the `submit` and `__callback` functions.
In `submit` the sender gives the Israeli post office confirmation string (for example "RR12345IL") the date of delivery and his name.
The method invokes an [oraclize.it](http://oraclize.it/) oracle that queries the [Israel post office JSON api](http://www.israelpost.co.il/itemtrace.nsf/trackandtraceJSON) on the specific confirmation string and returns the data to the `__callback` function.
In `__callback` the contract verifies that the destination of the mail is correct and that the date is as stated (the date is needed to verify that this is a recent mail delivery).
Once the details are correctly verified, a *payment* is sent to the sender and the token is assigned after his name.
Then, he can trade the token with `set_for_sale` and `buy_king` methods.

## Installation<commit_msg>README.md fixed TOC<commit_after># Smart Contract - send me my EZchip T-shirt
**Table of Contents**
- [Introduction](##Introduction)
- [Smart contracts](##Smart contracts)
- [The contract](##The contract)
- [Installation](##Installation)
- [How to run](##How to run)
- [FAQ](##FAQ)
- [Disclaimer](##Disclaimer)

## Introduction
We demonstrate how to use [Ethereum](http://ethereum.org/) smart contracts platform to make an agreement between two parties.
In the agreement the first party *pays* in exchange for a (physical) mail delivery from the second party.
The *payment* is done with Ethereum crypto-currency ([ETH](http://coinmarketcap.com/currencies/ethereum/)). See [USD-ETH exchange rate](http://coinmarketcap.com/currencies/ethereum/)).
In addition, upon a successful delivery, a special (virtual) token, "The king of returning shirts", is assigned to the sender. The token serves as a certificate that indicates the sender name and it also tradable. That is, the sender may trade the certificate in exchange to ethers (ETHs).

**For the purpose of this demonstration we use _testnet_  ethers that have no value what so ever. The certificate resides over the _testnet_ network, and as a consequence there is no guarantee that it will last forever.**

## Smart contracts
*Smart contracts* are account holding objects on the ethereum blockchain. They contain code functions and can interact with other contracts, make decisions, store data, and send ether to others. Contracts are defined by their creators, but their execution, and by extension the services they offer, is provided by the ethereum network itself. They will exist and be executable as long as the whole network exists, and will only disappear if they were programmed to self destruct.

**TL;DR: a smart contract is an immutable and _unstoppable_ piece of software that can pay money**
## The contract
The contract code is deposit in [post_contract.sol](https://github.com/yaronvel/smart_contracts/blob/master/post_contract.sol). The interesting functionality resides in the `submit` and `__callback` functions.
In `submit` the sender gives the Israeli post office confirmation string (for example "RR12345IL") the date of delivery and his name.
The method invokes an [oraclize.it](http://oraclize.it/) oracle that queries the [Israel post office JSON api](http://www.israelpost.co.il/itemtrace.nsf/trackandtraceJSON) on the specific confirmation string and returns the data to the `__callback` function.
In `__callback` the contract verifies that the destination of the mail is correct and that the date is as stated (the date is needed to verify that this is a recent mail delivery).
Once the details are correctly verified, a *payment* is sent to the sender and the token is assigned after his name.
Then, he can trade the token with `set_for_sale` and `buy_king` methods.

## Installation
{'fraction_non_alphanumeric': 0.07767498690871007, 'fraction_numerical': 0.0017455053237912376, 'mean_word_length': 5.0, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '271512', 'n_tokens_mistral': 1484, 'n_tokens_neox': 1422, 'n_words': 778}