39
January 2017 Smart Contracts enabling the sharing economy Applied to mobile payments

Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

Embed Size (px)

Citation preview

Page 1: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

January 2017

Smart Contracts

enabling the sharing economy

Applied to mobile payments

Page 2: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

• What is a "Smart Contract"?• A "Smart Contract" is NOT…• Do SCs have anything to do with Blockchain and Cryptocurrencies?• What Smart Contracts are useful for?• How to improve business processes using Smart Contracts?

• MarketPay/LemonPay• Escrow Smart Contract• UnwiredApp: Instant Messaging Smart Contract

enabling the sharing economy

Page 3: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

3

Contracts & Computers

In 1958, the United States Department of Defense launched a computerized contract-management system that it dubbed Mechanization of Contract Administration Services, or MOCAS. Fifty-seven years later, it’s still going.

Trillions of dollars have passed through the computational records in MOCAS. In its current form the system is managing roughly $1.3 trillion in obligations and 340,000 contracts.

https://www.technologyreview.com/s/538966/what-is-the-oldest-computer-program-still-in-use/

Page 4: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

4

What is a “Smart Contract"?Para puristas: "La infraestructura de los smart contracts pueden ser implementados por registros de recursos replicados y la ejecución de los contratos pueden llevarse a cabo usando árboles Merkle los cuales funcionan mediante funciones hash criptográficas y la replicación de tolerancia a fallos bizantinos los cuales son una generalización del problema de los dos generales. Cada nodo en la red p2p actúa como un registro de propiedad y de fideicomiso o garantía, ejecutando los cambios de los titulares del contrato y comprobando automáticamente las reglas que impone la transacción, y comprueba también el mismo trabajo de los otros nodos."

https://es.wikipedia.org/wiki/Contrato_inteligente

A smart contract, also known as a cryptocontract, is a computer program that directly controls the transfer of digital currencies or assets between parties under certain conditions. A smart contract not only defines the rules and penalties around an agreement in the same way that a traditional contract does, but it can also automatically enforce those obligations.

Page 5: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

5

What is a “Smart Contract"? Again…

The concept was first proposed by Nick Szabo as an automatism for transactions.

Page 6: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

6

What is a “Smart Contract"? Again…

It is a piece of code stored in the Blockchain and can be called any moment by a user having enough funds in the form of crytocurrency, such as Ethers.

--- Do Smart Contracts have anything to do with Blockchain and Cryptocurrencies?

https://etherscan.io/address/0xBe56093286038885733a66e554DD43a22a45889f

Page 7: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

7

Blockchains allows an application developer to create a distributed database that can be read by anyone, but can

only be written to by consensus.

A blockchain is a ledger of records arranged in data batches called blocks that use cryptographic validation to link themselves together. Put simply, each block references and identifies the previous

block by a hashing function, forming an unbroken chain, hence the name.

Page 8: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

8

What is a “Smart Contract"? Again…

To run the Smart Contract user have to pay a fee for gas consumption in Ethers (on Ethereum blockchain)

Page 9: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

9

What is a “Smart Contract"? Again…

Solidity is the most used programming language to develop Smart Contracts on Ethereum. LLL, Serpent, and Solidity all can be used to write contracts but Solidity is the flagship language at the moment.

Page 10: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

10

What is a “Smart Contract"? Again…

Every blockchain network node runs the code of the Smart Contract when called. The result (deterministic) is the same for all of them.

Page 11: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

11

What is a “Smart Contract"? Again…

Out of gas: when transaction cost for a Smart Contract call is higher than fees sent, process stops and data is rollback. If you do not have the Ether to cover all the gas requirements to complete running your code, the processing aborts and all intermediate state changes rollback to the pre-transaction snapshot.

Page 12: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

12

What is a “Smart Contract"? Again…

A Smart Contract is basically a set of if-then statements with only difference being that they directly control real assets (cryptocurrencies and tokens).

Page 13: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

13

Marketpay team

ricardforn

alejandrocabanillas

franciscoaréchaga

beatrizamilibia

ferranfigueredo

juanperez

Page 14: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

• Users meet at the marketplace• Buyer or seller can start the transaction,

introducing amount and address for shipping. • The counterpart is notified on his/her mobile

phone and accepts the escrow transaction.• Buyer can ask for instant credit.• Seller pays the PSP fee.• The escrow payment is released automatically

