You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
User request: invoke hash-committed functions provided in the unlocking script #479
Most users will just want the MAST-like constructions tracked in #348, where the compiler handles this for all of a contract's functions and only the spending path that is used goes on-chain.
This request is the lower-level, opt-in version aimed at power users and script wizards: the contract author chooses which function is committed by hash and only revealed when used, and keeps control over exactly how that is done.
What it would need
Compiler: a way to define and invoke runtime-supplied bytecode after a hash check, with a declared signature so type checking still works, and a function ID that doesn't collide with compiler-allocated ones.
SDK (optional, later): the bytecode can already be passed as a regular bytes unlocking argument. Follow-ups could add debugging support for the invoked code and accepting a compiled function artifact directly.
Maybe something like external function Name(int m, int n) in declarations and any contract that calls it just calls it by Name but must also have the Name in contract function arguments e.g.:
function Settle(bytes unused padding, function Name, int m, int n) {
require(NameHash == sha256(Name));
Name(m, n);
}
functions without the function Name argument can't call it, only those that are listed can (and SDK would auto-generate the input's data push, and it would auto-assign the correct definition index -- still tracked globally per contract's functions)
This also lets contract writer manually implement the exact MAST shape they want.
This doesn't prescribe function validation. Actually, we could go further and allow function body to be declared/defined anywhere as a variable, and calling it depends on it being in the scope.
external function Name(int m, int n);
external function NameMutated(int m, int n);
function Settle(bytes unused padding, function Name, int m, int n) {
require(NameHash == sha256(Name));
function NameMutated = Name + 0x0075;
Name(m, n);
NameMutated(m, n);
}
Declaration just tells the compiler the expected function signature, which the SDK can validate just before calling OP_DEFINE when stack item will be known.
Activity
A60AB5450353F40E commentedon Nov 29, 2026
Maybe something like
external function Name(int m, int n)in declarations and any contract that calls it just calls it by Name but must also have the Name in contract function arguments e.g.:functions without the
function Nameargument can't call it, only those that are listed can (and SDK would auto-generate the input's data push, and it would auto-assign the correct definition index -- still tracked globally per contract's functions)This also lets contract writer manually implement the exact MAST shape they want.
This doesn't prescribe function validation. Actually, we could go further and allow function body to be declared/defined anywhere as a variable, and calling it depends on it being in the scope.
Declaration just tells the compiler the expected function signature, which the SDK can validate just before calling OP_DEFINE when stack item will be known.