Smart Contracts. Pierwsze starcie
-
Upload
the-software-house -
Category
Technology
-
view
11 -
download
1
Transcript of Smart Contracts. Pierwsze starcie
![Page 1: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/1.jpg)
SMART CONTRACTS THE FIRST ENCOUNTER
![Page 2: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/2.jpg)
SMART CONTRACTS - THE FIRST ENCOUNTER
AGENDA
▸ SMART CONTRACT - WHAT IS IT?
▸ SOLIDITY
▸ DEV ENVIRONMENT
▸ SIMPLE SMART CONTRACT
▸ TESTING
▸ PROBLEMS
▸ QUESTIONS
![Page 3: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/3.jpg)
ADAM POLAK PHP DEVELOPER
JS DEVELOPER
E2E DEVELOPER
POLAK.ADAM1
![Page 4: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/4.jpg)
LOOKING FOR AWESOME NODE.JS DEVS
![Page 5: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/5.jpg)
SMART CONTRACT
![Page 6: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/6.jpg)
SMART CONTRACT - WHAT IS IT?
IT’S A CONTRACTBUT IN BLOCKCHAIN
![Page 7: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/7.jpg)
SMART CONTRACT - WHAT IS IT?
▸ NOT ONLY ABOUT TRANSFERS
▸ WRITTEN IN SOLIDITY
▸ CONTAINS BUSINESS LOGIC
▸ TRANSACTION BASED
ETHEREUM SMART-CONTRACTS
![Page 8: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/8.jpg)
SMART CONTRACT - WHAT IS IT?
ETH SMART-CONTRACTaddResource(price, url)
accessUrl hasAccess
getAccess(price)
![Page 9: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/9.jpg)
SOLIDITY
![Page 10: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/10.jpg)
SOLIDITY
SMART-CONTRACTS IMPLEMENTING
LANGUAGE
![Page 11: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/11.jpg)
SOLIDITY
pragma solidity ^0.4.4;
contract HelloUszanowanko { string private message;
function HelloUszanowanko() public { message = 'Hello TSH'; }
function getMessage() constant public returns(string) { return message; }
function setMessage(string newMessage) public { message = newMessage; } }
![Page 12: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/12.jpg)
SOLIDITY
COMMANDS COST GAS
![Page 13: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/13.jpg)
SOLIDITY
QUERIES ARE FREE
![Page 14: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/14.jpg)
DEV ENVIRONMENT
![Page 15: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/15.jpg)
DEV ENVIRONMENT
▸ SMART-CONTRACT COMPILATION
▸ DEPLOYMENT
▸ CONSOLE
▸ EASIER TESTING
ETHEREUM DEVELOPMENT FRAMEWORK
![Page 16: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/16.jpg)
LOCAL BLOCKCHAIN
![Page 17: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/17.jpg)
LOCAL BLOCKCHAIN
![Page 18: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/18.jpg)
TRUFFLE-CLI
![Page 19: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/19.jpg)
DEV ENVIRONMENT
![Page 20: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/20.jpg)
FIRST CONTRACT
![Page 21: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/21.jpg)
FIRST CONTRACT
truffle init
truffle create contract HelloUszanowanko
pragma solidity ^0.4.4;
contract HelloUszanowanko { function HelloUszanowanko() public { // constructor } }
npm i -g truffle
![Page 22: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/22.jpg)
FIRST CONTRACT
pragma solidity ^0.4.4;
contract HelloUszanowanko { string private message;
function HelloUszanowanko() public { message = 'Hello TSH'; }
function getMessage() constant public returns(string) { return message; }
function setMessage(string newMessage) public { message = newMessage; } }
![Page 23: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/23.jpg)
MIGRATION
![Page 24: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/24.jpg)
FIRST CONTRACT
truffle create migration HelloUszanowanko
module.exports = function(deployer) { // Use deployer to state migration tasks. };
const HelloUszanowanko = artifacts.require('HelloUszanowanko');
module.exports = function(deployer) { deployer.deploy(HelloUszanowanko); };
truffle migrate
![Page 25: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/25.jpg)
FIRST CONTRACT
OOPS! FAIL!
![Page 26: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/26.jpg)
NETWORK CONFIG
![Page 27: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/27.jpg)
FIRST CONTRACT
module.exports = { networks: { development: { host: "127.0.0.1", port: 7545, network_id: "5777" } } };
![Page 28: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/28.jpg)
FIRST CONTRACT
![Page 29: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/29.jpg)
FIRST CONTRACT
truffle console
![Page 30: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/30.jpg)
FIRST CONTRACT
![Page 31: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/31.jpg)
TESTING
![Page 32: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/32.jpg)
TESTING
truffle create test HelloUszanowanko
contract('HelloUszanowanko', function(accounts) { it("should assert true", function(done) { var hello_uszanowanko = HelloUszanowanko.deployed(); assert.isTrue(true); done(); }); });
truffle test
![Page 33: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/33.jpg)
TESTING
OOPS! FAIL! AGAIN!
![Page 34: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/34.jpg)
TESTING
const HelloUszanowanko = artifacts.require(‘HelloUszanowanko’);
contract(‘HelloUszanowanko', function(accounts) { it("should assert true", function(done) { var hello_uszanowanko = HelloUszanowanko.deployed(); assert.isTrue(true); done(); }); });
truffle test
![Page 35: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/35.jpg)
TESTING
![Page 36: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/36.jpg)
TESTING
const HelloUszanowanko = artifacts.require('HelloUszanowanko');
contract('HelloUszanowanko', function(accounts) { it('has default message', async function() { const contract = await HelloUszanowanko.deployed(); const message = await contract.getMessage(); assert.equal(message, 'Hello TSH', 'Hello TSH is message'); });
it('changes message', async function() { const contract = await HelloUszanowanko.deployed(); await contract.setMessage('Hello Uszanowanko'); const message = await contract.getMessage(); assert.equal(message, 'Hello Uszanowanko', 'Hello Uszanowanko is message'); }); });
truffle test
![Page 37: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/37.jpg)
TESTING
![Page 38: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/38.jpg)
DECENTRALIZED APPS
SOON
![Page 39: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/39.jpg)
PROBLEMS
![Page 40: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/40.jpg)
PROBLEMS
▸ IMMATURE TOOLS
▸ STEEP LEARNING CURVE
▸ DECENTRALIZED APPS ARE SLOW
▸ EASY TO LOSE MONEY
![Page 41: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/41.jpg)
QUESTIONS ?
SMART CONTRACTS - THE FIRST ENCOUNTER
![Page 42: Smart Contracts. Pierwsze starcie](https://reader034.fdocuments.in/reader034/viewer/2022051521/5aac577a7f8b9a435e8b4767/html5/thumbnails/42.jpg)
THANK YOU