24h after successful delivery. • Pay-out to the seller’s account is executed right

away.

LemonPay. Designed to facilitate the economic transaction between peers

14

Page 15: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

15

the escrow payment provider that enables marketplace revenue models

Page 16: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

16

Secure escrow based transactions are core to the sharing economy: anonymity, compliance and agile

business rules for marketplaces\ Marketplaces, e-commerce websites and mobile apps must

guarantee secure transactions between buyers and sellers.

\ Marketpay covers all your operational cycle which includes:

o Pay-in and pay-out transactions and wallet statements.

o Agile escrow rules and payments upon delivery.

\ Most countries require a banking license to handle money on

behalf of third parties. Marketplaces cannot afford to break

legal and regulatory requirements and Marketpay is the perfect

partner that allows you to concentrate on your core business.

Page 17: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

17

Marketpay value proposition

Good or service is offered on marketplace

Search is made on listing app or website

Deal is closed and escrow is placed through Marketpay

Pay-out is executed to sellers bank account

Delivery is confirmed and payment is released

Page 18: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

18

Marketpay architecture

LemonPay

Mobile payments

Nubelo

Freelance Marketplace

Gasport

Petrol Payments

YoVoy

Events Organization

AuditLog

gEth Node

PayIn

Sabadell TPV

PayOut

OpenAPI

SQL BlockchainEthereum

Marketpay

Page 19: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

A "Smart Contract" is NOT…

19

A Smart Contract is not a DApp, but just a part of it. A DApp consists of a user interface (usually a mobile App or a Web page) and a backend based on a Blockchain Smart Contract. So it is not possible to use Smart Contracts by themselves to develop Apps nor Web sites, but you may well create a distributed and decentralized database to feed those dummy interfaces. This give us the advantage to perform crytocurrency operations in a smart fashion, not to mention recording and querying data.

Page 20: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

A "Smart Contract" is NOT…

20

A Smart Contract is not an Internet application: They cannot reach information outside the blockchain. Like decentralized code they can really only get pushes, they cannot pull. But because pushes and pulls can be inversed this is not a crippling limitation.

- Ethereum by Henning Diedrich

Page 21: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

A "Smart Contract" is NOT…

21

A Smart Contract is not "smart" nor "contract". When Nick Szabo created the concept of "Smart Contracts" they really were "smart", being capable of autorun and accomplish the job with no human intervention (trust middle-man role). Nevertheless, current smart contracts have no legal contractual effect. And they are not so smart as expected due to just being a set of if-else sentences with the capability to transact cryptocurrency and store/query records.

Smart contracts will use code to reshape law.https://iohk.io/blog/smart-contracts-will-use-code-to-reshape-law/

Blockchain consortium R3 contracts global law firm Norton Rose Fulbright to determine whether smart contracts have contractual enforceability.https://www.finextra.com/newsarticle/29798/norton-rose-fulbright-addresses-the-legal-implications-of-smart-contracts

Page 22: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

22

Blockchain is not going to emerge in industry as a single platform, as was once imagined, but as a series of different

blockchain platforms designed for different purposes.

https://goo.gl/5133lG Map of decentralized transaction ledgers

BTC/XBT ETH XRP Hyperledger 

# of nodes 6,000 7,000 200 200

access Open Open Permissioned

Permissioned

blockTime 10m 14s 4s ~1ms

smartContracts Script Solidity Codius Go

Page 23: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

23

Marketpay auditLog

\ Blockchain will make all kinds of transactions transparent, more reliable, and easier to audit without centralized processing.

Page 24: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

24

LemonPay: escrows, while they can be conducted through a central agent, are increasingly being

conducted through a smart contract on the Ethereum blockchain controlled by several independent agents.

BuyerSeller

3rd party logistics

Smart Contract is just a phrase used

to describe computer code that

can facilitate the exchange of money, content, property, shares, or anything

of value.

Page 25: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

MarketPay escrow Smart Contract

25

// Datastruct escrow {

address buyer;address seller;address thirdParty;address recipient;uint amount;uint revokedByBuyer;uint revokedBySeller;uint revokedByThirdParty;uint releasedByBuyer;uint releasedBySeller;uint releasedByThirdParty;uint status; // 0 => non-existent 1 => started, 2 => revoked, 3 => paid

}

