Skip to content

emit

Emitted Transactions prepare()
  • Read a transaction from read_ptr
  • Validate the transaction against the emission rules
  • Emit the transaction into consensus when valid
  • Write canonical transaction hash to write_ptr

With the HooksUpdate2 amendment, use prepare() before emit() to automatically inject all required emission fields (Account, Sequence, SigningPubKey, Fee, EmitDetails, etc.) from a partial transaction.

int64_t emit (
uint32_t write_ptr,
uint32_t write_len,
uint32_t read_ptr,
uint32_t read_len
);
uint8_t emithash[32];
if (emit(SBUF(emithash), SBUF(tx)) < 0)
rollback(SBUF("hook: emit failed"), __LINE__);
NameTypeDescription
write_ptruint32_tPointer to a buffer to write the transaction hash to
write_lenuint32_tThe size of the buffer to write the transaction hash to (should be 32.)
read_ptruint32_tPointer to the transaction to emit
read_lenuint32_tThe length of the transaction
TypeDescription
int64_tOn success, the number of bytes of transaction hash written (32), or:

If negative, an error:
OUT_OF_BOUNDS
- pointers/lengths specified outside of hook memory.

PREREQUISITE_NOT_MET
- etxn_reserve must be called first

TOO_MANY_EMITTED_TXN
- the number of emitted transactions is now greater than the promise made when etxn_reserve was called earlier

EMISSION_FAILURE
- the transaction was malformed according to the emission rules.