File tree Expand file tree Collapse file tree 1 file changed +30
-0
lines changed
Expand file tree Collapse file tree 1 file changed +30
-0
lines changed Original file line number Diff line number Diff line change 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+ }
You can’t perform that action at this time.
0 commit comments