Skip to content

Commit 4a9f64a

Browse files
committed
feat: update Readme
Signed-off-by: sparkzky <sparkhhhhhhhhhh@outlook.com>
1 parent aaf6ed1 commit 4a9f64a

1 file changed

Lines changed: 139 additions & 78 deletions

File tree

README.md

Lines changed: 139 additions & 78 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,167 @@
1-
# CosmWasm Starter Pack
1+
# 学术研究数据管理与DAO治理智能合约
22

3-
This is a template to build smart contracts in Rust to run inside a
4-
[Cosmos SDK](https://github.com/cosmos/cosmos-sdk) module on all chains that enable it.
5-
To understand the framework better, please read the overview in the
6-
[cosmwasm repo](https://github.com/CosmWasm/cosmwasm/blob/master/README.md),
7-
and dig into the [cosmwasm docs](https://www.cosmwasm.com).
8-
This assumes you understand the theory and just want to get coding.
3+
这是一个基于CosmWasm构建的学术研究数据管理和去中心化自治组织(DAO)治理智能合约。该合约结合了NFT技术、数据版本控制、学术论文发布和DAO治理机制,为学术研究社区提供了一个完整的去中心化数据管理解决方案。
94

10-
## Creating a new repo from template
5+
## 项目特性
116

12-
Assuming you have a recent version of rust and cargo (v1.58.1+) installed
13-
(via [rustup](https://rustup.rs/)),
14-
then the following should get you a new repo to start a contract:
7+
### 核心功能
8+
- **研究数据NFT化**: 将研究数据转换为NFT,确保数据所有权和可追溯性
9+
- **版本控制**: 支持数据版本管理,记录每次更新的历史
10+
- **访问权限管理**: 灵活的权限控制系统,支持公开/私有数据访问
11+
- **学术论文发布**: 专门的学术论文创建和管理功能
12+
- **引用系统**: 内置的论文引用机制,支持引用费用分配
1513

16-
Install [cargo-generate](https://github.com/ashleygwilliams/cargo-generate) and cargo-run-script.
17-
Unless you did that before, run this line now:
18-
19-
```sh
20-
cargo install cargo-generate --features vendored-openssl
21-
cargo install cargo-run-script
22-
```
23-
24-
Now, use it to create your new contract.
25-
Go to the folder in which you want to place it and run:
14+
### DAO治理功能
15+
- **提案系统**: 支持文章发布、成员管理、配置更新等多种提案类型
16+
- **投票机制**: 基于成员身份的投票系统,支持是/否/弃权投票
17+
- **自动执行**: 提案通过后可自动执行相应操作
18+
- **成员管理**: 动态的DAO成员添加和移除机制
19+
- **配置管理**: 可通过治理流程调整DAO参数
2620

21+
### 经济模型
22+
- **引用费用**: 论文引用需要支付费用,95%给作者,5%给DAO
23+
- **数据访问费用**: 私有数据访问需要支付设定的费用
24+
- **灵活定价**: 数据所有者可自由设定访问价格
2725

28-
**Latest: 1.0.0-beta6**
26+
## 代码结构
2927

30-
```sh
31-
cargo generate --git https://github.com/CosmWasm/cw-template.git --name PROJECT_NAME
32-
````
33-
34-
**Older Version**
28+
```
29+
src/
30+
├── lib.rs # 库入口文件,模块声明
31+
├── contract.rs # 主合约逻辑,包含所有执行和查询函数
32+
├── msg.rs # 消息定义,包含执行消息、查询消息和响应结构
33+
├── state.rs # 状态存储定义,定义所有存储项和映射
34+
├── error.rs # 错误类型定义
35+
├── helpers.rs # 辅助函数,包含DAO治理相关的验证和检查函数
36+
└── integration_tests.rs # 集成测试,覆盖主要功能流程
37+
38+
schema/ # JSON Schema文件
39+
├── execute_msg.json # 执行消息schema
40+
├── query_msg.json # 查询消息schema
41+
├── instantiate_msg.json # 初始化消息schema
42+
└── ... # 其他响应类型schema
43+
44+
examples/
45+
└── schema.rs # Schema生成示例
46+
47+
artifacts/ # 编译产物
48+
├── bc.wasm # 编译后的WASM文件
49+
└── checksums.txt # 校验和文件
50+
```
3551

36-
Pass version as branch flag:
52+
### 核心模块说明
53+
54+
#### contract.rs
55+
主合约逻辑文件,包含:
56+
- `instantiate`: 合约初始化,设置基础参数和DAO配置
57+
- `execute`: 处理所有执行消息,包括数据管理、NFT操作、DAO治理等
58+
- `query`: 处理所有查询请求,提供数据访问接口
59+
60+
主要执行函数:
61+
- 数据管理: `execute_create_data_item`, `execute_update_data_item`, `execute_freeze_data`
62+
- 权限管理: `execute_grant_access`, `execute_request_access`
63+
- 论文管理: `execute_create_paper_item`, `execute_cite_paper`, `execute_submit_correction`
64+
- DAO治理: `execute_submit_*_proposal`, `execute_vote_on_proposal`, `execute_proposal`
65+
66+
#### msg.rs
67+
消息和数据结构定义:
68+
- `ExecuteMsg`: 所有执行操作的消息枚举
69+
- `QueryMsg`: 所有查询操作的消息枚举
70+
- `DataItem`: 研究数据项结构
71+
- `Proposal`: DAO提案结构
72+
- `DaoConfig`: DAO配置参数
73+
- 各种响应结构体
74+
75+
#### state.rs
76+
状态存储定义:
77+
- 基础存储: 合约信息、Token计数器
78+
- NFT存储: Token所有权、批准关系
79+
- 数据存储: 数据项、版本历史、访问控制
80+
- 论文存储: 引用记录、DOI映射
81+
- DAO存储: 成员列表、提案、投票记录
82+
83+
#### helpers.rs
84+
DAO治理辅助函数:
85+
- 成员身份验证: `is_dao_member`, `ensure_dao_member`
86+
- 提案状态管理: `ensure_proposal_exists`, `can_vote_on_proposal`
87+
- 时间验证: `is_proposal_expired`, `validate_voting_period`
88+
- 配置验证: `validate_dao_config`
89+
90+
#### error.rs
91+
自定义错误类型:
92+
- 基础错误: `Unauthorized`, `TokenNotFound`, `InsufficientPayment`
93+
- DAO错误: `NotDaoMember`, `ProposalNotFound`, `VotingPeriodActive`
94+
95+
## 环境设置
96+
97+
### rust环境
98+
```
99+
rustc 1.87.0 (17067e9ac 2025-05-09)
100+
binary: rustc
101+
commit-hash: 17067e9ac6d7ecb70e50f92c1944e545188d2359
102+
commit-date: 2025-05-09
103+
host: x86_64-unknown-linux-gnu
104+
release: 1.87.0
105+
LLVM version: 20.1.1
106+
```
37107

108+
### 编译合约
38109
```sh
39-
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch <version> --name PROJECT_NAME
40-
````
110+
# 开发编译
111+
make build
41112

42-
Example:
113+
# 优化编译(用于部署)
114+
make artifacts
115+
```
43116

117+
### 运行测试
44118
```sh
45-
cargo generate --git https://github.com/CosmWasm/cw-template.git --branch 0.16 --name PROJECT_NAME
119+
# 集成测试
120+
make test
46121
```
47122

48-
You will now have a new folder called `PROJECT_NAME` (I hope you changed that to something else)
49-
containing a simple working contract and build system that you can customize.
50-
51-
## Create a Repo
52-
53-
After generating, you have a initialized local git repo, but no commits, and no remote.
54-
Go to a server (eg. github) and create a new upstream repo (called `YOUR-GIT-URL` below).
55-
Then run the following:
56-
123+
### 生成Schema
57124
```sh
58-
# this is needed to create a valid Cargo.lock file (see below)
59-
cargo check
60-
git branch -M main
61-
git add .
62-
git commit -m 'Initial Commit'
63-
git remote add origin YOUR-GIT-URL
64-
git push -u origin main
125+
make schema
65126
```
66127

67-
## CI Support
68-
69-
We have template configurations for both [GitHub Actions](.github/workflows/Basic.yml)
70-
and [Circle CI](.circleci/config.yml) in the generated project, so you can
71-
get up and running with CI right away.
128+
## 部署和使用
72129

73-
One note is that the CI runs all `cargo` commands
74-
with `--locked` to ensure it uses the exact same versions as you have locally. This also means
75-
you must have an up-to-date `Cargo.lock` file, which is not auto-generated.
76-
The first time you set up the project (or after adding any dep), you should ensure the
77-
`Cargo.lock` file is updated, so the CI will test properly. This can be done simply by
78-
running `cargo check` or `cargo unit-test`.
130+
### 本地测试网部署
131+
1. 创建`injective`账号
132+
2. 编译合约: `make artifacts`
133+
3. 部署合约到测试网
134+
4. 初始化合约参数
79135

80-
## Using your project
136+
### Injective Testnet (最新部署 - 2025-07-25)
137+
`hash`: `inj1ntm3dlcagyvdk2p3cq9mwgmc7njes2n0n6uayy
138+
`
139+
### 主要使用流程
81140

82-
Once you have your custom repo, you should check out [Developing](./Developing.md) to explain
83-
more on how to run tests and develop code. Or go through the
84-
[online tutorial](https://docs.cosmwasm.com/) to get a better feel
85-
of how to develop.
141+
1. **初始化DAO**: 合约部署时自动创建DAO,部署者成为首个成员
142+
2. **创建研究数据**: 研究者可以创建数据NFT,设置访问权限和价格
143+
3. **发布学术论文**: 通过DAO提案流程发布学术论文
144+
4. **数据访问**: 其他用户可以请求访问数据,支付相应费用
145+
5. **论文引用**: 引用论文时支付引用费用,自动分配给作者和DAO
146+
6. **DAO治理**: 成员可以提交各类提案,通过投票决定DAO事务
86147

87-
[Publishing](./Publishing.md) contains useful information on how to publish your contract
88-
to the world, once you are ready to deploy it on a running blockchain. And
89-
[Importing](./Importing.md) contains information about pulling in other contracts or crates
90-
that have been published.
148+
## 技术特点
91149

92-
Please replace this README file with information about your specific project. You can keep
93-
the `Developing.md` and `Publishing.md` files as useful referenced, but please set some
94-
proper description in the README.
150+
- **模块化设计**: 清晰的模块分离,便于维护和扩展
151+
- **完整的测试覆盖**: 包含单元测试和集成测试
152+
- **灵活的权限系统**: 支持多级访问控制
153+
- **自动化治理**: 提案自动执行机制
154+
- **经济激励**: 内置的费用分配和激励机制
95155

96-
## Gitpod integration
156+
## 贡献指南
97157

98-
[Gitpod](https://www.gitpod.io/) container-based development platform will be enabled on your project by default.
158+
欢迎提交Issue和Pull Request。在贡献代码前,请确保:
159+
1. 运行所有测试通过
160+
2. 代码符合Rust编码规范
161+
3. 添加必要的测试用例
162+
4. 更新相关文档
99163

100-
Workspace contains:
101-
- **rust**: for builds
102-
- [wasmd](https://github.com/CosmWasm/wasmd): for local node setup and client
103-
- **jq**: shell JSON manipulation tool
164+
## 许可证
104165

105-
Follow [Gitpod Getting Started](https://www.gitpod.io/docs/getting-started) and launch your workspace.
166+
本项目采用开源许可证,具体信息请查看LICENSE文件。
106167

0 commit comments

Comments
 (0)