When I try to execute the transaction in composer-playground I got an error "getAssetRegistry is returning null and the error message says assetRegistry is not defined"
/*Here is my .cto file: */
namespace org.acme.payrent
participant Authority identified by authorityId {
o String authorityId
}
participant Tenant identified by tenantEmailId {
o String tenantEmailId regex =/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
o String tFirstName
o Address Address
o TBankDetails tBank
o Integer accountNo
}
participant Owner identified by ownerEmailId {
o String ownerEmailId regex =/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
o String name
o String number regex=/^[0-9]*$/
o Integer bankaccountno
o Address propAddress
--> Tenant tnt
}
participant Bank identified by bankID {
o String bankID
o TBankDetails tBank
}
asset Property identified by propAddress {
o String propAddress
o Address propActAddress
o String tenantName
o Double rentAmount
}
concept Address {
o String houseNumber
o String street
o String city
o String country
}
concept TBankDetails {
o String bankName
o String ifscCode
o String branchName
}
concept Contact {
o String email regex =/^([a-zA-Z0-9_\-\.]+)@([a-zA-Z0-9_\-\.]+)\.([a-zA-Z]{2,5})$/
o String mobileNumber regex=/^[0-9]*$/
o String firstName
o String lastName
}
event E1{
o String email
o String mobileNumber regex=/^[0-9]*$/
o String tntName
o TBankDetails tntBankDetails
o Address propertyAddress
}
transaction Agreement{
--> Property property
o String owrName
o String tntName
o String email
o String propAddress
o String mobileNumber
o String bankName
o String ifscCode
o String branchName
}`
/* chaincode/logic.js file: */ ` /** * Place an order for a vehicle * @param {org.acme.payrent.Agreement} the Create Agreement transaction * @transaction */
function Agreement(tntObj)
{
debugger
var factory = getFactory(tntObj);
var Namespace = "org.acme.payrent";
var property = tntObj.propAddress;
var addTntEvent = factory.newEvent(Namespace, 'E1');
addTntEvent.email = tntObj.email;
addTntEvent.mobileNumber = tntObj.mobileNumber ;
addTntEvent.tntName = tntObj.tntName;
addTntEvent.tntBankName = tntObj.bankName;
addTntEvent.ifscCode = tntObj.ifscCode;
addTntEvent.branchName = tntObj.branchName;
var a = getAssetRegistry('org.acme.payrent.Property');
return getAssetRegistry('org.acme.payrent.Property')
.then(function(propertyRegistry){
return assetRegistry.update(property); });
}`
Access control file:permission.acl
`/**
* New access control file
*/
rule Default {
description: "Allow all participants access to all resources"
participant: "ANY"
operation: ALL
resource: "org.acme.payrent.*"
action: ALLOW
}
rule SystemACL {
description: "System ACL to permit all access"
participant: "ANY"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
rule Owner {
description: "Owner can add a Tenant"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
rule Bank {
description: "Bank can verify tenant's bank account"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}
rule Govenment {
description: "To verify property belongs to owner"
participant: "org.hyperledger.composer.system.Participant"
operation: ALL
resource: "org.hyperledger.composer.system.**"
action: ALLOW
}`