Skip to content

Commit fa2deb1

Browse files
committed
Add agent contract & deployment scripts
1 parent 091e313 commit fa2deb1

17 files changed

Lines changed: 375 additions & 60 deletions

.env.example

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
PRIVATE_KEY=
2+
RPC_URL=https://eth-sepolia.g.alchemy.com/v2/your-api-key
3+
AGENT_ADDRESS=
4+
TOKEN_ID=0
5+
RECIPIENT=0x..

.gitignore

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@ cache/
33
out/
44

55
# Ignores development broadcast logs
6-
!/broadcast
7-
/broadcast/*/31337/
8-
/broadcast/**/dry-run/
6+
broadcast/
97

108
# Docs
119
docs/

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
11
[submodule "lib/forge-std"]
22
path = lib/forge-std
33
url = https://github.com/foundry-rs/forge-std
4+
[submodule "lib/openzeppelin-contracts"]
5+
path = lib/openzeppelin-contracts
6+
url = https://github.com/OpenZeppelin/openzeppelin-contracts

SCRIPTS.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# Deployment and Interaction Scripts
2+
3+
## Environment Setup
4+
5+
Create a `.env` file with:
6+
7+
```bash
8+
PRIVATE_KEY=your_private_key_here
9+
RPC_URL=your_rpc_url_here
10+
```
11+
12+
## Usage
13+
14+
### 1. Deploy Contract
15+
16+
```bash
17+
forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast --verify --etherscan-api-key $ETHERSCAN_API_KEY
18+
19+
```
20+
21+
### 2. Mint Token (Admin Only)
22+
23+
Set environment variables
24+
25+
Run mint script:
26+
27+
```bash
28+
forge script script/Mint.s.sol --rpc-url $RPC_URL --broadcast
29+
```
30+
31+
### 3. Claim Token (Admin Only)
32+
33+
Set environment variables
34+
35+
Run claim script:
36+
37+
```bash
38+
forge script script/Claim.s.sol --rpc-url $RPC_URL --broadcast
39+
```
40+
41+
## Example Flow
42+
43+
1. Deploy: `forge script script/Deploy.s.sol --rpc-url $RPC_URL --broadcast`
44+
2. Set AGENT_ADDRESS from deploy output
45+
3. Mint: `forge script script/Mint.s.sol --rpc-url $RPC_URL --broadcast`
46+
4. Set TOKEN_ID=0 and RECIPIENT address
47+
5. Claim: `forge script script/Claim.s.sol --rpc-url $RPC_URL --broadcast`

foundry.lock

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,11 @@
44
"name": "v1.10.0",
55
"rev": "8bbcf6e3f8f62f419e5429a0bd89331c85c37824"
66
}
7+
},
8+
"lib/openzeppelin-contracts": {
9+
"tag": {
10+
"name": "v5.4.0",
11+
"rev": "c64a1edb67b6e3f4a15cca8909c9482ad33a02b0"
12+
}
713
}
814
}

lib/openzeppelin-contracts

Submodule openzeppelin-contracts added at c64a1ed

remappings.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
@openzeppelin/contracts/=lib/openzeppelin-contracts/contracts/

script/Claim.s.sol

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
import {Script, console} from "forge-std/Script.sol";
5+
import {Agent} from "../src/Agent.sol";
6+
7+
contract ClaimScript is Script {
8+
function run() external {
9+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
10+
address agentAddress = vm.envAddress("AGENT_ADDRESS");
11+
uint256 tokenId = vm.envUint("TOKEN_ID");
12+
address recipient = vm.envAddress("RECIPIENT");
13+
14+
vm.startBroadcast(deployerPrivateKey);
15+
16+
Agent agent = Agent(agentAddress);
17+
18+
console.log("Token owner before claim:", agent.ownerOf(tokenId));
19+
console.log("Claiming token", tokenId, "to:", recipient);
20+
21+
agent.claim(recipient, tokenId);
22+
23+
console.log("Token owner after claim:", agent.ownerOf(tokenId));
24+
console.log("Claim successful!");
25+
26+
vm.stopBroadcast();
27+
}
28+
}

script/Counter.s.sol

Lines changed: 0 additions & 19 deletions
This file was deleted.

script/Deploy.s.sol

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.28;
3+
4+
import {Script, console} from "forge-std/Script.sol";
5+
import {Agent} from "../src/Agent.sol";
6+
7+
contract DeployScript is Script {
8+
function run() external {
9+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
10+
11+
vm.startBroadcast(deployerPrivateKey);
12+
13+
Agent agent = new Agent();
14+
15+
console.log("Agent deployed to:", address(agent));
16+
console.log("Owner:", agent.owner());
17+
18+
vm.stopBroadcast();
19+
}
20+
}

0 commit comments

Comments
 (0)