BSV.Contract.OpCodeHelpers (BSV v2.1.0) View Source

Helper module for using Op Codes in BSV.Contract modules.

All known Op Codes are available as a function which simply pushes the Op Code word onto the Contract Script. Refer to BSV.VM for descriptions of each Op Code.

In addition, op_if/2 and op_if/3 provide a more syntactically pleasing way of handling the flow controw operations by passing handle_if and handle_else callback functions.

op_if(contract, &op_1add/1, &op_1sub/1)

# Equivalent to...

contract
|> op_if()
|> op_1add()
|> op_else()
|> op_1sub()
|> op_endif()

The same applies to op_notif/2 and op_notif/3.

Link to this section Summary

Functions

Pushes the OP_0 word onto the script.

Pushes the OP_0NOTEQUAL word onto the script.

Pushes the OP_1 word onto the script.

Pushes the OP_10 word onto the script.

Pushes the OP_11 word onto the script.

Pushes the OP_12 word onto the script.

Pushes the OP_13 word onto the script.

Pushes the OP_14 word onto the script.

Pushes the OP_15 word onto the script.

Pushes the OP_16 word onto the script.

Pushes the OP_1ADD word onto the script.

Pushes the OP_1NEGATE word onto the script.

Pushes the OP_1SUB word onto the script.

Pushes the OP_2 word onto the script.

Pushes the OP_2DIV word onto the script.

Pushes the OP_2DROP word onto the script.

Pushes the OP_2DUP word onto the script.

Pushes the OP_2MUL word onto the script.

Pushes the OP_2OVER word onto the script.

Pushes the OP_2ROT word onto the script.

Pushes the OP_2SWAP word onto the script.

Pushes the OP_3 word onto the script.

Pushes the OP_3DUP word onto the script.

Pushes the OP_4 word onto the script.

Pushes the OP_5 word onto the script.

Pushes the OP_6 word onto the script.

Pushes the OP_7 word onto the script.

Pushes the OP_8 word onto the script.

Pushes the OP_9 word onto the script.

Pushes the OP_ABS word onto the script.

Pushes the OP_ADD word onto the script.

Pushes the OP_AND word onto the script.

Pushes the OP_BIN2NUM word onto the script.

Pushes the OP_BOOLAND word onto the script.

Pushes the OP_BOOLOR word onto the script.

Pushes the OP_CAT word onto the script.

Pushes the OP_CHECKLOCKTIMEVERIFY word onto the script.

Pushes the OP_CHECKMULTISIG word onto the script.

Pushes the OP_CHECKMULTISIGVERIFY word onto the script.

Pushes the OP_CHECKSEQUENCEVERIFY word onto the script.

Pushes the OP_CHECKSIG word onto the script.

Pushes the OP_CHECKSIGVERIFY word onto the script.

Pushes the OP_CODESEPARATOR word onto the script.

Pushes the OP_DEPTH word onto the script.

Pushes the OP_DIV word onto the script.

Pushes the OP_DROP word onto the script.

Pushes the OP_DUP word onto the script.

Pushes the OP_ELSE word onto the script.

Pushes the OP_ENDIF word onto the script.

Pushes the OP_EQUAL word onto the script.

Pushes the OP_EQUALVERIFY word onto the script.

Pushes the OP_FALSE word onto the script.

Pushes the OP_FROMALTSTACK word onto the script.

Pushes the OP_GREATERTHAN word onto the script.

Pushes the OP_GREATERTHANOREQUAL word onto the script.

Pushes the OP_HASH160 word onto the script.

Pushes the OP_HASH256 word onto the script.

Pushes the OP_IF word onto the script.

Wraps the given handle_if function with OP_IF and OP_ENDIF script words.

Wraps the given handle_if and handle_else functions with OP_IF, OP_ELSE and OP_ENDIF script words.

Pushes the OP_IFDUP word onto the script.

Pushes the OP_INVALIDOPCODE word onto the script.

Pushes the OP_INVERT word onto the script.

Pushes the OP_LESSTHAN word onto the script.

Pushes the OP_LESSTHANOREQUAL word onto the script.

