Skip to main content

Kathmandu

Note: as LIGO uses Mumbai protocol to Michelson type-check your programs, the flag --disable-michelson-typechecking is recommended to compile contracts to Kathmandu when using tickets / chest.

API

New primitives

Tezos

pascaligo

val emit<a> : string -> a -> operation

cameligo

val emit : string -> 'a -> operation

jsligo

let emit: string => 'a => operation

Build an event operation. To actually emit an event, this operation must be returned the same way as other operations (origination / transfer ..)

Test

pascaligo

val get_last_events_from<a,p,s> : typed_address (p,s) -> string -> list (a)

cameligo

val get_last_events_from : ('p,'s) typed_address -> string -> 'a list

jsligo

let get_last_events_from: typed_address <'p,'s> => string => list <'a>

Returns the list of all the event payloads emited with a given tag by a given address. Any call to this function must be annotated with the expected payload type.

Event testing

Here is how you emit events and fetch them from your tests:

namespace C {
@entry
let main = (p: [int, int], _s : unit) => {
let op1 = Tezos.emit("%foo", p);
let op2 = Tezos.emit("%foo", p[0]);
return [list([op1, op2]), unit];
};
}

let test = (() : [list<[int,int]>, list<int>] => {
let orig = Test.originate(contract_of(C), unit, 0 as tez);
Test.transfer_exn(orig.addr, Main([1,2]), 0 as tez);
return [Test.get_last_events_from(orig.addr, "foo") as list<[int, int]>, Test.get_last_events_from(orig.addr, "foo") as list<int>];
}) ();