Skip to content

Commit 4b05aaa

Browse files
committed
Add architecture description to README.md
1 parent 6f381da commit 4b05aaa

1 file changed

Lines changed: 103 additions & 1 deletion

File tree

README.md

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# UTU Trust Token Contract
22

3-
This project implements the UTU Trust Token (UTT) smart contract.
3+
This project contains the UTU Trust Token (UTT) smart contract, which implements UTU Protocol, a decentralized trust and reputation system that enables endorsements, rewards, and penalties between users. The mechanism and tokenomics are detailed in the [UTU Protocol Whitepaper](https://docs.google.com/document/d/1syxWDbJ5Ch0OiMiMfPQ3AWDiyY0Ol4pLJacTvczDo6I/edit?usp=sharing).
44

55
## Existing Deployments
66

@@ -101,6 +101,108 @@ It also prints out the code to add to the "Should allow contract upgrading with
101101

102102
## Architecture
103103

104+
### Main UTT Contract Architecture
105+
106+
The main UTT contract on Polygon mainnet is built using a modular, upgradeable architecture that combines multiple inheritance layers; each inherited contract's purpose is to implement specific aspects of the total UTT functionality.
107+
108+
#### Contract Hierarchy
109+
```
110+
UTT (Main Contract)
111+
├── MigratableReward
112+
│ ├── Reward (UTU Coin reward distribution)
113+
│ ├── MigratableEndorsement (Data migration for endorsements)
114+
│ │ ├── Migratable (Base migration functionality)
115+
│ │ └── Endorsement (Core endorsement logic)
116+
│ │ ├── ChainlinkClient (Oracle integration)
117+
│ │ ├── EndorsementInterface
118+
│ │ └── Roles (Access control)
119+
│ └── MigratableSocialConnector (Social media account linking)
120+
│ ├── Migratable
121+
│ └── SocialConnector
122+
├── ERC20BurnableUpgradeable (Token burning capability)
123+
└── ERC20PausableUpgradeable (Emergency pause functionality)
124+
```
125+
126+
#### Core Functionality Modules
127+
128+
1. **Token Properties**:
129+
- ERC20 token with 0 decimals (whole numbers only)
130+
- Non-transferable (transfers are blocked)
131+
- Burnable
132+
- Pausable for emergency controls
133+
- Upgradeable using OpenZeppelin proxy pattern
134+
135+
2. **Endorsement System** (`Endorsement.sol`):
136+
- `endorse()`: Direct endorsements on Polygon
137+
- `proxyEndorse()`: Cross-chain endorsements from proxy contracts (requires `PROXY_ENDORSER_ROLE`), see below.
138+
- Chainlink oracle integration for fetching previous endorsers
139+
- Reward calculations based on previous endorsers, see white paper.
140+
141+
3. **Reward Distribution** (`Reward.sol`):
142+
- UTT token rewards for endorsements
143+
- UTU Coin reward distribution (separate ERC20 token)
144+
- Requires being connected to whitelisted social media platforms
145+
- `claimUTURewards()`: Claim accumulated UTU Coin rewards
146+
- `proxyClaimRewards()`: Cross-chain reward claiming
147+
148+
4. **Social Connector** (`SocialConnector.sol`):
149+
- Link Ethereum addresses to social media accounts
150+
- `addConnection()`: Connect social media accounts (requires `SOCIAL_CONNECTOR_ROLE`)
151+
- Rewards for verified social connections (once only per address and platforms)
152+
153+
5. **Role-Based Access Control** (`Roles.sol`):
154+
- `DEFAULT_ADMIN_ROLE`: Contract administration
155+
- `PROXY_ENDORSER_ROLE`: Allows oracle to execute cross-chain endorsements
156+
- `SOCIAL_CONNECTOR_ROLE`: Allows social media connector service to connect accounts
157+
158+
6. **Migration System** (`Migratable*.sol`):
159+
- Support for migrating data from previous contract versions
160+
- Endorsement data migration
161+
- Social connection migration
162+
- Balance migration
163+
- Migration state controls
164+
165+
#### Key Technical Features
166+
167+
- **Upgradeability**: Uses OpenZeppelin's upgradeable proxy pattern with proper storage gaps
168+
- **Oracle Integration**: Chainlink oracles fetch endorsement history for reward calculations
169+
- **Cross-Chain Support**: Special functions (`proxyEndorse`, `proxyClaimRewards`) for proxy contract calls
170+
- **Data Migration**: Comprehensive migration system for contract upgrades
171+
- **Access Control**: Granular role-based permissions for different operations
172+
173+
### Cross-Chain Proxy Design
174+
175+
The UTU Trust Token system uses a cross-chain proxy architecture to enable users on multiple EVM chains to interact with the main UTT contract deployed on Polygon mainnet.
176+
177+
This architecture's purpose is to allow the system to maintain a single source of truth on Polygon while providing native UX, and therefore easy intergratability into apps, on other chains.
178+
179+
#### Proxy Mechanism Components
180+
181+
1. **Main UTT Contract** (Polygon mainnet): The authoritative contract containing all state, logic, and token balances
182+
2. **UTTProxy Contracts** (Other chains): Stateless proxy contracts that forward calls to the main contract via Chainlink oracles
183+
3. **Chainlink Oracle Infrastructure**: Facilitates cross-chain communication between proxy contracts and the main contract
184+
185+
#### Proxy Mechanism Properties
186+
187+
- **Stateless Proxies**: UTTProxy contracts don't hold any business logic state - they're pure proxies that forward operations
188+
- **Oracle-Mediated Communication**: All cross-chain calls go through Chainlink oracles with specific job configurations
189+
- **Role-Based Access**: The oracle node wallet must have `PROXY_ENDORSER_ROLE` on the main UTT contract to execute proxy operations
190+
- **Two-Way Communication**:
191+
- Endorsements: User → UTTProxy → Oracle → Main UTT Contract
192+
- Reward Claims: User → UTTProxy → Oracle → Query Main UTT → Execute Claim → Return Result
193+
194+
#### Oracle Jobs
195+
196+
Two distinct Chainlink jobs handle cross-chain operations:
197+
198+
1. **UTT Proxy Endorse Job**: Listens for endorsement requests on proxy chains and executes `proxyEndorse()` on the main contract
199+
2. **UTT Proxy Claim Rewards Job**: Handles reward claiming by querying claimable amounts and executing `proxyClaimRewards()` on the main contract
200+
201+
#### Data Flow Example (Endorsement)
202+
```
203+
User (Chain B) → UTTProxy.endorse() → Oracle Request → Chainlink Node →
204+
Main UTT.proxyEndorse() (Polygon) → Oracle Response → UTTProxy fulfillment
205+
```
104206

105207

106208
## Deploying

0 commit comments

Comments
 (0)