Running chaincode in development mode: Smart contract developers that want to iteratively develop and test their chaincode packages without the overhead of the smart contract lifecycle process for every update.

Overview

Fabric DEVMODE - Nano bash

1 ORG + 1 PEER + 1 ORDERER

Based on fabric-samples/test-network-nano-bash, but using devmode fabric peer

Prereqs

Instructions for starting network

Open terminal windows for 1 ordering node, 1 peer node, and 1 peer admin. The peer and peer admins belong to Org1.

The following instructions will have you run simple bash scripts that set environment variable overrides for a component and then runs the component. The scripts contain only simple single-line commands so that they are easy to read and understand. If you have trouble running bash scripts in your environment, you can just as easily copy and paste the individual commands from the script files instead of running the script files.

  • cd to the test-network-devmode directory in each terminal window
  • In the first terminal, run ./generate_artifacts.sh to generate crypto material (calls cryptogen) and system and application channel genesis block and configuration transactions (calls configtxgen). The artifacts will be created in the crypto-config and channel-artifacts directories.
  • In the orderer terminal, run ./orderer.sh
  • In the peer terminal, run ./peer.sh
  • Note that orderer and peer write their data (including their ledgers) to their own subdirectory under the data directory
  • In the peer admin terminal, run source peeradmin.sh

Note the syntax of running the scripts. The peer admin scripts run with the source command in order to source the script files in the respective shells. This is important so that the exported environment variables can be utilized by any subsequent user commands.

The peeradmin.sh script sets the peer admin environment variables, creates the application channel mychannel, updates the channel configuration for the org1 gossip anchor peer, and joins peer to mychannel. The remaining peer admin scripts join their respective peers to mychannel.

Instructions for deploying and running the basic asset transfer sample go chaincode

To deploy and invoke the chaincode, utilize the peer admin terminal that you have created in the prior steps.

1. Build the chaincode

// we move to the chaincode directory (ex: cd chaincodes/chaincode-go/)
cd chaincodes/chaincode-go

go mod vendor

// in linux
go build -o mychaincode
	
// in windows	
go build -o mychaincode.exe
// we copy to the chaincode binary to chaincodes/ folder
mv chaincodes/chaincode-go/mychaincode chaincodes/

1. Start the chaincode

Run the following batch script to start the chaincode and connect it to the peer:

sh cc_start.sh

2. Approve and commit the chaincode definition

Run the following batch script to approve and commit the chaincode definition to the channel:

sh cc_approve_commit.sh

The command will return output similar to the following:

...
committed with status (VALID) at 127.0.0.1:7051

Interact with the chaincode

Invoke the chaincode to create an asset. Then query the asset, update it, and query again to see the resulting asset changes on the ledger. Note that you need to wait a bit for invoke transactions to complete.

// InitLedger: adds a base set of assets to the ledger.
CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode invoke -o 127.0.0.1:7050 -C mychannel -n mycc -c '{"Args":["InitLedger"]}'

// CreateAsset: issues a new asset to the world state with given details.
CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode invoke -c '{"Args":["CreateAsset", "id1", "verde", "10", "kmilo", "1"]}' -o 127.0.0.1:7050 -C mychannel -n mycc

// ReadAsset: returns the asset stored in the world state with given id.
CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode query -c '{"Args":["ReadAsset", "id1"]}' -o 127.0.0.1:7050 -C mychannel -n mycc 

// UpdateAsset: updates an existing asset in the world state with provided parameters.
CORE_PEER_ADDRESS=127.0.0.1:7051 peer chaincode invoke -c '{"Args":["UpdateAsset", "id1", "negro", "10", "kmilo", "1"]}' -o 127.0.0.1:7050 -C mychannel -n mycc

Congratulations, you have deployed a minimal Fabric network! Inspect the scripts if you would like to see the minimal set of commands that were required to deploy the network.

Utilize Ctrl-C in the orderer and peer terminal windows to kill the orderer and peer processes. You can run the scripts again to restart the components with their existing data, or run ./generate_artifacts again to clean up the existing artifacts and data if you would like to restart with a clean environment.

Note: The benefit of running the peer in DevMode is that you can now iteratively make updates to your smart contract, save your changes, build the chaincode, and then start it again using the steps above. You do not need to run the peer lifecycle commands to update the chaincode every time you make a change.

Owner
Kmilo Denis González
Specialist in solutions based on blockchain and applied cryptography, with a wide variety of professional experiences. Adept at motivating self and others.
Kmilo Denis González
Troon-NFT-Contract is deployed on Flow Blockchain, which is a white-label smart-contract for NFTs with an addition layer of Brand, Schema and Template

