Dear Experts,
Help! I cannot get round this runtime error trying to create a contract using the ledger API. Any thoughts on where I am going wrong?
java.lang.RuntimeException: java.util.concurrent.ExecutionException: io.grpc.StatusRuntimeException: INVALID_ARGUMENT: Command interpretation error in LF-DAMLe: unknown module 86828b9843465f419db1ef8a8ee741d1eef645df02375ebf509cdc8c3ddd16cb:Trade while looking for record 86828b9843465f419db1ef8a8ee741d1eef645df02375ebf509cdc8c3ddd16cb:Trade:Trade. Details: N/A.
Looks like its missing the template or module in the request, but I am lost in where to add it.
Code:
DamlRecord recordDaml = new DamlRecord(
new DamlRecord.Field("newBuyer", new Party("TRADER_DAML")),
new DamlRecord.Field("newSeller", new Party("TRADER_A")),
new DamlRecord.Field("newVolume", new Numeric(new BigDecimal(trade.getTradeVolume()))),
new DamlRecord.Field("newPrice", new Numeric(new BigDecimal(trade.getTradePrice()))),
new DamlRecord.Field("newTimestamp", new Timestamp(trade.timeStampInMs))
);
Identifier dalmIdentifier = new Identifier(packageId, "Trade", "Trade");
CreateCommand createCommand = new CreateCommand(dalmIdentifier, recordDaml);
client.getCommandClient().submitAndWait(
String.format("Trade-%s-%d", "TRADER_DAML", numberOfLinesWritten),
"TraderApp",
UUID.randomUUID().toString(),
"DAML_TRADER",
Collections.singletonList(createCommand)
).blockingGet();
Template:
module Trade where
type TradeCid = ContractId Trade
template Trade
with
buyer : Party
seller : Party
volume: Decimal
price: Decimal
timestamp: Datetime
observers : [Party]
where
ensure volume > 0.0
signatory buyer
observer observers