Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 19 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,26 +53,28 @@ Note: `src/Escrow.sol` is excluded from `forge fmt` to preserve the audited sour

## Deploy

Deployment uses `script/DeployEscrow.s.sol:DeployEscrowScript`.
Deployment uses `script/DeployEscrow.s.sol:DeployEscrowScript`. Constructor parameters are read from `script/deploy.toml`.

Environment variables read by the script:
### Configuration

- `PRIVATE_KEY` (deployer key)
- `ESCROW_OWNER`
- `ESCROW_RECIPIENT`
- `ESCROW_DENOMINATION`
- `ESCROW_AMOUNT_DENOM`
Edit `script/deploy.toml` to set the deploy parameters:

Example:
```toml
[escrow]
owner = "0x..."
recipient = "0x..."
denomination = "0x..." # WETH, USDC, etc.
amount_denom = "1000000000" # full precision (wei/smallest unit)
```

### Dry run

```sh
forge script script/DeployEscrow.s.sol --account <keystore-name> --rpc-url $RPC_URL
```

### Broadcast

```sh
export PRIVATE_KEY=...
export ESCROW_OWNER=0x...
export ESCROW_RECIPIENT=0x...
export ESCROW_DENOMINATION=0x...
export ESCROW_AMOUNT_DENOM=100000000000000000000

forge script script/DeployEscrow.s.sol:DeployEscrowScript \
--rpc-url $RPC_URL \
--broadcast
forge script script/DeployEscrow.s.sol --account <keystore-name> --rpc-url $RPC_URL --broadcast
```
8 changes: 7 additions & 1 deletion foundry.lock
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
{
"lib/forge-std": {
"rev": "1801b0541f4fda118a10798fd3486bb7051c5dd6"
},
"lib/openzeppelin-contracts": {
"rev": "dbb6104ce834628e473d2173bbc9d47f81a9eec3"
},
"lib\\forge-std": {
"tag": {
"name": "v1.14.0",
Expand All @@ -11,4 +17,4 @@
"rev": "dbb6104ce834628e473d2173bbc9d47f81a9eec3"
}
}
}
}
1 change: 1 addition & 0 deletions foundry.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ out = "out"
libs = ["lib"]
solc_version = "0.8.30"
no_match_coverage = "^(script|test)/"
fs_permissions = [{ access = "read", path = "script/deploy.toml" }]
remappings = [
"forge-std/=lib/forge-std/src/",
"@openzeppelin/=lib/openzeppelin-contracts/"
Expand Down
19 changes: 12 additions & 7 deletions script/DeployEscrow.s.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,23 @@ import {Escrow} from "src/Escrow.sol";

contract DeployEscrowScript is Script {
function run() external returns (Escrow deployed) {
address owner = vm.envAddress("ESCROW_OWNER");
address recipient = vm.envAddress("ESCROW_RECIPIENT");
address denomination = vm.envAddress("ESCROW_DENOMINATION");
uint256 amountDenom = vm.envUint("ESCROW_AMOUNT_DENOM");
string memory toml = vm.readFile("script/deploy.toml");

uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
address owner = vm.parseTomlAddress(toml, ".escrow.owner");
address recipient = vm.parseTomlAddress(toml, ".escrow.recipient");
address denomination = vm.parseTomlAddress(toml, ".escrow.denomination");
uint256 amountDenom = vm.parseTomlUint(toml, ".escrow.amount_denom");

vm.startBroadcast(deployerPrivateKey);
vm.startBroadcast();
deployed = new Escrow(owner, recipient, denomination, amountDenom);
vm.stopBroadcast();

console2.log("Escrow deployed at", address(deployed));
console2.log("=== Escrow Deploy Summary ===");
console2.log("Escrow: ", address(deployed));
console2.log("Owner: ", owner);
console2.log("Recipient: ", recipient);
console2.log("Denomination:", denomination);
console2.log("Amount Denom:", amountDenom);
}
}

5 changes: 5 additions & 0 deletions script/deploy.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
[escrow]
owner = "0x1118e1c057211306a40A4d7006C040dbfE1370Cb"
recipient = "0x741c585e6dE1AD32C606C030cE7466aAE561641c"
denomination = "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2" # WETH
amount_denom = "1445198000000000000000" # 1445.198 WETH (18 decimals)