Hyperledger fabric 如何在Hyperledger Composer项目中加载示例数据

Hyperledger fabric 如何在Hyperledger Composer项目中加载示例数据,hyperledger-fabric,hyperledger-composer,Hyperledger Fabric,Hyperledger Composer,当我部署一个新的Hyperledger Composer项目时,它是完全空的。有没有加载某种种子/装置数据的方法?我过去所做的就是编写一个名为setup的事务,该事务只允许管理员运行。此函数使用大量模拟数据初始化链,您可以使用这些数据进行测试。例如: 型号: transaction Setup { } 事务脚本: /** * Seed chain with mock data for testing * @param {com.your.namespace} tx - set up req

当我部署一个新的Hyperledger Composer项目时,它是完全空的。有没有加载某种种子/装置数据的方法?

我过去所做的就是编写一个名为
setup
的事务,该事务只允许管理员运行。此函数使用大量模拟数据初始化链,您可以使用这些数据进行测试。例如:

型号:

transaction Setup {
}
事务脚本:

/**
 * Seed chain with mock data for testing
 * @param {com.your.namespace} tx - set up request
 * @transaction
 */
async function setup(tx) {
  const factory = getFactory();

  const exampleRegistry = await getParticipantRegistry(`${namespace}.example`);

  const exampleResource= factory.newResource(namespace, "Example", "ExampleResourceName");
  example.exampleProperty = 2000;

  await exampleRegistry.add(exampleResource);

  const otherExample = factory.newResource(namespace, "OtherExample", "OtherExampleName");
  otherExample.exampleProperty = 0;
  const otherExampleRef = factory.newRelationship(namespace, "OtherExample", "OtherExampleName");

  await otherExampleRegistry.addAll([otherExample]);

  const thirdExample = factory.newResource(namespace, "ThirdExample", "ThirdExampleName");
  thirdExample.exampleRelationshipProperty = otherExampleRef
  thirdExample.exampleProperty = 0;

  await thirdExampleRegistry.addAll([thirdExample]);
}
然后,您的
.ACL

rule SetupTransaction {
    description: "Deny anyone but admin access to call Setup transaction"
    participant: "com.your.namespace.**"
    operation: ALL
    resource: "com.your.namespace.Setup"
    action: DENY
}