ContractId for Template and Interface

Hi Team,

Recently discovered that via HTTP JSON API, fetch_by_contract_id on an interface ContractId without providing templateId nor interfaceId would give us the template object. Is this a deterministic behaviour that it will always give us the template object?

Does a template and its interface have the same contractId?



That’s correct, contract IDs are distinguished solely by static type in Daml and various codegens. So you could say that you have supplied “a contract ID” rather than “an interface ContractId”.

If we were to design the JSON API now, we would probably not allow you to leave off the template or interface ID. But the API precedes the introduction of interfaces, and the prior behavior of that endpoint was to return the template payload on such requests as you describe, and so it must continue to do that.

1 Like