3

Is there a way to return values that are not the unit in JSON form from an endpoint?

Currently, any successful endpoint call over HTTP returns "[]".

The only way we have to debug content is on the PAB side, from which we can read logs.

Does this have to do with the final parameter of the Contract w s e a where a is generally the unit in most starter PAB code?

According to the docs, a is a semigroup. If we return some type there we still don't get a result from the PAB.

1 Answer 1

2

As I understand, it's not possible to return a value different to unit because the endpoint response always returns unit () check here in endpoint line

Here is the call to endpoint:

:<|> "endpoint" :> Capture "endpoint-name" String :> ReqBody '[JSON] JSON.Value :> Description "Call an endpoint." :> Post '[JSON] ()

Post receives a JSON with JSON.Value value and returns a JSON with a () value.

Anyway, you can use status to debug and read logs, which returns ContractInstanceClientState including:

  • observableState
  • logs
  • lastLogs

You call status in this way: /api/contract/instance/<contract-instance-id>/status

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.