1. 电子存证合约

代码样例参看:contractsdk/go/example/eleccert.go

1.1. 电子存证合约简介

电子存证应用主要是通过区块链解决的存证中的信任问题,而存证合约只需做简单的读写操作即可

1.2. 电子存证合约具备的读写操作

  • 通过invoke方法,put存证到区块链
  • 通过query方法,get存证

1.3. 调用json文件示例

Invoke

./xchain-cli native invoke -a ‘下面json中args字段的内容’ —method save -H localhost:37101 eleccert

  1. {
  2. "module_name": "native", // native or wasm
  3. "contract_name": "eleccert", // contract name
  4. "method_name": "invoke", // invoke or query
  5. "args": {
  6. "owner": "aaa", // user name
  7. "filehash": "存证文件的hash值",
  8. "timestamp": "存证的timestamp"
  9. }
  10. }

Query

./xchain-cli native query -a ‘args内容’ —method query -H localhost:37101 eleccert

  1. {
  2. "module_name": "native", // native or wasm
  3. "contract_name": "eleccert", // contract name
  4. "method_name": "query", // invoke or query
  5. "args": {
  6. "owner": "aaa", // user name
  7. "filehash": "文件hash值"
  8. }
  9. }
  10. // output
  11. {
  12. "filehash": "文件hash值",
  13. "timestamp": "文件存入timestamp"
  14. }