- Write your definition of the object model and the services that are required from the Smart Contract. This is using the protobuf syntax, using the additional options/attributes that provide fine grained control
- Decide on what language you want to use for the contract implementation. Choices are Java, Go, JavaScript, TypeScript, Rust
- Decide on what langauges you want to use for the client implementations
- Generate the resources for the contract and client implementations. Starting point is the proto definitions (a)
- Fill out the code, and deploy
- .... repeat
(a) You can also start with the Contract Metadata JSON description. This is harder to read, but is more easily parsed and modified by tooling and the implementation libraries. It is akin to the 'intermediate representation' in a standard development tool chain.
The resource generator is a CLI that can be run either standalone or as a protoc plugin.
- Ensure that you have protoc installed
npm install -g fabric-resource-generator
(if you've clone this repo instead usenpm run build && npm link
)- Create a new directory to hold the protobufs. You need to have some of the google protobuf files to hand, and also the Fabric contract extensions.
As an example copy the
examples
directory in this repo (TODO script this....) - Let's work with the
my-contract.proto
protoc \
--plugin=protoc-fabric-gen \
-I ./proto \
./proto/my-contract.proto \
--metadata_out=json=y,js=y,ts=y:./generated
This will generate the json metadata, js resources, and ts resources