Overview Summary of NFTContract NFTContract is a Non Fungible Token (NFT) standard for Flow blockchain. It offers a powerful set while keeping unneces

null 0 Jan 4, 2022
A smart contract development toolchain for Go

ethgen - A smart contract development toolchain for Go A simple yet powerful toolchain for Go based smart contract development Compile solidity contra

Tally 31 Apr 25, 2022
OpenZeppelin Contracts is a library for secure smart contract development.

A library for secure smart contract development. Build on a solid foundation of community-vetted code. Implementations of standards like ERC20 and ERC

OpenZeppelin 18k May 17, 2022
Tools to help teams develop smart contracts on the Cardano blockchain

toolkit-for-cardano toolkit-for-cardano simplifies the development of Cardano smart contracts by providing teams with frequently needed tasks: Build T

SundaeSwap Finance 138 May 8, 2022
A Gomora template for building dApps and web3-powered API and smart contract listeners

Gomora dApp A Gomora template for building dApps and web3-powered API and smart contract listeners Local Development Setup the .env file first cp .env

Nuxify Inc. 3 Feb 15, 2022
An interoperable smart contract hub

Juno An interoperable smart contract hub which automatically executes, controls or documents a procedure of relevant events and actions according to t

Juno 195 May 9, 2022
A guide to smart contract security best practices

Smart Contract Security Best Practices Visit the documentation site: https://consensys.github.io/smart-contract-best-practices/ Read the docs in Chine

ConsenSys Software 5.5k May 10, 2022
An open source smart contract platform

EOSIO - The Most Powerful Infrastructure for Decentralized Applications Welcome to the EOSIO source code repository! This software enables businesses

EOSIO 11.3k May 9, 2022
The Fabric Smart Client is a new Fabric Client that lets you focus on the business processes and simplifies the development of Fabric-based distributed application.

Fabric Smart Client The Fabric Smart Client (FSC, for short) is a new Fabric client-side component whose objective is twofold. FSC aims to simplify th

null 36 May 3, 2022
Akroma GO client - Akroma is an EVM based application development platform (smart-contracts).

Akroma Akroma is an EVM based application development platform (smart-contracts). Akroma will utilize a Masternode system, and build out an Oracle pla

null 2 Apr 22, 2022
For whatever reason you want to transfer TLS certificates in kubernetes to Qiniu CDN

Qiniu Certificate Sync For whatever reason you want to transfer TLS certificates in kubernetes to Qiniu CDN This app will upload provided TLS secrets

null 2 Oct 21, 2021
Build a local copy of Known Exploited Vulnerabilities Catalog by CISA. Server mode for easy querying.

go-kev go-kev build a local copy of Known Exploited Vulnerabilities Catalog by CISA. Usage $ go-kev help Go Known Exploited Vulnerabilities Usage:

MaineK00n 11 Apr 18, 2022
Build a local copy of Known Exploited Vulnerabilities Catalog by CISA. Server mode for easy querying.

go-kev go-kev build a local copy of Known Exploited Vulnerabilities Catalog by CISA. Usage $ go-kev help Go Known Exploited Vulnerabilities Usage:

null 11 Apr 18, 2022
TTAK.KO-12.0223 Lightweight Encryption Algorithm with Galois/Counter Mode (LEA-GCM)

LEACrypt The Lightweight Encryption Algorithm (also known as LEA) is a 128-bit block cipher developed by South Korea in 2013 to provide confidentialit

Pedro F. Albanese 0 Dec 28, 2021
Pinki - Pinki helps developers ship software with authenticity

Pinki Pinki helps developers ship software with authenticity. Use it anywhere yo

Twuni 1 Jan 7, 2022
Return list of the contract's events logs

Return list of the contract's events logs Return contract's events logs via sending address, from_block and to_block range only as RAW data. Working w

Ali Shokoohi 1 Oct 12, 2021
Abigen by contract address using etherscan api

Abigen for zoomers Just a simple wrapper to fetch abis from etherscan and run abigen on it. Uses the name of a contract if possible. Usage First put y

Sina Khalili 1 Mar 24, 2022
Ransomware: a type of malware that prevents or limits users from accessing their system

Ransomware Note 1: This project is purely academic, use at your own risk. I do not encourage in any way the use of this software illegally or to attac

null 1 Nov 17, 2021
A system written in Golang to help ops team to automate the process of mapping Vault groups to LDAP Groups.

A system written in Golang to help ops team to automate the process of mapping Vault groups to LDAP Groups. This utility automatically adds LDAP Groups' members to the corresponding Vault Groups.

Rahul Indra 0 Nov 12, 2021