Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
TIC
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Registry
Registry
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
BY
TIC
Commits
45230e05
Commit
45230e05
authored
Feb 10, 2021
by
anandhakumarpalanisamy
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
- Added chaincode for the articonf bank app
- Refer README for more instructions
parent
c057c861
Changes
26
Show whitespace changes
Inline
Side-by-side
Showing
26 changed files
with
964 additions
and
0 deletions
+964
-0
.gitignore
articonf-bank-chaincode/.gitignore
+104
-0
LICENSE
articonf-bank-chaincode/LICENSE
+201
-0
README.md
articonf-bank-chaincode/README.md
+72
-0
get.sh
articonf-bank-chaincode/bank_chaincode/shell_scripts/get.sh
+12
-0
install.sh
...nf-bank-chaincode/bank_chaincode/shell_scripts/install.sh
+11
-0
instantiate.sh
...ank-chaincode/bank_chaincode/shell_scripts/instantiate.sh
+11
-0
put.sh
articonf-bank-chaincode/bank_chaincode/shell_scripts/put.sh
+14
-0
1_package.sh
...ncode/bank_chaincode/shell_scripts_lifecycle/1_package.sh
+22
-0
2_install.sh
...ncode/bank_chaincode/shell_scripts_lifecycle/2_install.sh
+22
-0
3_approve_chaincode_def_for_org.sh
...hell_scripts_lifecycle/3_approve_chaincode_def_for_org.sh
+30
-0
4_check_commit_readiness.sh
...ncode/shell_scripts_lifecycle/4_check_commit_readiness.sh
+27
-0
5_commit_chaincode_def_to_channel.sh
...ll_scripts_lifecycle/5_commit_chaincode_def_to_channel.sh
+29
-0
invoke_create_asset.sh
..._chaincode/shell_scripts_lifecycle/invoke_create_asset.sh
+20
-0
invoke_init_ledger.sh
...k_chaincode/shell_scripts_lifecycle/invoke_init_ledger.sh
+20
-0
invoke_transfer.sh
...bank_chaincode/shell_scripts_lifecycle/invoke_transfer.sh
+21
-0
query.sh
...chaincode/bank_chaincode/shell_scripts_lifecycle/query.sh
+21
-0
get.sh
...onf-bank-chaincode/bank_chaincode/shell_scripts_v2/get.sh
+13
-0
install.sh
...bank-chaincode/bank_chaincode/shell_scripts_v2/install.sh
+13
-0
instantiate.sh
...-chaincode/bank_chaincode/shell_scripts_v2/instantiate.sh
+15
-0
put.sh
...onf-bank-chaincode/bank_chaincode/shell_scripts_v2/put.sh
+13
-0
.eslintignore
articonf-bank-chaincode/bank_chaincode/src/.eslintignore
+5
-0
.eslintrc.js
articonf-bank-chaincode/bank_chaincode/src/.eslintrc.js
+37
-0
index.js
articonf-bank-chaincode/bank_chaincode/src/index.js
+13
-0
indexOwner.json
.../src/lib/META-INF/statedb/couchdb/indexes/indexOwner.json
+1
-0
chaincode.js
articonf-bank-chaincode/bank_chaincode/src/lib/chaincode.js
+198
-0
package.json
articonf-bank-chaincode/bank_chaincode/src/package.json
+19
-0
No files found.
articonf-bank-chaincode/.gitignore
0 → 100644
View file @
45230e05
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# Next.js build output
.next
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
.cache/
# Comment in the public line in if your project uses Gatsby and *not* Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
articonf-bank-chaincode/LICENSE
0 → 100644
View file @
45230e05
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
articonf-bank-chaincode/README.md
0 → 100644
View file @
45230e05
# Smart bank Chaincodes
Chaincodes for Smart bank App
Get into CLI container
-
cd chaincodes/
-
git clone https://github.com/bityoga/articonf-bank-chaincode.git
-
cd articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/
**Set Environment Variables:**
export ORGANISATION_NAME="hlfMSP"
export PEER_HOST=peer2
export CORE_PEER_TLS_ENABLED=true
export CORE_PEER_LOCALMSPID=${ORGANISATION_NAME}
export CORE_PEER_TLS_ROOTCERT_FILE=/root/CLI/${ORGCA_HOST}/${PEER_HOST}/msp/tls/ca.crt
export CORE_PEER_MSPCONFIGPATH=/root/CLI/${ORGCA_HOST}/${ADMIN_USER}/msp
export CORE_PEER_ADDRESS=${PEER_HOST}:7051
export ORDERER_CA=/root/CLI/${ORGCA_HOST}/${ORDERER_HOST}/msp/tls/ca.crt
**Chaincode Lifecycle Install Steps**
1.
**Package Chaincode**
peer lifecycle chaincode package bank.tar.gz --path ../src/ --lang node --label bank_1.0
2)
**Install Chaincode**
peer lifecycle chaincode install bank.tar.gz
peer lifecycle chaincode queryinstalled --output json
**Set PACKAGE_ID environmental variable**
export CC_PACKAGE_ID="PACKAGE ID GOT IN PERVIOUS STEP"
3.
**Approve Chaincode definition for organisation**
peer lifecycle chaincode approveformyorg -o orderer:7050 --channelID appchannel --name bank --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt
4.
**Check Commit Readiness**
peer lifecycle chaincode checkcommitreadiness --channelID appchannel --name bank --version 1.0 --sequence 1 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt --output json
5.
**Commit Chaincode Definition to Channel**
peer lifecycle chaincode commit -o orderer:7050 --channelID appchannel --name bank --version 1.0 --sequence 1 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt
peer lifecycle chaincode querycommitted --channelID appchannel --name bank --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt
**Query Examples**
peer chaincode query -C appchannel -n bank -c '{"Args":["GetAllAssets"]}'
peer chaincode query -C appchannel -n bank -c '{"Args":["GetAssetHistory","ark"]}'
**Invoke Examples**
**Invoke InitLedger**
peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["InitLedger"]}'
**Invoke CreateAsset**
peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["CreateAsset","ark","1000","Initial Credit"]}'
peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["CreateAsset","srk","1000","Initial Credit"]}'
**Invoke TransferBalance**
peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["TransferBalance","ark","srk","5","Friendly Help"]}'
articonf-bank-chaincode/bank_chaincode/shell_scripts/get.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
export
CORE_PEER_ADDRESS
=
"peer2:7051"
export
CORE_PEER_MSPCONFIGPATH
=
"/root/admin/msp"
export
CORE_PEER_TLS_ROOTCERT_FILE
=
"/root/
${
PEER2_HOST
}
/tls-msp/tlscacerts/tls-
${
TLSCA_HOST
}
-7054.pem"
export
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
export
CORE_PEER_MSPCONFIGPATH
=
$CORE_PEER_MSPCONFIGPATH
export
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode query
-C
appchannel
-n
bankcccccc
-c
'{"Args":["readMarble","marble1"]}'
#peer chaincode query -C appchannel -n bankcccc -c '{"Args":["getHistoryForMarble","marble1"]}'
articonf-bank-chaincode/bank_chaincode/shell_scripts/install.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
export
CORE_PEER_ADDRESS
=
"peer2:7051"
export
CORE_PEER_MSPCONFIGPATH
=
"/root/admin/msp"
export
CORE_PEER_TLS_ROOTCERT_FILE
=
"/root/
${
PEER2_HOST
}
/tls-msp/tlscacerts/tls-
${
TLSCA_HOST
}
-7054.pem"
export
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
export
CORE_PEER_MSPCONFIGPATH
=
$CORE_PEER_MSPCONFIGPATH
export
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode
install
-n
bankcccccc
-v
1.0
-l
node
-p
/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src/
articonf-bank-chaincode/bank_chaincode/shell_scripts/instantiate.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
export
CORE_PEER_ADDRESS
=
"peer2:7051"
export
CORE_PEER_MSPCONFIGPATH
=
"/root/admin/msp"
export
CORE_PEER_TLS_ROOTCERT_FILE
=
"/root/
${
PEER2_HOST
}
/tls-msp/tlscacerts/tls-
${
TLSCA_HOST
}
-7054.pem"
export
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
export
CORE_PEER_MSPCONFIGPATH
=
$CORE_PEER_MSPCONFIGPATH
export
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode instantiate
-C
appchannel
-n
bankcccccc
-v
1.0
-c
'{"Args":["init"]}'
-o
${
ORDERER_HOST
}
:7050
--tls
--cafile
${
CORE_PEER_TLS_ROOTCERT_FILE
}
articonf-bank-chaincode/bank_chaincode/shell_scripts/put.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
export
CORE_PEER_ADDRESS
=
"peer2:7051"
export
CORE_PEER_MSPCONFIGPATH
=
"/root/admin/msp"
export
CORE_PEER_TLS_ROOTCERT_FILE
=
"/root/
${
PEER2_HOST
}
/tls-msp/tlscacerts/tls-
${
TLSCA_HOST
}
-7054.pem"
export
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
export
CORE_PEER_MSPCONFIGPATH
=
$CORE_PEER_MSPCONFIGPATH
export
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
#peer chaincode invoke -C appchannel -n bankcccccc -c '{"Args":["initMarble","marble1","blue","35","tom","1000"]}' --tls --cafile ${CORE_PEER_TLS_ROOTCERT_FILE} &&
#peer chaincode invoke -C appchannel -n bankcccccc -c '{"Args":["initMarble","marble2","green","35","tom","1000"]}' --tls --cafile ${CORE_PEER_TLS_ROOTCERT_FILE}
peer chaincode invoke
-C
appchannel
-n
bankcccccc
-c
'{"Args":["buy_bank","marble1","marble2","45"]}'
--tls
--cafile
${
CORE_PEER_TLS_ROOTCERT_FILE
}
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/1_package.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer lifecycle chaincode package bank.tar.gz --path ../src/ --lang node --label bank_1.0
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
PACKAGE_NAME
=
"
${
CHAINCODE_NAME
}
.tar.gz"
CHAINCODE_LABEL
=
"
${
CHAINCODE_NAME
}
_
${
CHAINCODE_VERSION
}
"
CHAINCODE_SRC_CODE_PATH
=
"/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src"
CHANCODE_LANGUAGE
=
"node"
export
ORGANISATION_NAME
=
"hlfMSP"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
peer lifecycle chaincode package
${
PACKAGE_NAME
}
--path
${
CHAINCODE_SRC_CODE_PATH
}
--lang
${
CHANCODE_LANGUAGE
}
--label
${
CHAINCODE_LABEL
}
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/2_install.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer lifecycle chaincode install bank.tar.gz
# peer lifecycle chaincode queryinstalled --output json
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
PACKAGE_NAME
=
"
${
CHAINCODE_NAME
}
.tar.gz"
CHAINCODE_LABEL
=
"
${
CHAINCODE_NAME
}
_
${
CHAINCODE_VERSION
}
"
CHAINCODE_SRC_CODE_PATH
=
"/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src"
CHANCODE_LANGUAGE
=
"node"
export
ORGANISATION_NAME
=
"hlfMSP"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
peer lifecycle chaincode
install
${
PACKAGE_NAME
}
&&
peer lifecycle chaincode queryinstalled
--output
json
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/3_approve_chaincode_def_for_org.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer lifecycle chaincode queryinstalled --output json | jq .installed_chaincodes[0].package_id
# peer lifecycle chaincode approveformyorg -o orderer:7050 --channelID appchannel --name bank --version 1.0 --package-id $CC_PACKAGE_ID --sequence 1 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
PACKAGE_NAME
=
"
${
CHAINCODE_NAME
}
.tar.gz"
CHAINCODE_LABEL
=
"
${
CHAINCODE_NAME
}
_
${
CHAINCODE_VERSION
}
"
CHAINCODE_SRC_CODE_PATH
=
"/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src"
CHANCODE_LANGUAGE
=
"node"
export
ORGANISATION_NAME
=
"hlfMSP"
SIGNATURE_POLICY
=
"OR('
${
ORGANISATION_NAME
}
.member')"
CHANNEL_NAME
=
"appchannel"
SEQUENCE
=
"1"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CC_PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
peer lifecycle chaincode approveformyorg
-o
${
ORDERER_HOST
}
:7050
--channelID
${
CHANNEL_NAME
}
--name
${
CHAINCODE_NAME
}
--version
${
CHAINCODE_VERSION
}
--package-id
${
CC_PACKAGE_ID
}
--sequence
${
SEQUENCE
}
--tls
--cafile
${
ORDERER_CA
}
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/4_check_commit_readiness.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer lifecycle chaincode checkcommitreadiness --channelID appchannel --name bank --version 1.0 --sequence 1 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt --output json
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
PACKAGE_NAME
=
"
${
CHAINCODE_NAME
}
.tar.gz"
CHAINCODE_LABEL
=
"
${
CHAINCODE_NAME
}
_
${
CHAINCODE_VERSION
}
"
CHAINCODE_SRC_CODE_PATH
=
"/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src"
CHANCODE_LANGUAGE
=
"node"
export
ORGANISATION_NAME
=
"hlfMSP"
SIGNATURE_POLICY
=
"OR('
${
ORGANISATION_NAME
}
.peer')"
CHANNEL_NAME
=
"appchannel"
SEQUENCE
=
"1"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CC_PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
peer lifecycle chaincode checkcommitreadiness
--channelID
${
CHANNEL_NAME
}
--name
${
CHAINCODE_NAME
}
--version
${
CHAINCODE_VERSION
}
--sequence
${
SEQUENCE
}
--tls
--cafile
${
ORDERER_CA
}
--output
json
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/5_commit_chaincode_def_to_channel.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer lifecycle chaincode commit -o orderer:7050 --channelID appchannel --name bank --version 1.0 --sequence 1 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt
# peer lifecycle chaincode querycommitted --channelID appchannel --name bank --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
PACKAGE_NAME
=
"
${
CHAINCODE_NAME
}
.tar.gz"
CHAINCODE_LABEL
=
"
${
CHAINCODE_NAME
}
_
${
CHAINCODE_VERSION
}
"
CHAINCODE_SRC_CODE_PATH
=
"/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src"
CHANCODE_LANGUAGE
=
"node"
export
ORGANISATION_NAME
=
"hlfMSP"
SIGNATURE_POLICY
=
"OR('
${
ORGANISATION_NAME
}
.peer')"
CHANNEL_NAME
=
"appchannel"
SEQUENCE
=
"1"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CC_PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
peer lifecycle chaincode commit
-o
${
ORDERER_HOST
}
:7050
--channelID
${
CHANNEL_NAME
}
--name
${
CHAINCODE_NAME
}
--version
${
CHAINCODE_VERSION
}
--sequence
${
SEQUENCE
}
--tls
--cafile
${
ORDERER_CA
}
--peerAddresses
${
CORE_PEER_ADDRESS
}
--tlsRootCertFiles
${
CORE_PEER_TLS_ROOTCERT_FILE
}
&&
peer lifecycle chaincode querycommitted
--channelID
${
CHANNEL_NAME
}
--name
${
CHAINCODE_NAME
}
--cafile
${
ORDERER_CA
}
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/invoke_create_asset.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["CreateAsset","admin_test","1000","Initial Credit"]}'
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHANNEL_NAME
=
"appchannel"
INVOKE_PARAMS
=
'{"Args":["CreateAsset","admin_test","1000","Initial Credit"]}'
export
ORGANISATION_NAME
=
"hlfMSP"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
export
PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
peer chaincode invoke
-o
${
ORDERER_HOST
}
:7050
--tls
--cafile
${
ORDERER_CA
}
-C
${
CHANNEL_NAME
}
-n
${
CHAINCODE_NAME
}
--peerAddresses
${
CORE_PEER_ADDRESS
}
--tlsRootCertFiles
${
CORE_PEER_TLS_ROOTCERT_FILE
}
-c
${
INVOKE_PARAMS
}
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/invoke_init_ledger.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["InitLedger"]}'
set
-x
#echo on
CHAINCODE_NAME
=
"articonf-bank-demo"
CHANNEL_NAME
=
"appchannel"
INVOKE_PARAMS
=
'{"Args":["InitLedger"]}'
export
ORGANISATION_NAME
=
"hlfMSP"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
export
PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
peer chaincode invoke
-o
${
ORDERER_HOST
}
:7050
--tls
--cafile
${
ORDERER_CA
}
-C
${
CHANNEL_NAME
}
-n
${
CHAINCODE_NAME
}
--peerAddresses
${
CORE_PEER_ADDRESS
}
--tlsRootCertFiles
${
CORE_PEER_TLS_ROOTCERT_FILE
}
-c
${
INVOKE_PARAMS
}
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/invoke_transfer.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer chaincode invoke -o orderer:7050 --tls --cafile /root/CLI/orgca/orderer/msp/tls/ca.crt -C appchannel -n bank --peerAddresses peer2:7051 --tlsRootCertFiles /root/CLI/orgca/peer2/msp/tls/ca.crt -c '{"Args":["InitLedger"]}'
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHANNEL_NAME
=
"appchannel"
INVOKE_PARAMS
=
'{"Args":["TransferBalance","ark","srk","5"]}'
export
ORGANISATION_NAME
=
"hlfMSP"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
export
PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
#peer chaincode invoke -o ${ORDERER_HOST}:7050 --tls --cafile ${ORDERER_CA} -C ${CHANNEL_NAME} -n ${CHAINCODE_NAME} --peerAddresses ${CORE_PEER_ADDRESS} --tlsRootCertFiles ${CORE_PEER_TLS_ROOTCERT_FILE} -c ${INSTANTIATE_PARAMS}
peer chaincode invoke
-o
${
ORDERER_HOST
}
:7050
--tls
--cafile
${
ORDERER_CA
}
-C
${
CHANNEL_NAME
}
-n
${
CHAINCODE_NAME
}
--peerAddresses
${
CORE_PEER_ADDRESS
}
--tlsRootCertFiles
${
CORE_PEER_TLS_ROOTCERT_FILE
}
-c
${
INVOKE_PARAMS
}
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_lifecycle/query.sh
0 → 100644
View file @
45230e05
#!/bin/bash
# peer chaincode query -C appchannel -n bank -c '{"Args":["GetAllAssets"]}'
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHANNEL_NAME
=
"appchannel"
QUERY_PARAMS
=
'{"Args":["GetAllAssets"]}'
export
ORGANISATION_NAME
=
"hlfMSP"
export
PEER_HOST
=
peer2
export
CORE_PEER_TLS_ENABLED
=
true
export
CORE_PEER_LOCALMSPID
=
${
ORGANISATION_NAME
}
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
ORDERER_CA
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ORDERER_HOST
}
/msp/tls/ca.crt
export
PACKAGE_ID
=
$(
peer lifecycle chaincode queryinstalled
--output
json | jq .installed_chaincodes[0].package_id
)
peer chaincode query
-C
${
CHANNEL_NAME
}
-n
${
CHAINCODE_NAME
}
-c
${
QUERY_PARAMS
}
\ No newline at end of file
articonf-bank-chaincode/bank_chaincode/shell_scripts_v2/get.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHANNEL_NAME
=
"appchannel"
QUERY_PARAMS
=
'{"Args":["GetAllAssets"]}'
export
PEER_HOST
=
peer2
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode query
-C
$CHANNEL_NAME
-n
$CHAINCODE_NAME
-c
$QUERY_PARAMS
articonf-bank-chaincode/bank_chaincode/shell_scripts_v2/install.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
CHAINCODE_SRC_CODE_PATH
=
"/root/CLI/chaincodes/articonf-bank-chaincode/bank_chaincode/src"
export
PEER_HOST
=
peer2
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
CORE_PEER_MSPCONFIGPATH
=
$CORE_PEER_MSPCONFIGPATH
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode
install
-n
$CHAINCODE_NAME
-v
$CHAINCODE_VERSION
-l
node
-p
$CHAINCODE_SRC_CODE_PATH
articonf-bank-chaincode/bank_chaincode/shell_scripts_v2/instantiate.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHAINCODE_VERSION
=
"1.0"
INSTANTIATE_PARAMS
=
'{"Args":["InitLedger"]}'
CHANNEL_NAME
=
"appchannel"
export
PEER_HOST
=
peer2
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
CORE_PEER_MSPCONFIGPATH
=
$CORE_PEER_MSPCONFIGPATH
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode instantiate
-C
$CHANNEL_NAME
-n
$CHAINCODE_NAME
-v
$CHAINCODE_VERSION
-c
$INSTANTIATE_PARAMS
-o
${
ORDERER_HOST
}
:7050
--tls
--cafile
${
CORE_PEER_TLS_ROOTCERT_FILE
}
articonf-bank-chaincode/bank_chaincode/shell_scripts_v2/put.sh
0 → 100644
View file @
45230e05
#!/bin/bash
set
-x
#echo on
CHAINCODE_NAME
=
"bank"
CHANNEL_NAME
=
"appchannel"
INVOKE_PARAMS
=
'{"Args":["CreateAsset","srk","1000","InitialCredit"]}'
export
PEER_HOST
=
peer2
export
CORE_PEER_ADDRESS
=
${
PEER_HOST
}
:7051
export
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
ADMIN_USER
}
/msp
export
CORE_PEER_TLS_ROOTCERT_FILE
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp/tls/ca.crt
CORE_PEER_ADDRESS
=
$CORE_PEER_ADDRESS
CORE_PEER_MSPCONFIGPATH
=
/root/CLI/
${
ORGCA_HOST
}
/
${
PEER_HOST
}
/msp
CORE_PEER_TLS_ROOTCERT_FILE
=
$CORE_PEER_TLS_ROOTCERT_FILE
peer chaincode invoke
-C
$CHANNEL_NAME
-n
$CHAINCODE_NAME
-c
$INVOKE_PARAMS
-o
${
ORDERER_HOST
}
:7050
--tls
--cafile
${
CORE_PEER_TLS_ROOTCERT_FILE
}
articonf-bank-chaincode/bank_chaincode/src/.eslintignore
0 → 100644
View file @
45230e05
#
# SPDX-License-Identifier: Apache-2.0
#
coverage
articonf-bank-chaincode/bank_chaincode/src/.eslintrc.js
0 → 100644
View file @
45230e05
/*
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'
;
module
.
exports
=
{
env
:
{
node
:
true
,
mocha
:
true
},
parserOptions
:
{
ecmaVersion
:
8
,
sourceType
:
'script'
},
extends
:
'eslint:recommended'
,
rules
:
{
indent
:
[
'error'
,
'tab'
],
'linebreak-style'
:
[
'error'
,
'unix'
],
quotes
:
[
'error'
,
'single'
],
semi
:
[
'error'
,
'always'
],
'no-unused-vars'
:
[
'error'
,
{
args
:
'none'
}],
'no-console'
:
'off'
,
curly
:
'error'
,
eqeqeq
:
'error'
,
'no-throw-literal'
:
'error'
,
strict
:
'error'
,
'no-var'
:
'error'
,
'dot-notation'
:
'error'
,
'no-trailing-spaces'
:
'error'
,
'no-use-before-define'
:
'error'
,
'no-useless-call'
:
'error'
,
'no-with'
:
'error'
,
'operator-linebreak'
:
'error'
,
yoda
:
'error'
,
'quote-props'
:
[
'error'
,
'as-needed'
]
}
};
articonf-bank-chaincode/bank_chaincode/src/index.js
0 → 100644
View file @
45230e05
/*
* Copyright IBM Corp. All Rights Reserved.
*
*
* SPDX-License-Identifier: Apache-2.0
*/
'use strict'
;
const
CC
=
require
(
'./lib/chaincode.js'
);
module
.
exports
.
CC
=
CC
;
module
.
exports
.
contracts
=
[
CC
];
articonf-bank-chaincode/bank_chaincode/src/lib/META-INF/statedb/couchdb/indexes/indexOwner.json
0 → 100644
View file @
45230e05
{
"index"
:{
"fields"
:[
"docType"
,
"owner"
]},
"ddoc"
:
"indexOwnerDoc"
,
"name"
:
"indexOwner"
,
"type"
:
"json"
}
articonf-bank-chaincode/bank_chaincode/src/lib/chaincode.js
0 → 100644
View file @
45230e05
/*
* Copyright IBM Corp. All Rights Reserved.
*
* SPDX-License-Identifier: Apache-2.0
*/
"use strict"
;
const
{
Contract
}
=
require
(
"fabric-contract-api"
);
class
bankChaincode
extends
Contract
{
async
InitLedger
(
ctx
)
{
const
assets
=
[
{
ID
:
"demo1"
,
Balance
:
1000
,
Type
:
"Initial Credit"
,
},
{
ID
:
"demo2"
,
Balance
:
100
,
Type
:
"Initial Credit"
,
},
];
for
(
const
asset
of
assets
)
{
asset
.
docType
=
"asset"
;
await
ctx
.
stub
.
putState
(
asset
.
ID
,
Buffer
.
from
(
JSON
.
stringify
(
asset
)));
console
.
info
(
`User
${
asset
.
ID
}
initialized`
);
}
}
// CreateAsset issues a new asset to the world state with given details.
async
CreateAsset
(
ctx
,
id
,
balance
,
type
)
{
const
asset
=
{
ID
:
id
,
Balance
:
balance
,
Type
:
type
,
};
return
ctx
.
stub
.
putState
(
id
,
Buffer
.
from
(
JSON
.
stringify
(
asset
)));
}
// ReadAsset returns the asset stored in the world state with given id.
async
ReadAsset
(
ctx
,
id
)
{
const
assetJSON
=
await
ctx
.
stub
.
getState
(
id
);
// get the asset from chaincode state
if
(
!
assetJSON
||
assetJSON
.
length
===
0
)
{
throw
new
Error
(
`The user
${
id
}
does not exist`
);
}
return
assetJSON
.
toString
();
}
// UpdateAsset updates an existing asset in the world state with provided parameters.
async
UpdateAsset
(
ctx
,
id
,
balance
,
type
)
{
const
exists
=
await
this
.
AssetExists
(
ctx
,
id
);
if
(
!
exists
)
{
throw
new
Error
(
`The user
${
id
}
does not exist`
);
}
// overwriting original asset with new asset
const
updatedAsset
=
{
ID
:
id
,
Balance
:
balance
,
Type
:
type
,
};
return
ctx
.
stub
.
putState
(
id
,
Buffer
.
from
(
JSON
.
stringify
(
updatedAsset
)));
}
// DeleteAsset deletes an given asset from the world state.
async
DeleteAsset
(
ctx
,
id
)
{
const
exists
=
await
this
.
AssetExists
(
ctx
,
id
);
if
(
!
exists
)
{
throw
new
Error
(
`The user
${
id
}
does not exist`
);
}
return
ctx
.
stub
.
deleteState
(
id
);
}
// AssetExists returns true when asset with given ID exists in world state.
async
AssetExists
(
ctx
,
id
)
{
const
assetJSON
=
await
ctx
.
stub
.
getState
(
id
);
return
assetJSON
&&
assetJSON
.
length
>
0
;
}
// TransferAsset updates the owner field of asset with given id in the world state.
async
TransferAsset
(
ctx
,
id
,
newOwner
)
{
const
assetString
=
await
this
.
ReadAsset
(
ctx
,
id
);
const
asset
=
JSON
.
parse
(
assetString
);
asset
.
Owner
=
newOwner
;
return
ctx
.
stub
.
putState
(
id
,
Buffer
.
from
(
JSON
.
stringify
(
asset
)));
}
// GetAsset returns the asset stored in the world state with given id.
async
GetAsset
(
ctx
,
id
)
{
const
assetJSON
=
await
ctx
.
stub
.
getState
(
id
);
// get the asset from chaincode state
if
(
!
assetJSON
||
assetJSON
.
length
===
0
)
{
throw
new
Error
(
`The user
${
id
}
does not exist`
);
}
return
assetJSON
;
}
// TransferAsset updates the owner field of asset with given id in the world state.
async
TransferBalance
(
ctx
,
from_id
,
to_id
,
amount
,
reason
)
{
const
from_asset_string
=
await
this
.
ReadAsset
(
ctx
,
from_id
);
const
to_asset_string
=
await
this
.
ReadAsset
(
ctx
,
to_id
);
let
from_asset
=
JSON
.
parse
(
from_asset_string
);
let
to_asset
=
JSON
.
parse
(
to_asset_string
);
console
.
log
(
"from_asset"
);
console
.
log
(
from_asset
);
console
.
log
(
"to_asset"
);
console
.
log
(
to_asset
);
let
from_balance
=
parseInt
(
from_asset
[
"Balance"
].
toString
());
let
to_balance
=
parseInt
(
to_asset
[
"Balance"
].
toString
());
let
transfer_amount
=
parseInt
(
amount
);
let
updated_from_balance
=
from_balance
-
transfer_amount
;
let
updated_to_balance
=
to_balance
+
transfer_amount
;
if
(
updated_from_balance
<
0
)
{
throw
new
Error
(
`The user
${
from_id
}
does not have sufficient balance`
);
}
else
{
await
this
.
UpdateAsset
(
ctx
,
from_id
,
updated_from_balance
,
"Debit - "
+
reason
);
await
this
.
UpdateAsset
(
ctx
,
to_id
,
updated_to_balance
,
"Credit - "
+
reason
);
}
}
// GetAssetHistory returns the chain of custody for an asset since issuance.
async
GetAssetHistory
(
ctx
,
assetName
)
{
let
resultsIterator
=
await
ctx
.
stub
.
getHistoryForKey
(
assetName
);
let
results
=
await
this
.
GetAllResults
(
resultsIterator
,
true
);
return
JSON
.
stringify
(
results
);
}
// GetAllAssets returns all assets found in the world state.
async
GetAllAssets
(
ctx
)
{
const
allResults
=
[];
// range query with empty string for startKey and endKey does an open-ended query of all assets in the chaincode namespace.
const
iterator
=
await
ctx
.
stub
.
getStateByRange
(
""
,
""
);
let
result
=
await
iterator
.
next
();
while
(
!
result
.
done
)
{
const
strValue
=
Buffer
.
from
(
result
.
value
.
value
.
toString
()).
toString
(
"utf8"
);
let
record
;
try
{
record
=
JSON
.
parse
(
strValue
);
}
catch
(
err
)
{
console
.
log
(
err
);
record
=
strValue
;
}
allResults
.
push
({
Key
:
result
.
value
.
key
,
Record
:
record
});
result
=
await
iterator
.
next
();
}
return
JSON
.
stringify
(
allResults
);
}
async
GetAllResults
(
iterator
,
isHistory
)
{
let
allResults
=
[];
let
res
=
await
iterator
.
next
();
while
(
!
res
.
done
)
{
if
(
res
.
value
&&
res
.
value
.
value
.
toString
())
{
let
jsonRes
=
{};
console
.
log
(
res
.
value
.
value
.
toString
(
"utf8"
));
if
(
isHistory
&&
isHistory
===
true
)
{
jsonRes
.
TxId
=
res
.
value
.
tx_id
;
jsonRes
.
Timestamp
=
res
.
value
.
timestamp
;
try
{
jsonRes
.
Value
=
JSON
.
parse
(
res
.
value
.
value
.
toString
(
"utf8"
));
}
catch
(
err
)
{
console
.
log
(
err
);
jsonRes
.
Value
=
res
.
value
.
value
.
toString
(
"utf8"
);
}
}
else
{
jsonRes
.
Key
=
res
.
value
.
key
;
try
{
jsonRes
.
Record
=
JSON
.
parse
(
res
.
value
.
value
.
toString
(
"utf8"
));
}
catch
(
err
)
{
console
.
log
(
err
);
jsonRes
.
Record
=
res
.
value
.
value
.
toString
(
"utf8"
);
}
}
allResults
.
push
(
jsonRes
);
}
res
=
await
iterator
.
next
();
}
iterator
.
close
();
return
allResults
;
}
}
module
.
exports
=
bankChaincode
;
articonf-bank-chaincode/bank_chaincode/src/package.json
0 → 100644
View file @
45230e05
{
"name"
:
"smart-bank-chaincode"
,
"version"
:
"1.0.0"
,
"description"
:
"smart bank chaincode implemented in node.js"
,
"main"
:
"index.js"
,
"engines"
:
{
"node"
:
">=12"
,
"npm"
:
">=5.3.0"
},
"scripts"
:
{
"start"
:
"fabric-chaincode-node start"
},
"engine-strict"
:
true
,
"license"
:
"Apache-2.0"
,
"dependencies"
:
{
"fabric-contract-api"
:
"^2.0.0"
,
"fabric-shim"
:
"^2.0.0"
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment