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:
- api/contract/< contract-instance-id >/endpoint/< json >
- api/contract/< contract-instance-id >/status
Using curl, I can call endpoint 1.:
curl --header "Content-Type: application/json" -X POST http://127.0.0.1:9080/api/contract/instance/1c893716-913b-4fce-a28d-1d09f15f56d1/endpoint/buyTx --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 http://127.0.0.1:9080/api/contract/instance/1c893716-913b-4fce-a28d-1d09f15f56d1/status
And this returns a very big json containing the ExportTx
that my contract function returns.
My questions are:
- Is it possible to get the ExportTx as a return value of http request 1. ?
- Is my use of the PAB and the contract instances correct for the use case described or am I doing something wrong ?
- 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.