Pular para o conteúdo

hook_validate

Este conteúdo não está disponível em sua língua ainda.

(Introduced in 2026.10.13-release+4119.)

The hook_validate method runs the Hook guard checker and the WebAssembly VM validation against Hook code supplied by the caller, without installing it. It uses the rules of the current open ledger, so the result reflects which Hook APIs are currently enabled on the network.

  • The method is controlled by the [hook_validate_rpc] configuration section. It is disabled by default on networked nodes and enabled by default in standalone mode. When disabled, it returns notSupported.
  • When enabled, it is available to non-admin (user) clients. It is charged as a heavy-burden request.
{
"command": "hook_validate",
"code": "0061736D01000000..."
}
FieldJSON TypeRequired?Description
codeStringYesThe Hook’s WebAssembly binary as an even-length hex string, no larger than the maximum Hook size.

A valid Hook:

{
"result": {
"valid": true,
"instruction_count_cbak": "0",
"instruction_count_hook": "1091",
"log": [
"HookSet(50)[]: GuardCheck Total worse-case execution count: 1091"
],
"status": "success"
}
}

An invalid Hook:

{
"result": {
"valid": false,
"log": [
"HookSet(80)[]: Malformed transaction: Hook was not valid webassembly binary. Too small."
],
"status": "success"
}
}
FieldJSON TypeDescription
validBooleantrue if the code passes both the guard checker and VM validation.
instruction_count_hookString(Valid Hooks only) The worst-case instruction count of the hook function, computed by the guard checker.
instruction_count_cbakString(Valid Hooks only) The worst-case instruction count of the cbak function, computed by the guard checker.
logArrayThe guard checker’s messages, one string per line. Also present for valid Hooks (for example, the worst-case execution count).
vm_errorString(Invalid Hooks only) Present only if guard checking passed but the WebAssembly VM rejected the module.
  • Any of the universal error types.
  • notSupported: the method is disabled on this server.
  • invalidParams: code is missing, not a string, of odd length, too large, or not decodable as hex.