Skip to content

Commit fd967a3

Browse files
committed
docs: update README.md to enhance project description and usage instructions
1 parent 3c0173f commit fd967a3

File tree

1 file changed

+201
-10
lines changed

1 file changed

+201
-10
lines changed

README.md

Lines changed: 201 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,208 @@
1-
What this project does:
1+
## About the Project
22

3-
1. Users use their account address and select the supported ways to make payments and the supported chains to make payments.
4-
2. Our contract will monitor the user's account after some time and check if the user has enough balance to make the payment.
5-
3. If the user has enough balance, the contract will take some amount of the user's balance and send it to the recipient's address.
6-
4. If the user does not have enough balance, the contract will rather check the second chain where user has enough balance and send the payment from that chain.
7-
5. If the user does not have enough balance in any of the chains, the contract will then notify the user about the insufficient balance.
3+
ChainSync is a subscription system where user can pay the subscription fee on different chains with the help of Chainlink CCIP.
84

9-
This is like a subscription service where the user can select the supported chains and supported ways to make payments and the contract will automatically make the payment from the user's account to the recipient's account.
5+
The user can decide which chain to pay the subscription fee on. => Primary payment chain and optional payment chain(s).
106

11-
- TBH, I think if there is not enough token on the optional chain, it will revert, but I just want to show the integration of those chainlink techniques.
7+
- if the user pays the subscription fee on the primary chain, which is where the `Subscription` contract is deployed, it will be simple payment process.
8+
- if the user pays the subscription fee on the optional chain, the payment process will be a bit complex. As shown below:
129

13-
---
10+
### Process of optional chain payment:
11+
12+
Role of each contract in the process:
1413

15-
## Process of optional chain payment:
14+
- `Subscription` contract: The contract where the user subscribes to the service.
15+
- `CheckBalance` contract: The contract which send an API request to the `Blockscout` service to check the balance of the user's token on the optional chain.
16+
- `Sender` contract: The contract which sends the cross-chain message to the `Receiver` contract on the optional chain.
17+
- `Receiver` contract: The contract which receives the cross-chain message from the `Sender` contract and do the actual transfer process.
18+
- `Relayer` contract: The contract which listens for `MessageReceived` event from the `Receiver` contract and sends another cross-chain message back to the `Subscription` contract to update the user's subscription status.
1619

