<p>I'm confused as to the order regarding which script is run. For examples sake: say I want to spend 1 Bitcoin which was given to me by Alice in a single transaction of value 1 Bitcoin. I understand that the input to me is 1 Bitcoin and the output is 1 Bitcoin, but I am not sure about the which script runs first when i want to 'claim' this transaction</p>

<p>Edit: after reading the other question, I'm not sure if this is a chicken and egg kind of question. its a cycle where one runs after the other...</p>

CC BY-SA 4.0
2018-06-21T21:34:01.313Z
After reading the other question, I'm not sure if this is a chicken and egg kind of question. its kind of like a cycle where one runs after the other?
DCH
CC BY-SA 4.0
2018-06-22T07:56:32.463Z
I see. The funding transaction defines the spending  condition in the scriptPubKey, and the spending transaction provides the solution in the sigScript. When the tx' script logic is executed, the sigScript goes onto the stack, followed by the scriptPubKey. I recommend Andreas' book "Mastering Bitcoin", chapter 6 (Transactions, page 132ff). It is freely available online... and Ken Shirriff explains it very well (http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html).
pebwindkraft
CC BY-SA 4.0
2018-06-22T08:03:03.497Z
Thanks , I have always wanted that book but thought it will be better to cover the basics via the Coursera Princeton course .... however it was the course's lecture on scripts which got me confused as to the order of scripts
DCH
<transactions><bitcoin-core><block><script><input-script>
Bitcoin transaction scripts : does ScriptSig or ScriptPubkey run first?
DCH
# Bitcoin transaction scripts : does ScriptSig or ScriptPubkey run first?

(Asked by: username_0 on 2018-06-21)

I'm confused as to the order regarding which script is run. For examples sake: say I want to spend 1 Bitcoin which was given to me by Alice in a single transaction of value 1 Bitcoin. I understand that the input to me is 1 Bitcoin and the output is 1 Bitcoin, but I am not sure about the which script runs first when i want to 'claim' this transaction

Edit: after reading the other question, I'm not sure if this is a chicken and egg kind of question. its a cycle where one runs after the other...

**Tags:** transactions, bitcoin-core, block, script, input-script

> **Comments:**
> **username_0**: After reading the other question, I'm not sure if this is a chicken and egg kind of question. its kind of like a cycle where one runs after the other?  
> **username_1**: I see. The funding transaction defines the spending  condition in the scriptPubKey, and the spending transaction provides the solution in the sigScript. When the tx' script logic is executed, the sigScript goes onto the stack, followed by the scriptPubKey. I recommend Andreas' book "Mastering Bitcoin", chapter 6 (Transactions, page 132ff). It is freely available online... and Ken Shirriff explains it very well (http://www.righto.com/2014/02/bitcoins-hard-way-using-raw-bitcoin.html).  
> **username_0**: Thanks , I have always wanted that book but thought it will be better to cover the basics via the Coursera Princeton course .... however it was the course's lecture on scripts which got me confused as to the order of scripts  

---

## 0 answers

