Using dfuse Events

dfuse Events are a powerful way to give smart contract developers a way to ask dfuse Search to index their transactions, with arbitrary key/value pairs.

Getting Started

Say a smart contract manages virtual pets. Each pet has a unique ID and a kind (dog, cat, mouse, rabbit).

Say you have an action train(pet_id) that trains and increases whatever features of your pet.

If you want to list all trainings for dogs, you’re short of luck - the action does not contain the kind of pet being trained here.

By adding an inline action to dfuseiohooks:event in your smart contract, and exfiltrating the missing bit of data, such as pet_kind=dog in the data field, you will immediately be able to search for event.pet_kind:dog action:train receiver:yourcontract anywhere on the dfuse Platform.

The gist of the EOSIO contract implementation is:

const std::string& pet_kind = get_pet_kind(pet_id);

      // Parameter `auth_key`
      // Parameter `data`
      std::string("pet_id=" + pet_id + "&pet_kind=" + pet_kind)

Example contract

See an example implementation from a sample smart contract .