Skip to content

Instantly share code, notes, and snippets.

View mbwhite's full-sized avatar

Matthew B White mbwhite

View GitHub Profile
version=${FABRIC_VERSION:-2.5}
artifactory_url=hyperledger-fabric.jfrog.io
for image in peer orderer ca baseos ccenv tools; do
artifactory_image="${artifactory_url}/fabric-${image}:amd64-${version}-stable"
docker pull -q "${artifactory_image}"
docker tag "${artifactory_image}" "hyperledger/fabric-${image}"
docker rmi -f "${artifactory_image}" >/dev/null
done
@mbwhite
mbwhite / commands
Last active May 5, 2023 04:58
WSL2 - docker buildx
# start docker - this is a helper script created to start docker as wsl2 doesn't use systemd
docker-start
ping github.com
# why a ping here? emperiically I've determined this has to occur
# otherwise for me the docker daemon messes up dns.
# don't know why, ymmv
wget https://gist.githubusercontent.com/ArturKlauser/0f0293c62f5626df0261ac994d8a46af/raw/d5863dfc22e6d65fd912c9ec760dcdc86ea320cc/check-qemu-binfmt.sh
chmod +x check-qemu-binfmt.sh
@mbwhite
mbwhite / notes.md
Created August 8, 2022 09:17
Connecting VSCode to Multipass VM (Windows)
multipass launch --name fabric-dev --disk 80G --cpus 8 --mem 8G --cloud-init https://raw.githubusercontent.com/hyperledgendary/full-stack-asset-transfer-guide/main/infrastructure/multipass-cloud-config.yaml
  • Find out the IP address of the machines thats created - multipass list will show you this. For example
@mbwhite
mbwhite / For the version 2.2.4
Created September 15, 2021 08:29
Running Fabric-Samples
Clone the samples repo to a clean directory by
```
git clone https://github.com/hyperledger/fabric-samples.git
git checkout release-2.2 # <<< ONLY if you want to use the 2.2.4 release
```
OR if you've already cloned it
```
git clean -xdf
@mbwhite
mbwhite / notes.md
Created August 20, 2021 08:42
Package GoLang Fabric Contract for v14 & v2 peer

Scenario: You have a channel that is used withboth 1.4 and v2 Peers. Chaincode needs to be installed on both peers as a CDS file. How to create the CDS file that can be used by both peers?

Taking an example contract from Fabric-Samples, these are the tiles currently in the contract. Note that this MUST have the go.mod, The folder is chaindcode-go

 ls -lart chaincode-go
total 36
@mbwhite
mbwhite / versions.js
Created January 19, 2021 11:30
Very simple query of IBP using the node sdk
// Apache-2
// Import and IBP Node SDK, and also two cli helpers
const ibp = require('ibp-node-sdk');
const { table } = require('table');
const chalk = require('chalk');
// package JSON contains
// "chalk": "^4.1.0",
// "ibp-node-sdk": "^0.1.11",
@mbwhite
mbwhite / notes.md
Last active July 30, 2020 09:34
Building Node modules with native code with restricted/no internet connection

Scenario

No internet connection or limited. npm install will access npmjs to install node modules, any native modules will attempt to load the native modules that have been pre-built. This is defined the relavent package author's in each module's package.json.

However if there is no prebuilt binary available either because ones not defined, or the connection can not be established it will be rebuilt. This itself though will access the internet to get the node headers.

Steps to workaround this

0. Don't use native modules

If you can, but sometimes not practical or possible

@mbwhite
mbwhite / lifecycle.md
Last active June 25, 2020 09:51
Fabric Chaincode Lifecycle

Chaincode Package

The starting point of deploying a brand new chaincode starts with the chaincode package.

Irrespective of what language or api you have used to write your contract or chaincode, from the peer's perspective when deploying it can be considered a BLOB (Binary Object). Therefore the package is made up of your code (treated as a BLOB) and some metadata.

This metadata is a JSON file with

  • Code Path : for when the BLOG is unpacked where in the resulting directory tree the code is
  • Type : to indicate what type of builder is needed
@mbwhite
mbwhite / endorsmentpolicy.pegjs
Created April 29, 2020 12:55
Hyperledger Fabric: Parsing the Endorsement Policies
// Grammar for parsing of the Fabric Endorsment Policies
//
// Defined in the documentation at
// https://hyperledger-fabric.readthedocs.io/en/latest/endorsement-policies.html#endorsement-policy-syntax
// The expression will be an operator with arguments, each of the arguments can be an expression
// The OutOf operator is a bit different as that demands the first agument be a number
Expression
= op:Operator '(' _ args:Some_Expression_Args _ ')'
{
@mbwhite
mbwhite / ansible_setup.sh
Last active January 29, 2020 16:43
Using Ansible Playbooks for Hyperledger Fabric v2
# Download Fabric CLI
wget -q -P /tmp https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-linux-amd64-latest.tar.gz
sudo tar xzvf /tmp/hyperledger-fabric-linux-amd64-latest.tar.gz -C /usr/local
# Download Fabric-ca CLI
wget -q -P /tmp https://hyperledger.jfrog.io/hyperledger/fabric-binaries/hyperledger-fabric-ca-linux-amd64-latest.tar.gz
sudo tar xzvf /tmp/hyperledger-fabric-ca-linux-amd64-latest.tar.gz -C /usr/local
export FABRIC_CFG_PATH=/usr/local/config