Search code examples
node.jshyperledger-composer

Type SampleTransaction is not defined


I have been following the example as shown in https://hyperledger.github.io/composer/v0.19/tutorials/developer-tutorial.html

After editing the .cto, .js and .acl file , I am getting an error while I am trying to create the .bna file.

Type SampleTransaction is not defined in namespace org.example.mynetwork

I am not understanding why this error shows up. I am using composer v 0.19.18.

I tried clearing all my prior installation and did a complete new installation. This is what I followed while installing the required stuff:

npm install --unsafe-perm --verbose -g composer-cli@0.19

npm install --unsafe-perm --verbose -g composer-rest-server@0.19

npm install --unsafe-perm --verbose -g generator-hyperledger-composer@0.19

npm install --unsafe-perm --verbose -g yo

What am I doing wrong? I have added the screenshot enter image description here

And Also

sssaha@EN4096144:~/fabric-dev-servers/tutorial-network$ composer archive create -t dir -n . Creating Business Network Archive

Looking for package.json of Business Network Definition Input directory: /home/sssaha/fabric-dev-servers/tutorial-network TypeNotFoundException: Type SampleTransaction is not defined in namespace org.example.mynetwork Command failed


Solution

  • While following the same tutorial, i made the same mistake as you did and hence had the same error: There are 2 .js files (in the lib and the test folders). The tutorial does not exactly say which one of the 2 we should overwrite. I initially overwrote the one in the test folder and had the same error as you since the SampleTransaction was still available in the logic.js in the lib folder.

    If you overwrite the correct .js file the error will disappear.

    Hope this helps.