Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Fintech Meetup 20160705 - Smart Contracts

Fintech Meetup 20160705 - Smart Contracts

http://www.meetup.com/FinTech-Ireland/events/231968414/
We will present an overview of a number of different APIs from payment, banking, cryptocurrency, blockchain and smart contracts. The session should be about and hour and each API limited to 15/20 minutes. Networking and discussion afterwards.

• Smart Contract - a demo and walkthrough from Vineet Singh of Citi.

Vineet is an innovation lead in Citi Innovation Lab Dublin. He leads Citi’s work in blockchain and smart contract research. Supply Chains and Trade finance are the business areas when vineet hopes to make block chain’s a reality. He is a huge proponent of public chains and also represents Citi TTS in R3 group of Consortium. Vineet has a Master’s in in distributed systems and peer to peer networks from Trinity College Dublin.

Transcript

  1. Contracts don't make anything possible that was previously impossible, but

    rather, they allow you to solve common problems in a way that minimizes trust. Minimal trust often makes things more convenient by allowing human judgements to be taken out of the loop, thus allowing complete automation*. *https://en.bitcoin.it/wiki/Contract
  2. Decentralized provable execution of logic. A smart contract’s state is

    stored on the public blockchain. A smart contract program is executed by a network of miners who reach consensus on the outcome of the execution, and update the contract’s state on the blockchain accordingly. Users can send money or data to a contract; or receive money or data from a contract
  3. Block i Block i+1 Block i+2 Block i+3 Block i+4

    Mined Block Code Storage Miners Contracts Users Turing Compatible Smart Contracts Compatible Blockchains Data Money Blockchain
  4. Solidity Contracts • State Variables • Functions • Function Modifiers

    • Events • Structs • Enum Types Contracts in Solidity are similar to Classes in Object Oriented Languages.
  5. State Variables contract SimpleStorage { uint storedData; // State variable

    // ... } • external • public • internal • private
  6. Function Modifiers contract Purchase { address public seller; modifier onlySeller()

    { // Modifier if (msg.sender != seller) throw; _ } function abort() onlySeller { // Modifier usage // ... } }
  7. Events contract SimpleAuction { event HighestBidIncreased(address bidder, uint amount); //

    Event function bid() { // ... HighestBidIncreased(msg.sender, msg.value); // Triggering event } }
  8. Structs contract Ballot { struct Voter { // Struct uint

    weight; bool voted; address delegate; uint vote; } }
  9. Bob Alice Two Party Escrow Buyer unhappy with goods Received

    Seller refunds or money in escrow until they resolve
  10. Secure Contract Principles... • Error in encoding state machine. •

    Failing to use cryptography. • Misaligned Incentives. Ethereum Specific Mistakes • Call stack bug • Blockhash bug • Not checking return value of sender.send();