Pushes the OP_LSHIFT word onto the script.

Pushes the OP_MAX word onto the script.

Pushes the OP_MIN word onto the script.

Pushes the OP_MOD word onto the script.

Pushes the OP_MUL word onto the script.

Pushes the OP_NEGATE word onto the script.

Pushes the OP_NIP word onto the script.

Pushes the OP_NOP word onto the script.

Pushes the OP_NOP1 word onto the script.

Pushes the OP_NOP10 word onto the script.

Pushes the OP_NOP2 word onto the script.

Pushes the OP_NOP3 word onto the script.

Pushes the OP_NOP4 word onto the script.

Pushes the OP_NOP5 word onto the script.

Pushes the OP_NOP6 word onto the script.

Pushes the OP_NOP7 word onto the script.

Pushes the OP_NOP8 word onto the script.

Pushes the OP_NOP9 word onto the script.

Pushes the OP_NOT word onto the script.

Pushes the OP_NOTIF word onto the script.

Wraps the given handle_if function with OP_NOTIF and OP_ENDIF script words.

Wraps the given handle_if and handle_else functions with OP_NOTIF, OP_ELSE and OP_ENDIF script words.

Pushes the OP_NUM2BIN word onto the script.

Pushes the OP_NUMEQUAL word onto the script.

Pushes the OP_NUMEQUALVERIFY word onto the script.

Pushes the OP_NUMNOTEQUAL word onto the script.

Pushes the OP_OR word onto the script.

Pushes the OP_OVER word onto the script.

Pushes the OP_PICK word onto the script.

Pushes the OP_PUBKEY word onto the script.

Pushes the OP_PUBKEYHASH word onto the script.

Pushes the OP_PUBKEYS word onto the script.

Pushes the OP_PUSHDATA1 word onto the script.

Pushes the OP_PUSHDATA2 word onto the script.

Pushes the OP_PUSHDATA4 word onto the script.

Pushes the OP_RESERVED word onto the script.

Pushes the OP_RESERVED1 word onto the script.

Pushes the OP_RESERVED2 word onto the script.

Pushes the OP_RETURN word onto the script.

Pushes the OP_RIPEMD160 word onto the script.

Pushes the OP_ROLL word onto the script.

Pushes the OP_ROT word onto the script.

Pushes the OP_RSHIFT word onto the script.

Pushes the OP_SHA1 word onto the script.

Pushes the OP_SHA256 word onto the script.

Pushes the OP_SIZE word onto the script.

Pushes the OP_SMALLDATA word onto the script.

Pushes the OP_SMALLINTEGER word onto the script.

Pushes the OP_SPLIT word onto the script.

Pushes the OP_SUB word onto the script.

Pushes the OP_SWAP word onto the script.

Pushes the OP_TOALTSTACK word onto the script.

Pushes the OP_TRUE word onto the script.

Pushes the OP_TUCK word onto the script.

Pushes the OP_VER word onto the script.

Pushes the OP_VERIF word onto the script.

Pushes the OP_VERIFY word onto the script.

Pushes the OP_VERNOTIF word onto the script.

Pushes the OP_WITHIN word onto the script.

Pushes the OP_XOR word onto the script.

Link to this section Functions

Specs

Pushes the OP_0 word onto the script.

Specs