mapping (uint => escrow) escrows;

Page 26: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

MarketPay escrow Smart Contract

26

function release(uint escrowId) returns (uint amount) {escrow e = escrows[escrowId];if (e.status != 1) { return 0; } // startedif (msg.sender == e.buyer) {

e.releasedByBuyer = 1;} else if (msg.sender == e.thirdParty) {

e.releasedByThirdParty = 1;} else if (msg.sender == e.seller) {

e.releasedBySeller = 1;} else { return 0; }

if (e.releasedByBuyer + e.releasedByThirdParty + e.releasedBySeller >= 2) {bool dummy = e.seller.send(e.amount);e.status = 3; // paidescrowRelease(e.seller, e.amount); // Logreturn e.amount;

} else { ; } // To complete the process two parties must invoke the release.return 0;

}

Page 27: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

MarketPay escrow Smart Contract

27

Calling the Smart Contract

Page 28: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

28

To avoid record tampering and identity spoofing:

Today, we Google for everything, mostly information or products. Tomorrow, we will perform the equivalent of "googling" to verify records, identities, authenticity, rights, work done, titles, contracts, and other valuable asset-related processes. There will be digital ownership certificates for everything. Just like we cannot double spend digital money anymore (thanks to Satoshi Nakamoto’s invention), we will not be able to double copy or forge official certificates once they are certified on a blockchain. That was a missing piece of the information revolution, which the blockchain fixes.

https://techcrunch.com/2016/05/11/the-blockchain-is-the-new-google/

Page 29: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

29

To cut costs:

• Blockchain technology could help the world’s largest investment banks cut their infrastructure costs by between $8 to $12 billion a year by 2025, according to a report by Accenture. As it creates a shared "golden record" of data that is virtually tamper-proof, it obviates the need for reconciliation and could prove a helpful resource for auditing.

- http://www.reuters.com/article/us-banks-blockchain-accenture-idUSKBN1511OU

• Finance-reporting costs could shrink by 70pc thanks to blockchain’s ability to optimize data and verification. Compliance costs could plummet by up to 50pc, thanks to "auditability". Other savings in support software for customer engagement procedures, as well as management procedures and office controls, could see the total saved at eight of the 10 largest investment banks top out at $12bn.

- https://www.siliconrepublic.com/enterprise/blockchain-accenture-investment-banks

• …to cut bank infrastructure costs attributable to cross-border payments… These costs referred here are for carrying out certain functions at the desired destination points and at the desired authenticity, by trustworthy agents.

- https://www.finextra.com/blogposting/13580/is-blockchain-necessary

Page 30: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

30

To develop cryptocurrency/token processes :

LaborX will serve as a decentralized marketplace where people in real-world professions will be able to sell labor-hours to anyone. LH (Labor Hour) tokens act as a substitute for payments enabling users to be rewarded for their work without cryptocurrency’s signature volatility risk. LH tokens can be bought and sold by companies to secure professional services, as well as by crypto traders who want to hedge their earnings in a stable, inflation-proof token.

- https://cointelegraph.com/news/how-ethereum-based-uber-of-time-chronobank-could-boost-cryptocurrency-adoption

Page 31: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

31

To raise finance fast through ICOs :

• Golem: You can rent the unused cycles of your CPU or GPU to other people so they can use it to do work. They will pay you GNT in exchange. Alternately, if you need to do computation and don't have a CPU or GPU that's appropriate, you can rent those from others, and pat them in GNT.

Total created: 1,000,000,000 GNTFunds raised: 820,000 ETH / 100% of cap

- https://golem.network/crowdfunding.html- https://etherscan.io/address/0xa74476443119a942de498590fe1f2454d7d4ac0d- https://coinmarketcap.com/assets/golem-network-tokens/

• MillionEther: A total of 1 million pixels are available for purchase. Advertisers can buy as much or as little ad space as they need, with the price per pixel starting at 0.01 ETH. Early birds may want to take advantage of this offer as soon as possible, as prices will go up as more pixels are sold.

- https://themerkle.com/millionether-smart-contract-can-change-the-world-of-advertising-for-good/

Page 32: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

32

Be careful with blockchain ICOs!:

Companies behind these ICOs are promising the moon and the stars, putting out polished websites, white papers, advisory boards, Slack channels, GitHubs, peppering with some legalese language, and topping it with the full dressing support enchilada they can think of; in order to appear as legitimate, as hard-working, as smart and as credible as possible.

