我的问题是我在模型文件中定义事务,然后在 js 脚本中使用它,但它引发错误“错误:找不到任何要为事务执行的函数。” 当我尝试执行时。它发生在代码测试期间
我的模式文件 /** * 新的模式文件 */
/**
* New model file
*/
namespace org.acme.bank
participant accountholder identified by bankid
{
o String bankid
o String firstname
o String lastname
o String address
}
asset acount identified by accno
{
o String accno
o String balance
-->accountholder customer1
}
transaction amountTransfer
{
o String tid
o String amount
-->acount owner1
-->acount owner2
}
我的 script.js
/**
* Track the trade of a commodity from one trader to another
* @param {org.acme.bank.amountTransfer} Transfer - to trade
* @transactiton
*/
function Transfer(Transfer)
{
var amount1=Transfer.owner1.balance
var amount2=Transfer.owner2.balance
if(Transfer.amount>amount1)
{
return 0;
}else
{
owner1.balance-=Transfer.amount
owner2.balance+=Transfer.amount
return getAssetRegistry('org.acme.bank.acount')
.then(function (assetRegistry) {
return assetRegistry.update(Transfer.owner1);
}).then(function () {
return getAssetRegistry('org.acme.bank.acount');
}).then(function (assetRegistry) {
return assetRegistry.update(Transfer.owner2);
});
}
}
先感谢您