-
Notifications
You must be signed in to change notification settings - Fork 256
Case food traceability
[TOC]
Use the Solidity compiler to compile contract, the following tools are available :
Create a new solidity contract, and select the compiler version to compile.
Once compiled, the ABI and Bytecode can be used to create contracts.
-
ABI generated by remix has characters such as newline, whitespace, etc. Chain33 EVM cannot use it directly, and further formatting is required: remove line breaks and whitespace.
-
Chrome does not support copying compiled abi or bin file, so try to use Edge or Internet explorer.
Considering these two points, it is recommended to use Intellij-Solidity plug-ins for compilation.
NOTE:
- When defining a struct in a contract:
- Do not define too many elements, or the compiler will declare exception Stack too deep.
- Do not use nested struct; currently the EVM virtual machine implemented internally by Chain33 does not support nested struct type.
Open IntelliJ IDEA, in File->Settings->Plugins, find IntelliJ-Solidity to install。
If no geth node is installed locally, you can get the official compiled version of Chain33 directly or use code to compile locally. Otherwise you can use node build-in Solc directly.
Get the latest code to compile, github address: [email protected]:ethereum/solidity.git
Specific installation process refer to Official Document
windows: https://bty.oss-ap-southeast-1.aliyuncs.com/solc/solc_0.5.5-windows.zip
linux: https://bty.oss-ap-southeast-1.aliyuncs.com/solc/solc_0.5.5-linux.tar.gz
macOS: https://bty.oss-ap-southeast-1.aliyuncs.com/solc/solc_0.5.5-macOS.tar.gz
Use Build->Compile Solidity to compile contract, the compiled results can be seen in the project bar.
Use the generated abi, bin files for contract creation.
For details see HERE
To realize a food traceability process is to achieve the origin, production, circulation and other links of traceability.
The actual traceability is a very complicated process, which is reduced to the following steps: farm, food factory, supermarket, food quality inspection department, and user. Properties of the product, take live pigs as an example.
Cattle ranches selling
Batch Number | Name | Weight | Date | Origin |
---|---|---|---|---|
00001 | pig001 | 500 | 20190221 | NanJing |
Food factory production (for example, ham)
Food number(such as QR code) | Name | Weight | Production Date | Packing Date | Expiration Date | Pork Batch |
---|---|---|---|---|---|---|
001 | food001 | 500 | 20190215 | 20190220 | 20210215 | 00001 |
Food quality inspection department sampling
Food number(such as QR code) | Test Time | Test Results | Test Instructions |
---|---|---|---|
food001 | 20190226 | Qualified | The food is good. |
Food number(such as QR code) | Last Date |
---|---|
food001 | 20190304 |
Food number(such as QR code) | User Rating |
---|---|
food001 | 90 |
hello world