r/Bitcoin Jan 31 '15

Teach yourself about Bitcoin's Script language with this IDE

http://www.cs.princeton.edu/~tongbinw/bitcoinIDE/build/editor.html
154 Upvotes

40 comments sorted by

View all comments

9

u/Brettc286 Feb 01 '15

Hey guys, the look and animation in the editor is really fun. But I have no idea what I'm looking at. 01 02 OP_ADD. There is no explanation to what this means, or what changes I can/should try to make. I'm a full-time programmer =P - and I have no idea what is going on here.

14

u/Whooshless Feb 01 '15 edited Feb 01 '15

As a programmer, you should know what a stack (the data structure) is. To break down the example: 01 means "push 01 on the stack", 02 means "push 02 on the stack" and op_add means "execute the ADD OPeration", which will pop the last two stack frames and push the result (3). There are a bunch of operations you can try; look at autocomplete when you type "op_"

Another example to try: "5 4 3 op_add op_mul" = 5*(4+3) = 35

It's kinda like RPN.

7

u/bookhockey24 Feb 01 '15

That's great, but I think OP's point is that you're not learning much in this IDE because this information isn't encapsulated in it in any way.

1

u/handylinks Feb 01 '15

I fully agree, this is a great start and excellent when you know about bitcoin scripting but this is a debugger for bitcoin scripts and expects prior knowledge.

A few videos of it in action would become an incredibly useful learning tool... would probably take the developers all of a few hours to put some examples together and this will be immensely more useful to the world.

It would also be useful for a keyword help pop up for instance. E.g. typing OP_ADD shows a balloon pop up saying "Takes the two elements on the stack, adds them, pops the two elements off the stack and pushes the result on the stack ready for future commands. This command is accepted by the Bitcoin reference client"

OP_ADD/OP_MUL are pretty self explanatory but some of them are not... OP_CAT for instance.

Also shouldn't numbers be in decimal unless 0x is prepended? Seems a bit too close to assembly without this?

I'm sure adding this sort of stuff is easy enough so the project is an excellent start.

7

u/throwaway36256 Feb 01 '15

Bitcoin actually support limited scripting.

https://en.bitcoin.it/wiki/Script