Skip to content

Commit cd2b013

Browse files
authored
merge release/20250308 into main (#84)
2 parents 68eba03 + 340f7fa commit cd2b013

File tree

88 files changed

+7227
-4804
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+7227
-4804
lines changed

.doc/content.md

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Content
2+
3+
## Technical Overview
4+
5+
* [Contracts Overview](./technical-overview/overview.md)
6+
* [Contracts Details](./technical-overview/contracts-details.md)
7+
8+
## Development
9+
10+
* [Development Guidelines](./development/development-guidelines.md)
11+
12+
## Deployment
13+
14+
* [Deploy Guidelines](./deployment/deployment-guidelines.md)
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
# Deployment Guidelines
2+
3+
## Contracts Deployment
4+
5+
Find contract deployment addresses by network at these links:
6+
7+
- USDT 0xFd086bC7CD5C481DCC9C85ebE478A1C0b69FCbb9
8+
- USDC (Circle): [Circle Contracts Addresses](https://www.circle.com/blog/usdc-on-arbitrum-now-available)
9+
- WETH: [Arbitrum Contract Addresses](https://docs.arbitrum.io/build-decentralized-apps/reference/contract-addresses)
10+
- Uniswap Swap Router: [Uniswap Contract Deployments](https://docs.uniswap.org/contracts/v3/reference/deployments/polygon-deployments)
11+
- EntryPoint: [eth Infinitism - Account Abstraction](https://github.com/eth-infinitism/account-abstraction/releases/tag/v0.6.0)
12+
13+
14+
## Paymaster Deployment
15+
16+
### Post-Deployment
17+
18+
After deploying a new Paymaster contract, you **MUST** perform the staking process to deposit ETH into the StakeManager of the EntryPoint. This step is essential for security purposes and is validated by the bundler to ensure the proper operation of the Paymaster contract. 🛡️
19+
20+
This is a critical step that you **cannot skip** after deployment. Failure to stake the required ETH will result in the bundler failing to validate the contract, and your transactions may not work correctly! 🚨
21+
22+
#### **How to Stake:**
23+
24+
1. **Run the following command to stake ETH in the Paymaster contract:**
25+
26+
```sh
27+
cast send paymaster_contract_address "addStake(uint32)" 100000 --value 100000000000000000 --from backend_signer_wallet_address --rpc-url https://arb-sepolia.g.alchemy.com/v2/API_KEY_ALCHEMY --private-key _backend_signer_wallet_private_key
28+
```
29+
30+
- `100000` represents the amount of seconds of unstake time.
31+
- `100000000000000000` equals **0.1 ETH** to be staked.
32+
33+
**Important Notes:**
34+
- Make sure you have enough ETH in the backend signer wallet to cover the stake.
35+
- The staking process is required for security validation and interaction with the EntryPoint.
36+
37+
2. **To check the balance and verify the stake:**
38+
39+
```sh
40+
cast call entrypoint_contract_address "getDepositInfo(address)(uint112,bool,uint112,uint32,uint48)" paymaster_contract_address --rpc-url https://arb-sepolia.g.alchemy.com/v2/API_KEY_ALCHEMY
41+
```
42+
43+
This will return the deposit information, including the amount of staked ETH and other relevant details.
44+
45+
#### **Why Is This Important?**
46+
47+
- **Security:** The bundler validates this stake to ensure that the Paymaster contract can be used safely and securely within the ecosystem. 🛡️
48+
- **Smooth Operations:** Without this staking, the contract will not pass bundler validation and operations will fail. ⚠️
49+
50+
#### **Additional Notes on StakeManager & Bundler**
51+
52+
The **StakeManager** within the EntryPoint is responsible for managing the ETH deposits that cover gas costs for Paymaster operations. By staking ETH in the StakeManager, you are essentially providing a guarantee that there are sufficient funds to pay for transaction fees. This step is critical for the bundler to validate and process transactions that the Paymaster is handling.
53+
54+
The **bundler** is a service that aggregates multiple transactions and ensures that gas is paid in an efficient manner. Without proper staking, the bundler will not validate the transactions, and the system will fail to function as intended.
55+
56+
Make sure you complete this step right after the Paymaster deployment, as it is a necessary part of the contract initialization. ✅

.doc/development/coding-guidelines.md

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Coding guidelines
2+
3+
## Configuring Git's line ending handling
4+
5+
This cofniguration converts LF to CRLF when checking out in Windows systems and CRLF to LF when committing.
6+
7+
```sh
8+
# Global Configuration: Applies the settings to all repositories on your system.
9+
git config --global core.autocrlf true
10+
```
11+
12+
```sh
13+
# Local Configuration: Applies the settings only to the current repository.
14+
git config core.autocrlf true
15+
```
16+
17+
18+
## Commit changes
19+
20+
It is recommended to use a linter for commit messages, which should be specified in the following format:
21+
22+
```sh
23+
- [type] message
24+
- [type] :icono: message
25+
```
26+
27+
Example:
28+
29+
```sh
30+
- commit -m [chore] add commitlinter
31+
- commit -m [chore] :sparkles: add commitlinter (to commit with an icon, you can use [gitmoji](https://gitmoji.dev/))
32+
```
33+
34+
The allowed standard types are:
35+
36+
```sh
37+
- feat: A new feature for the user.
38+
- fix: Fixes a bug that affects the user.
39+
- perf: Changes that improve site performance.
40+
- build: Changes in the build system, deployment tasks, or installation.
41+
- ci: Changes in continuous integration.
42+
- docs: Changes in documentation.
43+
- refactor: Code refactoring such as variable or function name changes.
44+
- style: Changes in formatting, tabs, spaces, or semicolons, etc.; do not affect the user.
45+
- test: Adds tests or refactors an existing one.
46+
- chore: Other changes that don't modify src or test files.
47+
- revert: Reverts a previous commit.
48+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,146 @@
1+
# ChatterPay Contracts Details
2+
3+
## 1. [**ChatterPay.sol**](../../src/ChatterPay.sol)
4+
5+
### **High-Level Overview**:
6+
The `ChatterPay` contract serves as the core of the ChatterPay ecosystem, acting as a smart wallet implementation that supports ERC-4337 account abstraction. It facilitates token transfers, fee management, Uniswap-based token swaps, and integration with price oracles for real-time token valuation.
7+
8+
### **Key Features**:
9+
- **ERC-4337 Account Abstraction**: Supports user operations via the EntryPoint contract, enabling decentralized transaction validation.
10+
- **Fee Management**: Implements a fee structure in USD cents, with customizable pool fees and slippage for token swaps.
11+
- **Uniswap V3 Integration**: Executes token swaps with single-hop or multi-hop routes and customizable price tolerances.
12+
- **Token Whitelisting and Price Feeds**: Allows only whitelisted tokens to be used, with price feeds from Chainlink oracles.
13+
- **Batch Transfers**: Supports multiple token transfers in a single transaction.
14+
- **Upgradeable**: Built using `UUPSUpgradeable` for future enhancements.
15+
16+
### **Relations with Other ChatterPay Contracts**:
17+
- **ChatterPayPaymaster**: Works alongside the Paymaster to manage fees and user operations.
18+
- **ChatterPayVault**: Can interact with the vault for secure asset storage and retrieval.
19+
- **ChatterPayWalletFactory**: Deployed wallets are created and managed by the factory contract.
20+
21+
### **External Contract Interactions**:
22+
- **Uniswap V3 Router**: Interacts with the swap router for token exchanges.
23+
- **Chainlink Oracles**: Retrieves token prices to calculate fees and ensure transaction accuracy.
24+
25+
---
26+
27+
## 2. [**ChatterPayNFT.sol**](../../src/ChatterPayNFT.sol)
28+
29+
### **High-Level Overview**:
30+
The `ChatterPayNFT` contract enables the minting and management of both original NFTs and their limited copies. It incorporates robust features for URI management, copy limits, and upgradeability.
31+
32+
### **Key Features**:
33+
- **ERC721 NFTs**: Implements the ERC721 standard for unique digital assets.
34+
- **Original and Copy NFTs**: Allows the creation of original NFTs and associated copies with defined limits.
35+
- **Base URI Management**: Supports dynamic updates to the base URI by the contract owner.
36+
- **Upgradeable**: Built using `UUPSUpgradeable` for seamless updates.
37+
38+
### **Relations with Other ChatterPay Contracts**:
39+
- **ChatterPay**: NFTs can be linked to wallet activities for rewards or asset tracking.
40+
- **ChatterPayVault**: Original and copy NFTs may serve as collateral or proof of ownership within the vault.
41+
42+
### **External Contract Interactions**:
43+
- **ERC721URIStorage**: Provides extended functionality for metadata management.
44+
45+
---
46+
47+
## 3. [**ChatterPayPaymaster.sol**](../../src/ChatterPayPaymaster.sol)
48+
49+
### **High-Level Overview**:
50+
The `ChatterPayPaymaster` contract validates and manages user operations in collaboration with the EntryPoint contract. It uses signature-based authentication to ensure secure and authorized transactions.
51+
52+
### **Key Features**:
53+
- **Paymaster Role**: Acts as a trusted intermediary to sponsor transaction costs for users.
54+
- **Signature Validation**: Ensures operations are authorized via backend-signed messages.
55+
- **Fee Management**: Integrates seamlessly with the `ChatterPay` wallet for fee processing.
56+
- **Upgradeable**: Can be enhanced with new functionalities over time.
57+
58+
### **Relations with Other ChatterPay Contracts**:
59+
- **ChatterPay**: Handles operation validation and fee sponsorship for the wallet contract.
60+
61+
### **External Contract Interactions**:
62+
- **EntryPoint**: Collaborates with the EntryPoint contract for operation validation.
63+
64+
---
65+
66+
## 4. [**ChatterPayVault.sol**](../../src/ChatterPayVault.sol)
67+
68+
### **High-Level Overview**:
69+
The `ChatterPayVault` contract serves as a secure storage mechanism for password-protected commitments. It supports the reservation, redemption, and cancellation of payments.
70+
71+
### **Key Features**:
72+
- **Password-Protected Payments**: Uses hashed passwords for added security in transactions.
73+
- **Commitment Expiration**: Ensures timely redemption or cancellation of commitments.
74+
- **ERC20 Integration**: Handles token-based payments securely.
75+
76+
### **Relations with Other ChatterPay Contracts**:
77+
- **ChatterPay**: Interacts with the main wallet for secure payment and asset management.
78+
- **ChatterPayNFT**: Supports NFTs as collateral or proof of ownership.
79+
80+
### **External Contract Interactions**:
81+
- **ERC20**: Facilitates secure token transfers within the vault.
82+
83+
---
84+
85+
## 5. [**ChatterPayWalletFactory.sol**](../../src/ChatterPayWalletFactory.sol)
86+
87+
### **High-Level Overview**:
88+
The `ChatterPayWalletFactory` contract is responsible for deploying and managing wallet proxies for users. It leverages deterministic address computation for predictable wallet creation.
89+
90+
### **Key Features**:
91+
- **Wallet Proxy Creation**: Deploys upgradeable wallet proxies using the ERC1967 standard.
92+
- **Proxy Tracking**: Maintains a record of all deployed wallet proxies.
93+
- **Upgradeable**: Built to support future enhancements.
94+
95+
### **Relations with Other ChatterPay Contracts**:
96+
- **ChatterPayWalletProxy**: Deploys and manages proxies for the core wallet.
97+
98+
---
99+
100+
## 6. [**ChatterPayWalletProxy.sol**](../../src/ChatterPayWalletProxy.sol)
101+
102+
### **High-Level Overview**:
103+
The `ChatterPayWalletProxy` contract provides upgradeable functionality for wallets using the ERC1967 Proxy standard. It ensures that wallets can be updated without changing their addresses.
104+
105+
### **Key Features**:
106+
- **Upgradeable Wallets**: Supports upgrades to wallet implementations while preserving state.
107+
- **ERC1967 Standard**: Provides a reliable mechanism for proxy upgrades.
108+
109+
### **Relations with Other ChatterPay Contracts**:
110+
- **ChatterPayWalletFactory**: Proxies are deployed and managed by the factory.
111+
- **ChatterPay**: Proxies delegate calls to the main wallet implementation.
112+
113+
---
114+
115+
## 7. [**AggregatorV3Interface.sol**](../../src/interfaces/AggregatorV3Interface.sol)
116+
117+
### **High-Level Overview**:
118+
The `AggregatorV3Interface` defines the interface for Chainlink price feeds. It enables the retrieval of real-time token prices and metadata.
119+
120+
### **Key Features**:
121+
- **Price Feeds**: Provides real-time token prices from decentralized oracles.
122+
- **Metadata Access**: Retrieves additional information like price feed descriptions and versions.
123+
124+
### **Relations with Other ChatterPay Contracts**:
125+
- **ChatterPay**: Utilizes price feeds to calculate transaction fees and validate swaps.
126+
127+
### **External Contract Interactions**:
128+
- **Chainlink Oracles**: Fetches price data for supported tokens.
129+
130+
---
131+
132+
## 8. [**ISwapRouter.sol**](../../src/interfaces/ISwapRouter.sol)
133+
134+
### **High-Level Overview**:
135+
The `ISwapRouter` interface facilitates token swaps using the Uniswap V3 protocol. It supports both single-hop and multi-hop swaps with fine-grained control over slippage and fees.
136+
137+
### **Key Features**:
138+
- **Token Swapping**: Enables efficient token exchanges within the ecosystem.
139+
- **Customizable Parameters**: Supports exact input/output swaps with defined slippage tolerances.
140+
141+
### **Relations with Other ChatterPay Contracts**:
142+
- **ChatterPay**: Executes swaps for supported tokens using the router.
143+
144+
### **External Contract Interactions**:
145+
- **Uniswap V3**: Provides the infrastructure for token swaps.
146+

.doc/technical-overview/overview.md

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# ChatterPay Contracts Overview
2+
3+
## Summary
4+
5+
These smart contracts collectively create a robust ecosystem for wallet management, token price feeds, and NFT handling. They provide flexibility, upgradeability, and security by implementing key features like account abstraction, secure wallet deployment, NFT minting, and real-time price data management. The system allows for efficient wallet creation, management of user operations, and the minting of original and copy NFTs, all while ensuring that transaction fees and external data feeds are properly handled.
6+
7+
## Contracts List:
8+
9+
1. [**ChatterPay.sol**](../../src/ChatterPay.sol)
10+
Core wallet contract for ChatterPay, handling user operations, token transfers, and transaction fee management.
11+
12+
# ChatterPay Contracts Overview
13+
14+
## Summary
15+
16+
These smart contracts collectively form a powerful ecosystem for wallet management, token price feeds, NFT handling, and transaction facilitation. They offer flexibility, upgradeability, and security by implementing advanced features like account abstraction, Uniswap V3 integration, secure wallet deployment, NFT minting, password-protected vaults, and real-time price feed management. The system enables efficient wallet creation, user operations management, token swaps, and NFT minting with robust mechanisms to handle fees, slippage, and external data feeds.
17+
18+
## Contracts List:
19+
20+
1. [**ChatterPay.sol**](../../src/ChatterPay.sol)
21+
Core wallet contract for ChatterPay, supporting ERC-4337 account abstraction, Uniswap integration, transaction fee management, and token whitelisting.
22+
23+
2. [**ChatterPayNFT.sol**](../../src/ChatterPayNFT.sol)
24+
Manages the minting of original NFTs and their limited copies. Includes functionality for copy limits, metadata updates, and ownership management, using an upgradeable proxy structure.
25+
26+
3. [**ChatterPayPaymaster.sol**](../../src/ChatterPayPaymaster.sol)
27+
Paymaster contract that validates and manages user operations with signature-based authentication and fee handling, integrated with the EntryPoint contract.
28+
29+
4. [**ChatterPayVault.sol**](../../src/ChatterPayVault.sol)
30+
A vault contract that handles password-protected payments, commitments, and secure asset storage with mechanisms for reservation, redemption, and cancellation.
31+
32+
5. [**ChatterPayWalletFactory.sol**](../../src/ChatterPayWalletFactory.sol)
33+
Factory contract for deploying and managing ChatterPay wallet proxies. Provides deterministic address computation, proxy tracking, and upgradeability.
34+
35+
6. [**ChatterPayWalletProxy.sol**](../../src/ChatterPayWalletProxy.sol)
36+
An upgradeable proxy contract for ChatterPay wallets, leveraging the ERC-1967 Proxy standard to enable wallet upgrades and version control.
37+
38+
7. [**AggregatorV3Interface.sol**](../../src/interfaces/AggregatorV3Interface.sol)
39+
Interface for interacting with Chainlink price feed aggregators, providing methods to fetch price data and metadata for token feeds.
40+
41+
8. [**ISwapRouter.sol**](../../src/interfaces/ISwapRouter.sol)
42+
Interface for the Uniswap V3 swap router, enabling precise control over token swaps, slippage, and multi-hop routing.
43+
44+
---
45+
46+
Representation of Chatterpay's Smart Contracts Flow:
47+
48+
49+
![ChatterPay Smart Contracts Flow](./images/chatterpay-contracts-flow.png)
50+
51+
52+
[Here](./contracts-details.md) you can see a detailed breakdown of the provided smart contracts used for ChatterPay.

.env.example

-3
This file was deleted.

.github/workflows/slither.yml

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: Smart Contract Security Analysis
2+
on:
3+
push:
4+
branches:
5+
- '*'
6+
pull_request:
7+
branches:
8+
- develop
9+
- main
10+
11+
jobs:
12+
analyze:
13+
name: Smart Contract Static Analysis
14+
runs-on: ubuntu-latest
15+
permissions:
16+
contents: read
17+
security-events: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v4
21+
22+
- name: Set up Node.js and Yarn
23+
uses: actions/setup-node@v3
24+
with:
25+
node-version: '20.15.0'
26+
cache: 'yarn'
27+
28+
- name: Install dependencies with Yarn
29+
run: |
30+
yarn install
31+
32+
- name: Run Slither
33+
uses: crytic/[email protected]
34+
id: slither
35+
with:
36+
fail-on: none
37+
continue-on-error: true

0 commit comments

Comments
 (0)