Skip to content

Instantly share code, notes, and snippets.

@vbar
Last active June 24, 2022 11:01
Show Gist options
  • Save vbar/d59ab254321bf32fa93652c51711ee50 to your computer and use it in GitHub Desktop.
Save vbar/d59ab254321bf32fa93652c51711ee50 to your computer and use it in GitHub Desktop.

Starter is the simplest possible hook: it just accepts all transactions and logs that it is running.

to test:

  • in the develop pane, compile starter.c
  • in the deploy pane, deploy it to Alice account
  • set up payment transaction from Alice to Bob
  • run it and see in the debug stream 'Accept.c: Called.'

Modifying the tracing message and compiling with different optimizations are left as an exercise for the reader.

/**
* This hook just accepts any transaction coming through it
*/
#include "hookapi.h"
int64_t hook(uint32_t reserved ) {
TRACESTR("Accept.c: Called.");
accept (0,0,0);
_g(1,1); // every hook needs to import guard function and use it at least once
// unreachable
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment