Ventimore Ltd
 
  HOME   DOCS    
 
The BSV Editor

The Hello Language

Hello is a very simple High-Level Language. It is intended to help development of complex scripts by replacing the forth-like syntax of bitcoin script with the more traditional syntax of Hello.

Hello is not type safe; generally data values on the stack are assume to be numbers.

Hello script must be compiled before it is run. The current version of the Hello compiler generates a output file consisting of annotated bitcoin script, which must be loaded into a Script window to be debugged. Future versions will allow users to execute Hello code a line at a time in a Hello window, and to set breakpoints in the Hello code. That facility is not yet available.

Syntax

There are four types of statements in Hello

  • Assignment
  • Conditionals (If-then-else)
  • For-loops
  • Native function calls

All statements exception conditionals must be followed by a ';'.

Assignments

These statements are of the form

     variable-name '=' numerical-expression

E.g. x = y + z; x = 0x6473F;

Variables are stored on the alt-stack and moved onto the standard stack when needed. Variables can be seen in the far left of a Hello windows.

The special variable tos represents the "top of stack", so the statement

	x = tos;

assigns the value of the top of the stack to x. The statement

	tos = x;

moves the value of x onto the top of the stack.

Conditionals (If-then-else)

These statements are of the form

	if (logical-expression)
	{
		statements
	}
	else
	{
		statements
	}	

E.g.if (x < y) { max = y; } else { max = x; }

The second 'else' clause is optional, as are statements within a block (inside the curly bracket). The curly brackets cannot be omitted even if there is only a single statement in the block.

For-Loops

These statements are of the form

	for variable-name in [ start-value .. end-value ]
	{
		[ statements ]	
	}
	
E.g.
	for i in [1.. 5]
	{
		x = x + i;
	}

Bitcoin script does not support loops. Loops are simulated by unrolling. I.e. the loop in the example repeats the statements in the block 5 times. Loops are therefore very expensive in bitcoin script.

Native function calls

These statements are of the form

	function-name ( args ) ;

These statements map directly to bitcoin-sv opcodes. For example:

	z = HASH160(x)

moves x to the top of the stack, invokes the OP_HASH160 opcode and moves the result from the top of the stack into the variable z.

The following functions are provided:

CheckSequenceVerfiy
CheckLocktimeVerfiy
RIPEMD160
SHA1
SHA256
HASH160
HASH256
CheckSig
CheckSigVerify
CheckMultiSig
CheckMultiSigVerify
Split
Cat

 

Copyright (c) Ventimore Ltd (UK), 2011, 2012, 2017, 2018, 2019.