This tool allows Kaleido users to provision and manager the resources such as consortiums, memberships, environments and Quorum/Geth nodes.
Install Go: https://golang.org/doc/install
The follow are regular steps to set up a typical golang dev environment. If you are already familiar with this language you can skip to the next section.
- Decide a folder as your container for all golang projects, and set
GOPATH
environment variable to point to it more information in SettingGOPATH - Because We are using Go Modules you must work outside
GOPATH
- If working with Go 1.11 and 1.12 make sure to enable Go modules with
export GO111MODULE=on
go mod download
go test ./...
go build -o kld
The kld
command works similarly to the popular CLI tools like kubectl
which multiple levels of commands with help. Try these commands:
./kld
./kld -h
./kld create -h
./kld create consortium -h
To use the CLI to do something, such as create a consortium, you first need to provide the two pieces of required information, API URL and API Key. The tool supports configurations through files (yaml, json, toml formats are all supported), or environment variables.
Create a .kld.yaml
(or .kld.json or .kld.toml based on your preferences) file in the home directory and give these values:
api:
url: https://console.kaleido.io/api/v1
key: <your API Key>
The configuration file can be at any location and called by any name, you can tell the command where it is:
./kld --config /path/to/your/config.toml create consortium ...
You can also use environment variables. Use all capital letters with KLD_
as the prefix, for instance:
KLD_API_URL=http://console.kaleido.io/api/v1
KLD_API_KEY=blahblah
If the same configurations are specified in multiple places, this is the precedence order:
environment variables overrides config files specified in --config overrides .kld.<yaml/json/toml> in home directory
jimzhang$ ./kld create consortium -m single-org -n testConsortium234 -d "this is a test consortium" | jq
{
"name": "testConsortium234",
"description": "this is a test consortium",
"mode": "single-org",
"owner": "z4a5lhio",
"_id": "xmvsgnlg",
"state": "setup",
"_revision": "0",
"created_at": "2018-04-13T15:14:20.930Z",
"environment": {
"name": "Auto-generated Environment",
"description": "Initial Environment for testConsortium234",
"state": "live",
"region": "us-east",
"provider": "quorum",
"consensus_type": "raft",
"mode": "single-org",
"_id": "wgv4mdl4",
"node_list": [],
"release_id": "i05cs743",
"_revision": "0",
"created_at": "2018-04-13T15:14:20.956Z"
}
}
export KALEIDO_API=https://xxxx
export KALEIDO_API_KEY=xxxxx
go test ./kaleido
Optionally use go test -v ./kaleido
to view
all test logs.
First, create the .abi and .bin files for each contract from the .sol source code.
solc —abi <contract_name>.sol -o .`
solc —bin <contract_name>.sol -o .`
Then, run these commands to automatically create the .go contract binding methods using go-ethereum's template.go.
contracts/directory/abigen --abi Directory.abi --bin Directory.bin --pkg directory --out Directory.go
contracts/properties/abigen --abi Properties.abi --bin Properties.bin --pkg properties --out Properties.go