The 3 typical characteristics, team, product and market seem to have taken a secondary position to the 3 new magical words: tokens, blockchain and decentralization. The token is not the business model. The value proposition or utility that is enabled by the token is the business model, and that linkage needs to be there early on. If the direction is not right, the chosen path will not lead to a good place. A smart company would not release more funding to itself until milestones are reached…

- http://startupmanagement.org/2017/01/23/watch-out-the-icos-are-coming/

Page 33: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

33

To decentralize the new sharing economy:

Don Tapscott, author of "Blockchain Revolution" says that the technology underlying Bitcoins could be used to disrupt the likes of Uber and Airbnb.

http://dontapscott.com/2016/01/could-blockchain-technology-disrupt-uber-airbnb/

Page 34: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

What Smart Contracts are useful for?

34

Unfortunately, it lost around $50m after someone hacked one of the contracts. The Ethereum Foundation then had to create a "hard fork" of its own blockchain to try and get the money back, but some people didn’t follow along, resulting in a new Ethereum blockchain and a Coca Cola-style Ethereum Classic. Governance-wise, it was complete carnage.

https://nakedsecurity.sophos.com/2017/01/24/when-is-a-blockchain-not-a-blockchain/

Not so fast, buddy!

The DAO, the ill-fated organization created on the Ethereum blockchain last year, it was hailed as a new development in autonomous, self-governing corporations. Instead of relying on central parties such as lawyers, accountants or a board for its governance structure, it used smart contracts, which were designed to handle things like voting and the unlocking of funds for contractors.

Page 35: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

How to improve business processes using Smart Contracts?

35

Trustless consensus: By removing middleman (disintermediation) we cut costs and simplify business processes.

Immutability: Prior to blockchain, immutability existed in closed systems, through the benevolence of a custodian. Bye bye to backups and data lost.

Security: No more worries about someone hacking the system. It is not possible anymore. Just focus on keeping secret your private keys and don't lose them.

Page 36: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

How to improve business processes using Smart Contracts?

36

Maybe there is not much difference for the end user between paying using VISA or Bitcoins, or between triggering a process by calling an API or a Smart Contract. But who knows if current systems (VISA, APIs) become deprecated and replaced by decentralized systems (cryptocurrencies and smart contracts) in a medium-short term, forcing us to update our business processes to avoid losing customers and partners.

Why Facebook instead of Orkut?Why Microsoft instead of Linux? (Desktop)

Critical mass: In social dynamics, critical mass is a sufficient number of adopters of an innovation in a social system so that the rate of adoption becomes self-sustaining and creates further growth.

Network effect: In economics and business, a network effect (also called network externality or demand-side economies of scale) is the effect that one user of a good or service has on the value of that product to other people. When a network effect is present, the value of a product or service is dependent on the number of others using it

Page 37: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

UnwiredApp Smart Contract

37

http://www.hackathon.io/unwiredapp1

A Smart Contract records messages related to a given user (wallet). Messages can only be read by the recipient (Blockchain ensures that only the recipient wallet has access to this information). Through a mobile/web interface a user with an Ethereum wallet will be able to read and write messages onto the Smart Contract, achieving this way a full DApp.

This same idea can be extended to guaranteed delivery messaging systems, in such a way to make it possible to audit whether a given message has been really sent and read by its recipient or not. Maybe Smart Cities are going to need a mechanism to make secure in a decentralized fashion the transfer of messages among officials or even citizens.

Pitch Video at https://www.youtube.com/watch?v=TH9Qha2Figw

Page 38: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

UnwiredApp Smart Contract

38

contract marketpayUnwiredApp is mortal { uint256 public countMessage; struct mess { uint256 idMessage; uint256 idPrevious; uint256 timestamp; address from; string message; } /* structure messages[to][idMessage] */ mapping (address =>

mapping (uint256 => mess) ) public messages;

Page 39: Event Itnig - Smart Contracts by MarketPay, Juan Ignacio Pérez Sacristán

Thanks!

Francisco Aréchaga

[email protected]+34 630 95 94 85

Juan Ignacio Pérez

[email protected]

+34 634 14 65 08

Ricardo Forn Palacin

[email protected]+34 609 85 83 44