1720
![Process of optional chain payment](img/optional_chain_payment_process.svg)
21+
22+
---
23+
24+
## Built With
25+
26+
- Solidity
27+
- OpenZeppelin
28+
- Foundry
29+
- Blockscout
30+
- Chainlink (CCIP, Functions, Automation)
31+
32+
## Getting Started
33+
34+
### Prerequisites
35+
36+
- [git](https://git-scm.com/book/en/v2/Getting-Started-Installing-Git)
37+
- You'll know you did it right if you can run `git --version` and you see a response like `git version x.x.x`
38+
- [foundry](https://getfoundry.sh/)
39+
- You'll know you did it right if you can run `forge --version` and you see a response like `forge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)`
40+
41+
### Quickstart
42+
43+
```
44+
git clone https://github.com/cqlyj/ChainSync.git
45+
cd ChainSync
46+
make
47+
```
48+
49+
## Usage
50+
51+
### Deployment sequence
52+
53+
1. First set up your environment variables in the `.env` file.
54+
55+
```
56+
cp .env.example .env
57+
```
58+
59+
2. In `Makefile`, update the `--account burner --sender 0xFB6a372F2F51a002b390D18693075157A459641F` to your own account.
60+
61+
```
62+
*** --account <your-account-name> --sender <your-account-address> ***
63+
```
64+
65+
3. In the `Subscription.sol` contract, update the `AMOY_SUBSCRIPTION_ID` variable to your own subscription ID of Chainlink functions. Also update those variables that are related to your own values, you can search those by inputting `@notice update` and update those values.
66+
67+
4. Follow the sequence below to deploy the contracts:
68+
69+
```
70+
71+
make deploy-sender
72+
make deploy-checkBalance
73+
make deploy-receiver
74+
make deploy-subscription
75+
make deploy-relayer
76+
77+
```
78+
79+
### Interacting with the contracts
80+
81+
Before interacting with the contracts, update those variables that are related to your own values in the script and then run the following commands:
82+
83+
```
84+
make add-consumer
85+
make add-linkTokenToReceiver
86+
make add-linkTokenToRelayer
87+
make add-linkTokenToSender
88+
make approve-receiverToSpendCCIPBNM
89+
make transfer-ownershipToSubscription
90+
make get-signedMessage
91+
```
92+
93+
Grab the signedMessage and update this in the `script/PaySubscriptionFeeForOptionalChain` contract.
94+
Set up your Chainlink Automation services and after everything is set up, run the following command:
95+
96+
```
97+
make pay-subscriptionFeeforOptionalChain
98+
```
99+
100+
You now have successfully paid the subscription fee on the optional chain.
101+
102+
## Testing
103+
104+
```
105+
forge test
106+
```
107+
108+
## Test Coverage
109+
110+
```
111+
forge coverage
112+
```
113+
114+
and for coverage based testing:
115+
116+
```
117+
forge coverage --report debug
118+
```
119+
120+
## Static Analysis
121+
122+
### Slither
123+
124+
```
125+
make slither
126+
```
127+
128+
### Aderyn
129+
130+
```
131+
make aderyn
132+
```
133+
134+
## How to Contribute
135+
136+
We welcome contributions to ChainSync! Here's how you can help:
137+
138+
### Types of Contributions
139+
140+
- **Bug Reports**: Open an issue describing the bug, including steps to reproduce, expected behavior, and actual behavior
141+
- **Feature Requests**: Submit an issue describing the new feature and its potential benefits
142+
- **Code Contributions**: Submit pull requests for bug fixes or new features
143+
- **Documentation**: Help improve or translate our documentation
144+
- **Testing**: Add more test cases or help identify test coverage gaps
145+
146+
### Development Process
147+
148+
1. Fork the repository and create your branch from `main`:
149+
150+
```
151+
git checkout -b feature/your-feature-name
152+
```
153+
154+
2. If you've added code, add tests that cover your changes:
155+
156+
```
157+
forge test
158+
```
159+
160+
3. Ensure your code follows the project's style guidelines:
161+
162+
```
163+
make slither
164+
make aderyn
165+
```
166+
167+
4. Make sure all tests pass:
168+
169+
```
170+
forge coverage
171+
```
172+
173+
5. Update the documentation if necessary
174+
175+
### Pull Request Process
176+
177+
1. Update the README.md with details of changes if applicable
178+
2. Follow the existing code style and formatting
179+
3. Include comments in your code where necessary
180+
4. Add or update tests for any new functionality
181+
5. Reference any relevant issues in your PR description
182+
6. The PR must pass all CI checks and receive approval from a maintainer
183+
184+
### Commit Guidelines
185+
186+
- Use clear and meaningful commit messages
187+
- Reference issue numbers in commit messages when applicable
188+
- Keep commits focused on single changes
189+
- Use present tense ("Add feature" not "Added feature")
190+
191+
### Code of Conduct
192+
193+
- Be respectful and inclusive in your interactions
194+
- Focus on constructive feedback
195+
- Help maintain a positive environment for all contributors
196+
197+
### Questions or Need Help?
198+
199+
Feel free to reach out if you have questions or need guidance:
200+
201+
- Open a GitHub issue for project-related questions
202+
- Contact Luo Yingjie at [[email protected]]([email protected]) for other inquiries
203+
204+
Your contributions help make ChainSync better for everyone. Thank you for your interest in contributing!
205+
206+
## License
207+
208+
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

0 commit comments

Comments
 (0)