ChainSync is a subscription system where user can pay the subscription fee on different chains with the help of Chainlink CCIP.
The user can decide which chain to pay the subscription fee on. => Primary payment chain and optional payment chain(s).
- 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. - if the user pays the subscription fee on the optional chain, the payment process will be a bit complex. As shown below:
Role of each contract in the process:
Subscription
contract: The contract where the user subscribes to the service.CheckBalance
contract: The contract which send an API request to theBlockscout
service to check the balance of the user's token on the optional chain.Sender
contract: The contract which sends the cross-chain message to theReceiver
contract on the optional chain.Receiver
contract: The contract which receives the cross-chain message from theSender
contract and do the actual transfer process.Relayer
contract: The contract which listens forMessageReceived
event from theReceiver
contract and sends another cross-chain message back to theSubscription
contract to update the user's subscription status.
- Solidity
- OpenZeppelin
- Foundry
- Blockscout
- Chainlink (CCIP, Functions, Automation)
- git
- You'll know you did it right if you can run
git --version
and you see a response likegit version x.x.x
- You'll know you did it right if you can run
- foundry
- You'll know you did it right if you can run
forge --version
and you see a response likeforge 0.2.0 (816e00b 2023-03-16T00:05:26.396218Z)
- You'll know you did it right if you can run
git clone https://github.com/cqlyj/ChainSync.git
cd ChainSync
make
- First set up your environment variables in the
.env
file.
cp .env.example .env
- In
Makefile
, update the--account burner --sender 0xFB6a372F2F51a002b390D18693075157A459641F
to your own account.
*** --account <your-account-name> --sender <your-account-address> ***
-
In the
Subscription.sol
contract, update theAMOY_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. -
Follow the sequence below to deploy the contracts:
make deploy-sender
make deploy-checkBalance
make deploy-receiver
make deploy-subscription
make deploy-relayer
Before interacting with the contracts, update those variables that are related to your own values in the script and then run the following commands:
make add-consumer
make add-linkTokenToReceiver
make add-linkTokenToRelayer
make add-linkTokenToSender
make approve-receiverToSpendCCIPBNM
make transfer-ownershipToSubscription
make get-signedMessage
Grab the signedMessage and update this in the script/PaySubscriptionFeeForOptionalChain
contract.
Set up your Chainlink Automation services and after everything is set up, run the following command:
make pay-subscriptionFeeforOptionalChain
You now have successfully paid the subscription fee on the optional chain.
forge test
forge coverage
and for coverage based testing:
forge coverage --report debug
make slither
make aderyn
We welcome contributions to ChainSync! Here's how you can help:
- Bug Reports: Open an issue describing the bug, including steps to reproduce, expected behavior, and actual behavior
- Feature Requests: Submit an issue describing the new feature and its potential benefits
- Code Contributions: Submit pull requests for bug fixes or new features
- Documentation: Help improve or translate our documentation
- Testing: Add more test cases or help identify test coverage gaps
-
Fork the repository and create your branch from
main
:git checkout -b feature/your-feature-name
-
If you've added code, add tests that cover your changes:
forge test
-
Ensure your code follows the project's style guidelines:
make slither make aderyn
-
Make sure all tests pass:
forge coverage
-
Update the documentation if necessary
- Update the README.md with details of changes if applicable
- Follow the existing code style and formatting
- Include comments in your code where necessary
- Add or update tests for any new functionality
- Reference any relevant issues in your PR description
- The PR must pass all CI checks and receive approval from a maintainer
- Use clear and meaningful commit messages
- Reference issue numbers in commit messages when applicable
- Keep commits focused on single changes
- Use present tense ("Add feature" not "Added feature")
- Be respectful and inclusive in your interactions
- Focus on constructive feedback
- Help maintain a positive environment for all contributors
Feel free to reach out if you have questions or need guidance:
- Open a GitHub issue for project-related questions
- Contact Luo Yingjie at [email protected] for other inquiries
Your contributions help make ChainSync better for everyone. Thank you for your interest in contributing!
This project is licensed under the MIT License - see the LICENSE file for details.