Skip to content

Commit 660f45e

Browse files
author
Gar Manji Michael
authored
Update InteractAPIConsumer.s.sol
1 parent 7e99a3c commit 660f45e

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

script/InteractAPIConsumer.s.sol

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// SPDX-License-Identifier: MIT
2+
pragma solidity ^0.8.19;
3+
4+
import {Script, console} from "forge-std/Script.sol";
5+
import {APIConsumer} from "../src/APIConsumer.sol";
6+
7+
contract InteractAPIConsumer is Script {
8+
function run() external {
9+
10+
uint256 deployerPrivateKey = vm.envUint("PRIVATE_KEY");
11+
address apiConsumerAddress = vm.envAddress("API_CONSUMER_ADDRESS");
12+
13+
vm.startBroadcast(deployerPrivateKey);
14+
15+
APIConsumer apiConsumer = APIConsumer(apiConsumerAddress);
16+
17+
console.log("Requesting posts data...");
18+
bytes32 requestId1 = apiConsumer.requestAPIData("posts", "");
19+
console.log("Request ID for posts:", vm.toString(requestId1));
20+
21+
22+
console.log("Requesting specific post data...");
23+
bytes32 requestId2 = apiConsumer.requestAPIData("posts", "1");
24+
console.log("Request ID for post 1:", vm.toString(requestId2));
25+
26+
27+
28+
vm.stopBroadcast();
29+
}
30+
}

0 commit comments

Comments
 (0)