{"id":10920,"date":"2023-02-08T19:21:20","date_gmt":"2023-02-08T19:21:20","guid":{"rendered":"https:\/\/www.bitnovo.com\/blog\/?p=10920"},"modified":"2022-05-17T20:19:57","modified_gmt":"2022-05-17T20:19:57","slug":"what-is-bitcoin-script","status":"publish","type":"post","link":"https:\/\/www.bitnovo.com\/blog\/en\/what-is-bitcoin-script","title":{"rendered":"What is Bitcoin Script?"},"content":{"rendered":"<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_82_2 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Table of Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Alternar tabla de contenidos\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #ffffff;color:#ffffff\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #ffffff;color:#ffffff\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-bitcoin-script\/#why_was_bitcoin_script_created\" >Why was Bitcoin Script created?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-bitcoin-script\/#how_does_bitcoin_script_work\" >How does Bitcoin Script work?<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-bitcoin-script\/#execution_of_a_script\" >Execution of a Script<\/a><ul class='ez-toc-list-level-3' ><li class='ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-bitcoin-script\/#smart_contract_language\" >Smart contract language<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-3'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-bitcoin-script\/#bitcoin_script_features\" >Bitcoin Script Features<\/a><\/li><\/ul><\/li><\/ul><\/nav><\/div>\n<span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Tiempo de lectura:<\/span> <span class=\"rt-time\"> 4<\/span> <span class=\"rt-label rt-postfix\">minutos<\/span><\/span><p>When we talk about Bitcoin Script we refer to a Bitcoin\u00a0<strong>programming language<\/strong>. It handles\u00a0<strong>transaction<\/strong>\u00a0processing. From transactions as simple as micro payments to multi-user accounts. This language is read from left to right and bases its operation on a set of linear\u00a0<strong>structures<\/strong>\u00a0known as<strong>\u00a0stack<\/strong>. The instructions of this language are executed in consecutive order one after the other.<\/p>\n<p>It is important to note that this language\u00a0<strong>is not Turing Complete<\/strong>\u00a0so it cannot solve all types of problems. Its operation is limited to not allowing loops in the system. However, this\u00a0<strong>limitation<\/strong>\u00a0is not a disadvantage, since it is intentionally created. Thanks to this limitation, in case of any error in the system, it would not be repeated constantly.<\/p>\n<p>Otherwise, very complicated operations could be created in a\u00a0<strong>loop<\/strong>, slowing down the system and consuming<strong>\u00a0the total\u00a0<a href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-a-hash\/\">Hash rate<\/a><\/strong>. This programming language is highly important, since it allows the writing of programs and the computer to execute our commands.<strong>\u00a0OP_CODES<\/strong>\u00a0are used for this purpose. These are used for functions such as mathematics, loops, function calls, etc\u2026.<\/p>\n<p>In other words,\u00a0<strong>Bitcoin Script is a set of instructions that record every transaction made<\/strong>. These instructions establish how users can make use of the network and gain\u00a0<strong>access<\/strong>\u00a0to Bitcoins.<\/p>\n<div id=\"image_1223662187\" class=\"img has-hover x md-x lg-x y md-y lg-y\">\n<div class=\"img-inner dark\"><img fetchpriority=\"high\" decoding=\"async\" class=\"attachment-large size-large lazyloaded\" src=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script.jpg\" sizes=\"(max-width: 768px) 100vw, 768px\" srcset=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script.jpg 768w, https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script-300x205.jpg 300w\" alt=\"Qu\u00e9-es-Bitcoin-Script1\" width=\"768\" height=\"526\" data-srcset=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script.jpg 768w, https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script-300x205.jpg 300w\" data-src=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script.jpg\" data-sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/div>\n<\/div>\n<div class=\"is-divider divider clearfix\"><\/div>\n<div class=\"is-divider divider clearfix\"><\/div>\n<h2><span class=\"ez-toc-section\" id=\"why_was_bitcoin_script_created\"><\/span><strong>Why was Bitcoin Script created?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>The goal of Bitcoin Script is to\u00a0<strong>offer<\/strong>\u00a0a set of flexible\u00a0<strong>parameters<\/strong>\u00a0that allow Bitcoin transactions in a\u00a0<strong>simple<\/strong>\u00a0way. For this very purpose\u00a0<a href=\"https:\/\/www.bitnovo.com\/blog\/en\/who-is-satoshi-nakamoto\/\">Satoshi Nakamoto<\/a>\u00a0disabled certain\u00a0<strong>functions<\/strong>\u00a0when he developed Bitcoin, including\u00a0<strong>multiplication.<\/strong>\u00a0For this reason it is a simple script in terms of programming.<\/p>\n<p>This language\u00a0<strong>decides<\/strong>\u00a0whether or not a transaction can be carried out on the network. In other words, it decides whether such a transaction is authorized to\u00a0<strong>transfer funds<\/strong>. The Bitcoin\u00a0<strong>Script<\/strong>\u00a0brings the programmable nature of Bitcoin. Thanks to the Bitcoin<strong>\u00a0Script<\/strong>\u00a0we can make a transaction that will only take place if certain\u00a0<strong>conditions<\/strong>\u00a0are met. Properties like this are only found in cryptocurrencies. This makes them different from the\u00a0<strong>current digital money<\/strong>\u00a0and especially from paper money.<\/p>\n<p>This program is an\u00a0<strong>evolution<\/strong>\u00a0that allows money to act<strong>\u00a0independently and decentralized<\/strong>\u00a0according to the programming<strong>\u00a0implemented<\/strong>\u00a0in it. But the Bitcoin Script not only allows<strong>\u00a0transactions<\/strong>, it also\u00a0<strong>avoids<\/strong>\u00a0the creation of errors in the system and\u00a0<strong>avoids<\/strong>\u00a0the use of\u00a0<strong>complex<\/strong>\u00a0operations. This script converts transactions into easy-to-calculate operations and, as we have already mentioned, it does not allow infinite loops that slow down the network.<\/p>\n<div class=\"is-divider divider clearfix\"><\/div>\n<div class=\"is-divider divider clearfix\"><\/div>\n<h2><span class=\"ez-toc-section\" id=\"how_does_bitcoin_script_work\"><\/span><strong>How does Bitcoin Script work?<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>Among the most widely used scripts on the network today is the\u00a0<strong>P2PKH script<\/strong>.\u00a0 Scripts are vital to carry out any type of Bitcoin operation. In this, each action is performed by a specific script that determines what should be done. In this operation nothing will happen that is not dictated by a\u00a0<strong>Bitcoin Script<\/strong>.<\/p>\n<p>A<strong>\u00a0standard script<\/strong>\u00a0would consist of a two-part structure, the\u00a0<strong>ScriptPubKey<\/strong>\u00a0and the\u00a0<strong>ScriptSig<\/strong>. This type of script is the most common way to perform a BTC transaction.<\/p>\n<div class=\"message-box relative\">\n<div class=\"container relative\">\n<div class=\"inner last-reset\">\n<div id=\"row-645622343\" class=\"row align-middle align-center\">\n<div class=\"col medium-9 small-12 large-9\">\n<div class=\"col-inner\">\n<p>The ScriptPubKey could be :<\/p>\n<p><strong>15higMjoCCNXSA95xZbJUdPvXNmkAduhCA<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"message-box relative\">\n<div class=\"container relative\">\n<div class=\"inner last-reset\">\n<div id=\"row-17568337\" class=\"row align-middle align-center\">\n<div class=\"col medium-9 small-12 large-9\">\n<div class=\"col-inner\">\n<p>And the ScriptSig would be a set of numbers and letters similar to the following :<\/p>\n<p><strong>760402203f004eeed0cef2715643e2f25a27a28f3c578e94c7f0<\/strong><\/p>\n<p><strong>f6a4df104e7d163f7f8f022100b8b248c1cfd8b55a0365107a9511d<\/strong><\/p>\n<p><strong>759b7544d979dd152a955c867epect0ef79702<\/strong><\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<p>At first glance we only see the difficulty of a mixture of numbers and letters impossible to understand, but it is really the layer behind which hides a totally\u00a0<strong>simple<\/strong>\u00a0system.<\/p>\n<p>In the\u00a0<strong>scriptPubKey<\/strong>\u00a0we see the\u00a0<strong>actions<\/strong>\u00a0to be performed in the transaction and in the\u00a0<strong>ScriptSig<\/strong>\u00a0we see the\u00a0<strong>public key<\/strong>\u00a0and\u00a0<strong>signature<\/strong>\u00a0that will help verify the authenticity of the transaction. This is how the Bitcoin Script ensures that the user sending the transaction has\u00a0<strong>access<\/strong>\u00a0to the funds and can move them.<\/p>\n<p>All this involves the\u00a0<strong>OP_CODES<\/strong>\u00a0mentioned above. These are operation codes that represent\u00a0<strong>a portion<\/strong>\u00a0of a language\u00a0<strong>instruction<\/strong>\u00a0that specifies what operation will be performed.<\/p>\n<p>In addition, OP_CODEs create\u00a0<strong>advanced structures<\/strong>\u00a0and schedule operations within the blockchain. Each OP_CODE has a\u00a0<strong>different task<\/strong>. Some carry out\u00a0<strong>input modification<\/strong>, others handle data\u00a0<strong>verification<\/strong>\u00a0and ensure that the data is correct and valid, and some duplicate items. Each OP_CODE performs an important role in the operation of the Bitcoin Script.<\/p>\n<div class=\"is-divider divider clearfix\"><\/div>\n<div class=\"is-divider divider clearfix\"><\/div>\n<h2><span class=\"ez-toc-section\" id=\"execution_of_a_script\"><\/span><strong>Execution of a Script<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n<p>To execute a script the first step is to\u00a0<strong>duplicate<\/strong>\u00a0the public key of the owner of the funds involved in the transaction. This key then undergoes a hashing process where the\u00a0<strong>SHA-256<\/strong>\u00a0hash is applied. The\u00a0<strong>RIPEMD-160<\/strong>\u00a0hash is applied to the resulting combination.<\/p>\n<p>Once this last hash has been applied, the result of the hashes is compared with the hash found in the public key of the\u00a0<strong>scriptPubKey<\/strong>\u00a0to verify that it is the same key and that it is verified as valid. Once it has been verified that the script matches, it proceeds to execute and passes to the\u00a0<strong>CHECKSIG<\/strong>\u00a0where the signature is verified through the public key.<\/p>\n<h3><span class=\"ez-toc-section\" id=\"smart_contract_language\"><\/span><strong>Smart contract language<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>It is very common for users to believe that Bitcoin is incapable of creating\u00a0<a href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-a-smart-contract\/\">smart contracts<\/a>. Bitcoin Script is Bitcoin\u2019s\u00a0<strong>smart contract<\/strong>\u00a0language so it can create smart contracts. It should be noted that Bitcoin\u2019s smart contract capabilities are\u00a0<strong>limited<\/strong>\u00a0compared to Ethereum, however, the Bitcoin network has this capability.<\/p>\n<p>We already know that Bitcoin Script does not share all the\u00a0<strong>capabilities of a full Turing machine<\/strong>\u00a0so it does not allow\u00a0<strong>loops<\/strong>\u00a0and thanks to this we can determine when a program will end and how it will end. In Bitcoin\u00a0<strong>Script<\/strong>\u00a0there is no possibility of creating scripts that run forever, just as it is\u00a0<strong>impossible<\/strong>\u00a0for the language to block programs or their executor.<\/p>\n<p>These\u00a0<strong>limitations<\/strong>\u00a0lag Bitcoin\u2019s smart contracts compared to\u00a0<a href=\"https:\/\/www.bitnovo.com\/blog\/en\/what-is-ethereum-eth-and-how-does-it-work\/\">Ethereum<\/a>, however, they ensure greater\u00a0<strong>security<\/strong>\u00a0in the network.<\/p>\n<div id=\"image_454934835\" class=\"img has-hover x md-x lg-x y md-y lg-y\">\n<div class=\"img-inner dark\"><img decoding=\"async\" class=\"attachment-large size-large lazyloaded\" src=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script1.jpg\" sizes=\"(max-width: 768px) 100vw, 768px\" srcset=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script1.jpg 768w, https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script1-300x205.jpg 300w\" alt=\"Qu\u00e9-es-Bitcoin-Script1\" width=\"768\" height=\"526\" data-srcset=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script1.jpg 768w, https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script1-300x205.jpg 300w\" data-src=\"https:\/\/www.bitnovo.com\/blog\/wp-content\/uploads\/2021\/06\/Que-es-Bitcoin-Script1.jpg\" data-sizes=\"(max-width: 768px) 100vw, 768px\" \/><\/div>\n<\/div>\n<h3><span class=\"ez-toc-section\" id=\"bitcoin_script_features\"><\/span><strong>Bitcoin Script Features<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h3>\n<p>The Bitcoin programming language has features that differentiate it from other languages. Below we will see some of them.<\/p>\n<ul>\n<li aria-level=\"1\"><b>Small language.\u00a0<\/b>This language is considered small, since it contains only 256 instructions and each instruction is expressed in one byte.<\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>It contains all the information.\u00a0<\/b>There is no state of the transaction before or after the script, since all the information is contained in it.<\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>Limited functionality.\u00a0<\/b>Bitcoin Script is limited so it brings a higher level of security to the system.<\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><strong>It is simple<\/strong>\u00a0as it requires minimal processing.<\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>Adaptability.<\/b>\u00a0because of its simplicity it can be run on a wide range of devices.<\/li>\n<\/ul>\n<ul>\n<li aria-level=\"1\"><b>Incomplete\u00a0<a href=\"https:\/\/www.bitnovo.com\/blog\/en\/alan-turing-the-father-of-computation-and-cryptography\/\">Turing<\/a>\u00a0language.<\/b>\u00a0Being incomplete, it does not allow loops. This ensures that the program stops repeating itself and with it the errors in the network.<\/li>\n<\/ul>\n","protected":false},"excerpt":{"rendered":"<p><span class=\"span-reading-time rt-reading-time\" style=\"display: block;\"><span class=\"rt-label rt-prefix\">Tiempo de lectura:<\/span> <span class=\"rt-time\"> 4<\/span> <span class=\"rt-label rt-postfix\">minutos<\/span><\/span>When we talk about Bitcoin Script we refer to a Bitcoin\u00a0programming language. It handles\u00a0transaction\u00a0processing. From transactions as simple as micro payments to multi-user accounts. This language is read from left to right and bases its operation on a set of linear\u00a0structures\u00a0known as\u00a0stack. The instructions of this language are executed in consecutive order one after the [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":6929,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[185],"tags":[],"class_list":["post-10920","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-blockchain-en"],"_links":{"self":[{"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/posts\/10920","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/comments?post=10920"}],"version-history":[{"count":0,"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/posts\/10920\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/media\/6929"}],"wp:attachment":[{"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/media?parent=10920"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/categories?post=10920"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.bitnovo.com\/blog\/wp-json\/wp\/v2\/tags?post=10920"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}