I am working on figuring out an efficient way to run an ELF binary after successful transaction. I also want to pass arguments along the execution.

Example: /bin/ping

OCW might be a solution, but because of the no_std environment required for WASM, it is not straightforward to:

  1. Execute the elf binary (eg. no std::Command available)
  2. Pass arguments

I saw some project fighting with similar questions (eg. Phala, DeeperNetwork) and thought about asking here. Problem is we can't access many things like std::Command under no_std.

To keep it simple and demo level, lets say we are using the template pallet and when someone transacts doSomething() we just execute the ping binary with ip address passed to it.

Code: https://github.com/substrate-developer-hub/substrate-pallet-template/blob/dbe0a44e7cb985a2a10f47cc58cb4591f92eeb83/src/lib.rs#L69

This is where the execution would start, inside doSomething().

Do we have a solution for that already? It also helps if we figure out that there is "no solution yet" and this needs to be solved.

2 Answers 2


There is no solution for this (yet). An API for executing binaries from the OCW could be introduced, but allowing a runtime to execute arbitrary binary code on essentially any node on the network is a systemic security risk. Realistically, it would need to be put behind some CLI option to make the danger very clear (e.g. --enable-ocw-binary-execution-DANGEROUS).

An alternative would be to create a secondary binary which connects to the node over RPC and watches the chain state for events and then executes the code itself.

  • Thank you and pepyakin. My conclusion is to make a PoC with an HTTP API with whitelisted commands. Users will be notified about the potential risks. The source code will be made open with a delay to lessen abuse possibilities.
    – six
    May 4, 2022 at 6:51

OCW could theoretically help, but Substrate does not provide a way to launch a program in response to some event. However, OCW can send HTTP requests. When OCW discover the transaction of interest it can send an HTTP request to already running HTTP server by side. That obviously requires the node operator who enables OCW will also run the companion HTTP server program side-by-side with the Substrate node.

Perhaps, though, in your case you might be able just to modify a Substrate node?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.