Skip to content

Commit 65dbfa3

Browse files
committed
Add content of Deploy Proxy Contract section.
1 parent 8d67e88 commit 65dbfa3

1 file changed

Lines changed: 178 additions & 1 deletion

File tree

README.md

Lines changed: 178 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,184 @@ npm run deploy -- --network <network>
248248

249249
### Deploy Proxy Contract
250250

251-
TODO: update this section
251+
Follow these steps to deploy UTTProxy on a new chain, let's call it "target chain", and connect it to the main UTT contract:
252+
253+
#### 1. Prerequisites Setup
254+
255+
**Environment Variables:**
256+
257+
Add/update in .env (or console environment):
258+
- `<NETWORK>_URL` - RPC endpoint for the new chain
259+
- Appropriate API keys for contract verification (if supported)
260+
- `TEST_PRIVATE_KEY` or `MAIN_PRIVATE_KEY` - Deployer wallet private key, should be same as for other networks;
261+
- Our testnet deployer wallet is 0xc8c745De6a84DFF8E604c1fD4BE18baDd8433135
262+
- Our mainnet deployer wallet is 0x0D1e9d15F6198C5458ca0Cd24b48f4D9B4AB942e
263+
264+
**Network Configuration:**
265+
Add new network configuration in `hardhat.config.ts`:
266+
267+
1. **Add to networks section:**
268+
```javascript
269+
new_chain: {
270+
url: process.env.NEW_CHAIN_URL,
271+
accounts: [process.env.MAIN_PRIVATE_KEY ?? ""],
272+
chainId: <chain_id>
273+
}
274+
```
275+
276+
2. **Add to etherscan.customChains for contract verification:**
277+
```javascript
278+
{
279+
network: "new_chain",
280+
chainId: <chain_id>,
281+
urls: {
282+
apiURL: "https://<explorer_domain>/api",
283+
browserURL: "https://<explorer_domain>"
284+
}
285+
}
286+
```
287+
288+
**Note:** For Blockscout explorers, set the corresponding `etherscan.apiKey` entry to `null` (no API key required). For Etherscan-based explorers, you'll need to provide the appropriate API key.
289+
290+
#### 2. Find or Deploy LINK Token
291+
292+
If the target chain is already supported by Chainlink and has a faucet, we can use this. LINK token addresses on all supported chains are [listed in the Chainlink docs](https://docs.chain.link/resources/link-token-contracts).
293+
294+
Otherwise, we can deploy our own LINK token like so:
295+
296+
```bash
297+
npm run deploy:link-token -- --network <new_chain>
298+
```
299+
300+
Note down the address for the next step.
301+
302+
#### 3. Deploy Chainlink Operator Contract
303+
304+
Create `scripts/deploy.operator.args.<new_chain>.js`:
305+
```javascript
306+
module.exports = [
307+
"0x<LINK_TOKEN_ADDRESS>", // LINK token address on this chain
308+
];
309+
```
310+
311+
```bash
312+
npm run deploy:operator -- --network <new_chain>
313+
```
314+
315+
**Verify Operator Contract:**
316+
```bash
317+
npm run verify -- --constructor-args ./scripts/deploy.operator.args.<new_chain>.js --contract contracts/mocks/Operator.sol:UTUOperator --network <new_chain> <operator_address>
318+
```
319+
320+
#### 4. Configure Oracle Node Jobs
321+
322+
**Configure Job Parameters:**
323+
Create network-specific job configuration in `chainlink-node/jobs/network-specific/values-<main_utt_chain_id>/<new_chain>.sh`:
324+
```bash
325+
export __PROXY_JOB_VALUE_NETWORK="<new_chain>"
326+
export __PROXY_JOB_VALUE_PROXY_NETWORK_ID="<new_chain_id>"
327+
export __PROXY_JOB_VALUE_PROXY_ORACLE_OPERATOR_ADDRESS="<operator_address_from_step_3>"
328+
export __PROXY_JOB_VALUE_UTT_PROXY_ENDORSE_EXTERNAL_JOB_ID="<32_char_hex_job_id>"
329+
export __PROXY_JOB_VALUE_UTT_PROXY_CLAIM_REWARD_EXTERNAL_JOB_ID="<32_char_hex_job_id>"
330+
```
331+
332+
333+
**Job ID Guidelines:**
334+
- Randomly generated 32-character hex strings (no hyphens), e.g. `30d3f168244f40788be35c05f6c5924f`; e.g. use a uuid v4 generator and remove hyphens.
335+
- Mainnet and testnet variants of the same proxy chain my share job ids, but job ids of different proxy chains must be different. E.g. Aurora mainnet job id for the endorse job migt be equal to the Aurora testnet job, but must be different from the Optimism mainnet job.
336+
337+
**Redeploy Oracle Node:**
338+
After adding the new chain configuration, rebuild and redeploy the Chainlink oracle node container to pick up the new jobs:
339+
340+
1. **Build the updated container:**
341+
```bash
342+
cd chainlink-node
343+
make docker-build
344+
```
345+
346+
2. **Deploy the container** (choose one):
347+
- **Local deployment:** `make docker-run` (uses docker-compose)
348+
- Deployment in k8s cluster:
349+
- **Standard way via pushing to registry:**
350+
- `make docker-push`
351+
- Update infrastructure project to use new version.
352+
- Redeploy chainlink node.
353+
- **Direct deployment:** `make k8s-deploy` (e.g. for quick debugging on staging); be sure to use the correct `K8S_NAMESPACE` env variable.
354+
355+
The container automatically processes job templates during startup:
356+
- `utt-proxy-endorse.toml.template` → Creates endorsement proxy jobs
357+
- `utt-proxy-claim-rewards.toml.template` → Creates reward claiming proxy jobs
358+
359+
**Whitelist Oracle Node:**
360+
In the operator contract, call `setAuthorizedSenders` to whitelist the Chainlink node address.
361+
362+
#### 5. Configure Oracle Node Access on Main UTT Contract
363+
364+
On the main UTT contract (Polygon), grant the oracle node wallet address the `PROXY_ENDORSER_ROLE`:
365+
```solidity
366+
utt.grantRole(await utt.PROXY_ENDORSER_ROLE(), <chainlink_node_wallet_address>);
367+
```
368+
369+
#### 6. Deploy UTU Coin Contract (Optional)
370+
If the chain needs a local UTU Coin token:
371+
```bash
372+
npm run deploy:utu-coin-mock -- --network <new_chain>
373+
```
374+
375+
#### 7. Create UTTProxy Deployment Arguments
376+
377+
Create `scripts/deploy.proxy.args.<new_chain>.js`:
378+
```javascript
379+
const { ethers } = require("hardhat");
380+
381+
module.exports = [
382+
"<OPERATOR_CONTRACT_ADDRESS>", // from step 3
383+
"<32_char_hex_endorse_job_id>", // same as step 4, no hyphens
384+
ethers.parseEther("0.0000001"), // LINK fee
385+
"<LINK_TOKEN_ADDRESS>", // from step 2
386+
"<32_char_hex_claim_job_id>", // same as step 4, no hyphens
387+
];
388+
```
389+
390+
#### 8. Deploy UTTProxy Contract
391+
```bash
392+
npm run deploy:proxy -- --network <new_chain>
393+
```
394+
395+
This deploys an upgradeable proxy with the UTTProxy implementation.
396+
397+
**Verify UTTProxy Contract:**
398+
```bash
399+
# Verify implementation
400+
npm run verify -- --network <new_chain> <implementation_address>
401+
402+
# Verify proxy
403+
npm run verify -- --constructor-args ./scripts/deploy.proxy.args.<new_chain>.js --network <new_chain> <proxy_address>
404+
```
405+
406+
#### 9. Configure UTTProxy Contract
407+
408+
**Set UTU Coin Address (if applicable):**
409+
```solidity
410+
uttProxy.setUTUCoin(<utu_coin_address>);
411+
```
412+
413+
**Fund with LINK tokens:**
414+
Send LINK tokens to the UTTProxy contract address for oracle payments.
415+
416+
#### 10. Test Cross-Chain Functionality
417+
418+
**Test Endorsement Flow:**
419+
1. User calls `endorse()` on UTTProxy (new chain)
420+
2. UTTProxy sends oracle request to operator
421+
3. Chainlink node picks up job, calls `proxyEndorse()` on main UTT contract (Polygon)
422+
4. Oracle fulfills request back to UTTProxy
423+
424+
**Test Reward Claiming:**
425+
1. User calls `claimUTURewards()` on UTTProxy
426+
2. Oracle queries main UTT contract for claimable rewards
427+
3. Oracle calls `proxyClaimRewards()` on main UTT contract
428+
4. Oracle returns reward amount to UTTProxy
252429

253430
### Upgrade UTT Contract
254431

0 commit comments

Comments
 (0)