Interacting with your client
How to get started with the laravel package.

Recording a trust event

Events can only be recorded using a single private key, this is the default behaviour. This means that you and your users can Trust that the messages will only come from you, the owner of the hedera private key.
If a Topic doesn't exist in your database one will be created before the consensus message is dispatched.

Imports

1
use Trustenterprises\LaravelHashgraph\LaravelHashgraph;
2
use Trustenterprises\LaravelHashgraph\Models\ConsensusMessage;
Copied!

Code

The Consensus Message takes a String if you wish to use an object convert it first using json_encode. We suggest that this code should be run in a Job as it uses the synchronous
1
$message = new ConsensusMessage('This is an event you wish to store');
2
$message->setReference('an-internal-model-id'); // optional
3
​
4
LaravelHashgraph::withTopic('Trust Enterprises')->sendMessage($message);
Copied!

Extending behaviour with event listenters

There are 2 events that can be listened to:
  • ConsensusMessageWasReceived
  • TopicWasCreated
Have a look at the Laravel offical docs for events for creating your own listenters for events.
​
​