Use the VSCode plug-in to develop Hyperledger Fabric smart contracts (chaincode)

background

Developing Fabric chaincode is cumbersome for developers: it requires deploying nodes, installing chaincode, restarting the network, and other operations. The current plug-in "Hyperledger Fabric Debugger" in VSCode can help us quickly develop smart contracts.

Steps for usage

  1. Install the plug-in
    Install the Hyperledger Fabric Debugger plug-in in VSCode
    Insert image description here

  2. Open the directory where you want to develop the chain code and create a .vscode/launch.json file with the following content:

{
    "configurations": [  
        {
            "name": "Debug Chaincode",
            "type": "hlf-go",
            "request": "launch",
            "isCaas": false
        }
        
    ]
}
  1. Write a contract

  2. Create the test.fabric file with the following content:

[      
    { 
        "query": "ReadAsset",
        "args": ["asset1"]   
    },
    {
        "invoke": "CreateAsset",
        "args": ["asset1","blue","71","Tom","220"]
    }
]
  1. Turn on debugging, press the F5 button, and click send request in the test.fabric file to debug the chain code.
    Insert image description here

Guess you like

Origin blog.csdn.net/qq_41575489/article/details/133559535