Code Monkey home page Code Monkey logo

Comments (2)

janb87 avatar janb87 commented on July 18, 2024

Hi @sedacrivity

In our ChaincodeBase it has no arguments but you could overwrite the function in your implementation and get access to the 'stub' (https://fabric-shim.github.io/ChaincodeStub.html). From the stub you can get to the arguments.

class Chaincode extends ChaincodeBase {
     async Init(stub) {
        const args =  stub.getArgs();
        // ...
    }
}

See https://fabric-shim.github.io/ChaincodeInterface.html.

The Init is only called when instantiating / upgrading chaincode. So it would not run when you invoke or query chaincode. For that you would need to use the 'Invoke' function.

The error you shared seems to come from your chaincode code itself. Would you be able to share your chaincode so I can get some more understanding on what your are trying to do?

from hyperledger-fabric-chaincode-dev-setup.

sedacrivity avatar sedacrivity commented on July 18, 2024

Hi @janb87,

Thanks for your reply and suggestion to overwrite the Init in an own implementation ... that would work fine indeed :-)

The error was indeed coming from the Init implementation within my own chaincode example ( which throws an error when there are no arguments ) - I did not inherit from your implementation ...

I understand that the Init is only executed upon instantiation ... in the Fabric examples it is used to define some attributes already ... but I reckon that is mostly for the sake of the example ... and not necessarely what one would do in a productive implementation ... hence my question on practise ... and it seems you guys didn't find a need either to have arguments in the Init method :-)

Thanks for your reply :-)

from hyperledger-fabric-chaincode-dev-setup.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.