op_0notequal(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_0NOTEQUAL word onto the script.

Specs

Pushes the OP_1 word onto the script.

Specs

Pushes the OP_10 word onto the script.

Specs

Pushes the OP_11 word onto the script.

Specs

Pushes the OP_12 word onto the script.

Specs

Pushes the OP_13 word onto the script.

Specs

Pushes the OP_14 word onto the script.

Specs

Pushes the OP_15 word onto the script.

Specs

Pushes the OP_16 word onto the script.

Specs

op_1add(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_1ADD word onto the script.

Specs

op_1negate(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_1NEGATE word onto the script.

Specs

op_1sub(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_1SUB word onto the script.

Specs

Pushes the OP_2 word onto the script.

Specs

op_2div(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2DIV word onto the script.

Specs

op_2drop(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2DROP word onto the script.

Specs

op_2dup(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2DUP word onto the script.

Specs

op_2mul(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2MUL word onto the script.

Specs

op_2over(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2OVER word onto the script.

Specs

op_2rot(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2ROT word onto the script.

Specs

op_2swap(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_2SWAP word onto the script.

Specs

Pushes the OP_3 word onto the script.

Specs

op_3dup(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_3DUP word onto the script.

Specs

Pushes the OP_4 word onto the script.

Specs

Pushes the OP_5 word onto the script.

Specs

Pushes the OP_6 word onto the script.

Specs

Pushes the OP_7 word onto the script.

Specs

Pushes the OP_8 word onto the script.

Specs

Pushes the OP_9 word onto the script.

Specs

Pushes the OP_ABS word onto the script.

Specs

Pushes the OP_ADD word onto the script.

Specs

Pushes the OP_AND word onto the script.

Specs

op_bin2num(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_BIN2NUM word onto the script.

Specs

op_booland(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_BOOLAND word onto the script.

Specs

op_boolor(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_BOOLOR word onto the script.

Specs

Pushes the OP_CAT word onto the script.

Link to this function

op_checklocktimeverify(contract)

View Source

Specs

op_checklocktimeverify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CHECKLOCKTIMEVERIFY word onto the script.

Link to this function

op_checkmultisig(contract)

View Source

Specs

op_checkmultisig(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CHECKMULTISIG word onto the script.

Link to this function

op_checkmultisigverify(contract)

View Source

Specs

op_checkmultisigverify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CHECKMULTISIGVERIFY word onto the script.

Link to this function

op_checksequenceverify(contract)

View Source

Specs

op_checksequenceverify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CHECKSEQUENCEVERIFY word onto the script.

Specs

op_checksig(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CHECKSIG word onto the script.

Link to this function

op_checksigverify(contract)

View Source

Specs

op_checksigverify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CHECKSIGVERIFY word onto the script.

Link to this function

op_codeseparator(contract)

View Source

Specs

op_codeseparator(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_CODESEPARATOR word onto the script.

Specs

op_depth(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_DEPTH word onto the script.

Specs

Pushes the OP_DIV word onto the script.

Specs

op_drop(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_DROP word onto the script.

Specs

Pushes the OP_DUP word onto the script.

Specs

op_else(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_ELSE word onto the script.

Specs

op_endif(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_ENDIF word onto the script.

Specs

op_equal(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_EQUAL word onto the script.

Link to this function

op_equalverify(contract)

View Source

Specs

op_equalverify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_EQUALVERIFY word onto the script.

Specs

op_false(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_FALSE word onto the script.

Link to this function

op_fromaltstack(contract)

View Source

Specs

op_fromaltstack(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_FROMALTSTACK word onto the script.

Link to this function

op_greaterthan(contract)

View Source

Specs

op_greaterthan(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_GREATERTHAN word onto the script.

Link to this function

op_greaterthanorequal(contract)

View Source

Specs

op_greaterthanorequal(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_GREATERTHANOREQUAL word onto the script.

Specs

op_hash160(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_HASH160 word onto the script.

Specs

op_hash256(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_HASH256 word onto the script.

Specs

Pushes the OP_IF word onto the script.

Link to this function

op_if(contract, handle_if)

View Source

Specs

Wraps the given handle_if function with OP_IF and OP_ENDIF script words.

Link to this function

op_if(contract, handle_if, handle_else)

View Source

Specs

Wraps the given handle_if and handle_else functions with OP_IF, OP_ELSE and OP_ENDIF script words.

Specs

op_ifdup(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_IFDUP word onto the script.

Link to this function

op_invalidopcode(contract)

View Source

Specs

op_invalidopcode(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_INVALIDOPCODE word onto the script.

Specs

op_invert(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_INVERT word onto the script.

Specs

op_lessthan(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_LESSTHAN word onto the script.

Link to this function

op_lessthanorequal(contract)

View Source

Specs

op_lessthanorequal(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_LESSTHANOREQUAL word onto the script.

Specs

op_lshift(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_LSHIFT word onto the script.

Specs

Pushes the OP_MAX word onto the script.

Specs

Pushes the OP_MIN word onto the script.

Specs

Pushes the OP_MOD word onto the script.

Specs

Pushes the OP_MUL word onto the script.

Specs

op_negate(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NEGATE word onto the script.

Specs

Pushes the OP_NIP word onto the script.

Specs

Pushes the OP_NOP word onto the script.

Specs

op_nop1(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP1 word onto the script.

Specs

op_nop10(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP10 word onto the script.

Specs

op_nop2(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP2 word onto the script.

Specs

op_nop3(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP3 word onto the script.

Specs

op_nop4(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP4 word onto the script.

Specs

op_nop5(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP5 word onto the script.

Specs

op_nop6(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP6 word onto the script.

Specs

op_nop7(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP7 word onto the script.

Specs

op_nop8(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP8 word onto the script.

Specs

op_nop9(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOP9 word onto the script.

Specs

Pushes the OP_NOT word onto the script.

Specs

op_notif(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NOTIF word onto the script.

Link to this function

op_notif(contract, handle_if)

View Source

Specs

Wraps the given handle_if function with OP_NOTIF and OP_ENDIF script words.

Link to this function

op_notif(contract, handle_if, handle_else)

View Source

Specs

Wraps the given handle_if and handle_else functions with OP_NOTIF, OP_ELSE and OP_ENDIF script words.

Specs

op_num2bin(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NUM2BIN word onto the script.

Specs

op_numequal(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NUMEQUAL word onto the script.

Link to this function

op_numequalverify(contract)

View Source

Specs

op_numequalverify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NUMEQUALVERIFY word onto the script.

Link to this function

op_numnotequal(contract)

View Source

Specs

op_numnotequal(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_NUMNOTEQUAL word onto the script.

Specs

Pushes the OP_OR word onto the script.

Specs

op_over(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_OVER word onto the script.

Specs

op_pick(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PICK word onto the script.

Specs

op_pubkey(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PUBKEY word onto the script.

Specs

op_pubkeyhash(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PUBKEYHASH word onto the script.

Specs

op_pubkeys(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PUBKEYS word onto the script.

Specs

op_pushdata1(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PUSHDATA1 word onto the script.

Specs

op_pushdata2(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PUSHDATA2 word onto the script.

Specs

op_pushdata4(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_PUSHDATA4 word onto the script.

Specs

op_reserved(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_RESERVED word onto the script.

Specs

op_reserved1(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_RESERVED1 word onto the script.

Specs

op_reserved2(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_RESERVED2 word onto the script.

Specs

op_return(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_RETURN word onto the script.

Specs

op_ripemd160(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_RIPEMD160 word onto the script.

Specs

op_roll(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_ROLL word onto the script.

Specs

Pushes the OP_ROT word onto the script.

Specs

op_rshift(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_RSHIFT word onto the script.

Specs

op_sha1(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SHA1 word onto the script.

Specs

op_sha256(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SHA256 word onto the script.

Specs

op_size(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SIZE word onto the script.

Specs

op_smalldata(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SMALLDATA word onto the script.

Link to this function

op_smallinteger(contract)

View Source

Specs

op_smallinteger(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SMALLINTEGER word onto the script.

Specs

op_split(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SPLIT word onto the script.

Specs

Pushes the OP_SUB word onto the script.

Specs

op_swap(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_SWAP word onto the script.

Specs

op_toaltstack(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_TOALTSTACK word onto the script.

Specs

op_true(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_TRUE word onto the script.

Specs

op_tuck(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_TUCK word onto the script.

Specs

Pushes the OP_VER word onto the script.

Specs

op_verif(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_VERIF word onto the script.

Specs

op_verify(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_VERIFY word onto the script.

Specs

op_vernotif(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_VERNOTIF word onto the script.

Specs

op_within(BSV.Contract.t()) :: BSV.Contract.t()

Pushes the OP_WITHIN word onto the script.

Specs

Pushes the OP_XOR word onto the script.