1

我正在关注 IBM Blockchain 上 Hyperledger Composer 的教程我陷入了该错误

这是交易:

{
  "$class": "org.acme.vehicle.auction.Offer",
  "bidPrice": 6000,
  "listing": "resource:org.acme.vehicle.auction.VehicleListing#1304",
  "member": "resource:org.acme.vehicle.auction.Member#alice@email.com"
}

1304 是 VehicleListing 的 id,alice@mail.com 是我之前插入的用户。

这是事务处理函数:

/**
 * Make an Offer for a VehicleListing
 * @param {org.acme.vehicle.auction.Offer} offer - the offer
 * @transaction
 */
async function makeOffer(offer) { 
    let listing = offer.listing;
    if (listing.state !== 'FOR_SALE') {
        throw new Error('Listing is not FOR SALE');
    }
    if (!listing.offers) {
        listing.offers = [];
    }
    listing.offers.push(offer);


    const vehicleListingRegistry = await getAssetRegistry('org.acme.vehicle.auction.VehicleListing');
    await vehicleListingRegistry.update(listing);
}

这是模型:

asset VehicleListing identified by listingId {
  o String listingId
  o Double reservePrice
  o String description
  o ListingState state
  o Offer[] offers optional
  --> Vehicle vehicle
}


abstract participant User identified by email {
  o String email
  o String firstname
  o String lastname
}

participant Member extends User {
  o Double balance
} 

transaction Offer {
  o Double bidPrice
  --> VehicleListing listing
  --> Member member
}
4

0 回答 0