Transactions t:Instance org.acme.seller.CarHW7722缺少必填字段oldOwner

Transactions t:Instance org.acme.seller.CarHW7722缺少必填字段oldOwner,transactions,blockchain,hyperledger-composer,Transactions,Blockchain,Hyperledger Composer,我是区块链新手,我在使用virtual box在Ubuntu上安装的hyperledger composer设置上尝试了一些代码,但无法解决此错误 我在提交事务时收到此错误: t:Instance org.acme.seller.CarHW7722缺少必填字段oldOwner 下面是我尝试的代码: 如果向资产添加了新字段,并且资产注册表中的现有数据没有该字段,则会看到此错误 如果将可选项添加到新字段中,例如->所有者oldOwner可选项,则错误应消失。具有引导功能总是很好的,它可以帮助您加载少

我是区块链新手,我在使用virtual box在Ubuntu上安装的hyperledger composer设置上尝试了一些代码,但无法解决此错误

我在提交事务时收到此错误:


t:Instance org.acme.seller.CarHW7722缺少必填字段oldOwner

下面是我尝试的代码:
如果向资产添加了新字段,并且资产注册表中的现有数据没有该字段,则会看到此错误


如果将可选项添加到新字段中,例如->所有者oldOwner可选项,则错误应消失。

具有引导功能总是很好的,它可以帮助您加载少量资产和参与者以测试您的功能。在您的案例中,事务需要您之前应该创建的所有者参与者。这有助于将汽车从一位车主转移到另一位车主


考虑到这一情况,请执行以下操作,而不是像@r-thatcher所提到的那样将其作为可选操作。创建两个所有者,然后通过在交易时提供所有者id来尝试进行交易。这将帮助您清楚地理解它。

感谢纳文的回复。我也在尝试这样做,但遇到了错误。我已经创建了两个所有者,一个当前拥有资产,另一个资产作为汽车,在提交交易后,我将另一个分配给第一个所有者。t:Instance org.acme.seller.CarHW7722缺少必填字段oldOwner是我在您首次创建汽车时处理的代码,您是否填写旧所有者Make it Owner(如果可能),因为它对任何所有者记录都有意义??
**Sample.cto**
/**
 * Sample business network definition.
 */
namespace org.acme.seller

asset Car identified by carNumber{
  o String carNumber
  o String carName
  --> Owner oldOwner
}


participant Owner identified by ownerId{
  o String ownerId
  o String fname
  o String lname
}

transaction Transfer{
  --> Car car
  --> Owner newOwner
}
----------------------
**Sample.js**

/**
 * Sample transaction processor function.
 * @param {org.acme.seller.Transfer} tx The sample transaction instance.
 * @transaction
 */
function Transfer(tx) {

    // Save the old value of the asset.
    tx.car.oldOwner = tx.car.newOwner;

    // Update the asset with the new value.
     // tx.car1.value = tx.newValue;

    // Get the asset registry for the asset.
    return getAssetRegistry('org.acme.seller.Car')
        .then(function (assetRegistry) {

            // Update the asset in the asset registry.
            return assetRegistry.update(tx.car);
        });
}
------------------------------------------------
**Permissions.acl**

/**
 * Sample access control list.
 */
rule EverybodyCanReadEverything {
    description: "Allow all participants read access to all resources"
    participant: "ANY"
    operation: ALL
    resource: "org.acme.seller.*"
    action: ALLOW
}

rule EverybodyCanSubmitTransactions {
    description: "Allow all participants to submit transactions"
    participant: "ANY"
    operation: ALL
    resource: "org.acme.seller.*"
    action: ALLOW
}

rule OwnerHasFullAccessToTheirAssets {
    description: "Allow all participants full access to their assets"
    participant(p): "org.acme.seller.*"
    operation: ALL
    resource(r): "org.acme.seller.*"
    condition: (r.owner.getIdentifier() === p.getIdentifier())
    action: ALLOW
}

rule SystemACL {
  description:  "System ACL to permit all access"
  participant: "org.hyperledger.composer.system.Participant"
  operation: ALL
  resource: "org.hyperledger.composer.system.**"
  action: ALLOW
}