text: (self.webpackChunkopentezos=self.webpackChunkopentezos||[]).push([[9133],{3905:function(t,e,a){"use strict";a.d(e,{Zo:function(){return c},kt:function(){return f}});var n=a(7294);function r(t,e,a){return e in t?Object.defineProperty(t,e,{value:a,enumerable:!0,configurable:!0,writable:!0}):t[e]=a,t}function o(t,e){var a=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),a.push.apply(a,n)}return a}function i(t){for(var e=1;e<arguments.length;e++){var a=null!=arguments[e]?arguments[e]:{};e%2?o(Object(a),!0).forEach((function(e){r(t,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(a)):o(Object(a)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(a,e))}))}return t}function l(t,e){if(null==t)return{};var a,n,r=function(t,e){if(null==t)return{};var a,n,r={},o=Object.keys(t);for(n=0;n<o.length;n++)a=o[n],e.indexOf(a)>=0||(r[a]=t[a]);return r}(t,e);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(t);for(n=0;n<o.length;n++)a=o[n],e.indexOf(a)>=0||Object.prototype.propertyIsEnumerable.call(t,a)&&(r[a]=t[a])}return r}var s=n.createContext({}),p=function(t){var e=n.useContext(s),a=e;return t&&(a="function"==typeof t?t(e):i(i({},e),t)),a},c=function(t){var e=p(t.components);return n.createElement(s.Provider,{value:e},t.children)},u={inlineCode:"code",wrapper:function(t){var e=t.children;return n.createElement(n.Fragment,{},e)}},m=n.forwardRef((function(t,e){var a=t.components,r=t.mdxType,o=t.originalType,s=t.parentName,c=l(t,["components","mdxType","originalType","parentName"]),m=p(a),f=r,g=m["".concat(s,".").concat(f)]||m[f]||u[f]||o;return a?n.createElement(g,i(i({ref:e},c),{},{components:a})):n.createElement(g,i({ref:e},c))}));function f(t,e){var a=arguments,r=e&&e.mdxType;if("string"==typeof t||r){var o=a.length,i=new Array(o);i[0]=m;var l={};for(var s in e)hasOwnProperty.call(e,s)&&(l[s]=e[s]);l.originalType=t,l.mdxType="string"==typeof t?t:r,i[1]=l;for(var p=2;p<o;p++)i[p]=a[p];return n.createElement.apply(null,i)}return n.createElement.apply(null,a)}m.displayName="MDXCreateElement"},2070:function(t,e,a){"use strict";a.r(e),a.d(e,{frontMatter:function(){return i},metadata:function(){return l},toc:function(){return s},default:function(){return c}});var n=a(2122),r=a(9756),o=(a(7294),a(3905)),i={id:"take-away",title:"Take Away",authors:"Maxime Sallerin, Benjamin Pilia and Frank Hillard"},l={unversionedId:"ligo/take-away",id:"ligo/take-away",isDocsHomePage:!1,title:"Take Away",description:"- LIGO is a programming language for writing Tezos smart contracts.",source:"@site/docs/ligo/take-away.md",sourceDirName:"ligo",slug:"/ligo/take-away",permalink:"/ligo/take-away",editUrl:"https://github.com/octo-technology/OpenTezos/tree/main/docs/ligo/take-away.md",version:"current",lastUpdatedBy:"frankhillard",lastUpdatedAt:1623846789,formattedLastUpdatedAt:"6/16/2021",frontMatter:{id:"take-away",title:"Take Away",authors:"Maxime Sallerin, Benjamin Pilia and Frank Hillard"},sidebar:"docs",previous:{title:"Exam",permalink:"/ligo/exam"},next:{title:"Introduction",permalink:"/michelson"}},s=[{value:"To go further",id:"to-go-further",children:[]}],p={toc:s};function c(t){var e=t.components,i=(0,r.Z)(t,["components"]);return(0,o.kt)("wrapper",(0,n.Z)({},p,i,{components:e,mdxType:"MDXLayout"}),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"LIGO is a programming language for writing ",(0,o.kt)("strong",{parentName:"p"},"Tezos smart contracts"),".")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"LIGO ",(0,o.kt)("strong",{parentName:"p"},"compiles")," scripts written in a high-level language into ",(0,o.kt)("strong",{parentName:"p"},"Michelson script"),".")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"A smart contract is some code written in Michelson language (a low-level stack-based turing-complete language)."),(0,o.kt)("ul",{parentName:"li"},(0,o.kt)("li",{parentName:"ul"},"It defines all the ",(0,o.kt)("strong",{parentName:"li"},"entrypoints")," (invokable functions) of the smart contract."),(0,o.kt)("li",{parentName:"ul"},"It defines the prototype of each entry point (e.g. specifies the parameters types of the entry point)."),(0,o.kt)("li",{parentName:"ul"},"It defines the ",(0,o.kt)("strong",{parentName:"li"},"storage")," of the smart contract."))),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},(0,o.kt)("strong",{parentName:"p"},"The storage")," is an allocated memory space associated with a smart contract.\nThe description of the storage is done by strongly-typing the data structure.")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},(0,o.kt)("strong",{parentName:"p"},"Entrypoints")," of a smart contract describe how to mutate the storage.\nExecuting an entry point takes some of the parameters and a state of the storage\nand returns a new state of storage and some operations."))),(0,o.kt)("br",null),(0,o.kt)("p",null,(0,o.kt)("img",{src:a(9511).Z})),(0,o.kt)("small",{className:"figure"},"FIGURE 1 Smart Contract"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"LIGO functions are the basic building block of smart contracts.\nEach ",(0,o.kt)("strong",{parentName:"p"},"entrypoint")," of a contract is a ",(0,o.kt)("strong",{parentName:"p"},"function"),"\nand each smart contract must have at least one ",(0,o.kt)("strong",{parentName:"p"},"main function"),"\nthat dispatches the control flow to other functions.")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"The ",(0,o.kt)("strong",{parentName:"p"},"option type")," is used to express if there is a value, of some type, or none.\nThis is especially useful when calling a partial function, that is, a function that is not defined for specific inputs.")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"The keyword ",(0,o.kt)("inlineCode",{parentName:"p"},"failwith(<string_message>)")," throws an exception and stop the execution of the smart contract.")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"You can transfer tez to an account, or to the function of another smart contract, with ",(0,o.kt)("inlineCode",{parentName:"p"},"Tezos.transaction (<parameter>, <mutez>, <contract>)")))),(0,o.kt)("h2",{id:"to-go-further"},"To go further"),(0,o.kt)("ul",null,(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"You can go to the ",(0,o.kt)("a",{parentName:"p",href:"https://tezosacademy.io/pascal/chapter-about"},"Tezos Academy"),"\nwhich is a fun interactive tutorial on the LIGO language.")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"You can go to ",(0,o.kt)("a",{parentName:"p",href:"https://ligolang.org/"},"Ligolang"),"\nand try your hand at their ",(0,o.kt)("a",{parentName:"p",href:"https://ide.ligolang.org/"},"IDE online"),".")),(0,o.kt)("li",{parentName:"ul"},(0,o.kt)("p",{parentName:"li"},"You can check the smart contract\nexample ",(0,o.kt)("a",{parentName:"p",href:"https://github.com/frankhillard/ligo_tutorial_fundadvisor"},"FundAdvisor")," with explanatory videos."))))}c.isMDXComponent=!0},9511:function(t,e,a){"use strict";e.Z=a.p+"assets/images/smart_contract-60cf30eef28cd3097505d46992b28ced.svg"}}]);