Hello,
I am using the Finance Library, assuming a party would like to transfer holdings to another party. However, the flow does not allow him to transfer it directly - he needs to apply a request for it, and once the custodian approves it, the custodian will do the transfer.
However, since the Holding does not have a key, how does the custodian can pull the owner’s holdings in order to find the best one (or more, in case a merge will be first needed) to do the transfer with?
The necessary authorization restriction on transfers can be achieved through the controllers property on accounts. It determines who needs to authorize outgoing and incoming transfers for an account.
Your design to collect joint authorization though eg. a TransferRequest contract makes sense
As a signatory the custodian has visibility on the owner’s holdings with them. So they can (using off-ledger logic) select suitable holdings, and pass them into eg. an Execute choice on the TransferRequest, which can take care of the “right-sizing” (ie. splitting / merging) of holdings, and subsequently calls Transfer on the resulting holding.
Thanks @georg for your answer, however, my question was about the proper way of doing it.
I know that the custodian can query the holdings for the owner, but since there is no key on holdings, the custodian will query for all the active holdings available on the ledger.
So, going through them can consume precious time, and it does not sound like the best approach. Is there a way to filter them?
Or is there something else that I can do in order to achieve it?
You could let the owner lock one of its holding to the custodian, and refer to that contract id in the TransferRequest (i.e., the TransferRequest template would have a ContractId Base.I as field). In the Execute choice body, the custodian would then:
Unlock the holding
Split off the right amount
Do the transfer
By locking the holding, you make sure that the provided holding can’t be used by another process, and the custodian would not need to do any query off-ledger.
I’m not sure a key would solve this: you’d need to have a unique key on each holding, and could only ever fetch a single contract by its key. And not sure what a sensible key would be for a holding.
If you’re referring to eg. querying holdings by instrument key, that is definitely something to be done on the client side - there’s no such functionality within Daml. Through the JSON API, for example, you can submit queries (eg. via the JS bindings) that contain such filter.
(check the docs for the exact syntax of the query)
The other option is what Johan mentions: “tagging” certain holdings by locking them, and referring to them specifically by contract id on the TransferRequest.
@georg I think that having the ability to query for contracts by multiple parties could solve such an issue.
I mean for example to do something like the following:
holdingCids <- query @Holding [custodian, owner]
In this case, the custodian can query for only the holdings that belong to the owner.