I want my users to interact with my smart contracts. All transactions come from these users. There are no transactions - except for setting up - that come from my wallets. As entry point for this interaction, I have the PAB running. The PAB runs on local host and listens to the requests that my webpage forwards to it.

My understanding is that every interaction with the Cardano block chain happens within a contract instance. This instance needs to be activated and then listens to calls. So I start one long running contract instance on PAB startup.

Now, the PAB exposes (among others) two endpoints:

  1. api/contract/< contract-instance-id >/endpoint/< json >
  2. api/contract/< contract-instance-id >/status

Using curl, I can call endpoint 1.:

curl --header "Content-Type: application/json" -X POST --data '{"quantity":1}'

When I call endpoint 1., I can see the logs but there is no output in the console. It seems the http request does not return any value.

To get a value I need to call endpoint 2. (after having called endpoint 1.):

curl -X GET

And this returns a very big json containing the ExportTx that my contract function returns.

My questions are:

  1. Is it possible to get the ExportTx as a return value of http request 1. ?
  2. Is my use of the PAB and the contract instances correct for the use case described or am I doing something wrong ?
  3. Shall I activate a contract instance for every user request or can I use one long running instance for all users ? The need to issue two http requests make me wonder if the latter is even possible without mixing up requests of different users.


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.

Browse other questions tagged or ask your own question.