Instantiate test contract fails with Contract name is not known #fabric-questions #fabric-chaincode

Keith Harrison-Broninski

I am trying to adapt the commercial paper tutorial to a custom contract, and cannot instantiate it.
In commercial-paper/organization/magnetocorp/contract, I updated:
  • package.json with a new name, version and description (also adding `"private" : true` to remove the "no repository field" warning)
  • package-lock.json with the same name and version
  • index.js with a new `contract` const, replacing this also in the `contracts` export
  • the lib directory with new contract scripts matching the above, editing only to replace org.papernet, commercialpaper, etc. with test names (not changing any functionality)
Then I ran `npm install`, started a basic network, and instead of installing the commercial paper contract, installed my custom contract:
    Get installed chaincodes on peer:
    Name: testcontract, Version: 0, Path: /opt/gopath/src/, Id: <id>
However,  instantiate fails with `Contract name is not known`:
    Error: could not assemble transaction, err proposal response was not successful, error code 500, msg transaction returned with failure: Error: Contract name is not known: com.test.testcontract
I validated all the edited js scripts using esprima and they passed without error.
Tried changing the contract name in the class back to the original `org.papernet.commercialpaper` and instantiating with this name instead - then instantiate gives no error, but nothing is instantiated:
    Get instantiated chaincodes on channel mychannel:
It seems as if the original contract name is set somewhere else that I omitted to update?  If so, I cannot locate it with a "Find in Files" search from VS Code.
Help gratefully received.

Keith Harrison-Broninski

PS: A simpler and more easily reproducible test is now available in Stack Overflow

Labib Farag Labib

It seems you didn't change the contract name in package.json papercontract as the contract installed on peer with details name: papercontract, Version: 0

Keith Harrison-Broninski

No, that's right, for a minimal test case I only changed the class name. 

In the original attempt I changed both and got the same behaviour.