This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // searchPublicKeysFromDir.ts | |
| // Usage: | |
| // ts-node searchPublicKeysFromDir.ts --dir ./data | |
| // # or compile first: tsc searchPublicKeysFromDir.ts && node dist/searchPublicKeysFromDir.js --dir ./data | |
| // | |
| // What it does: | |
| // - Reads all .json files in the given folder | |
| // - Searches for any record with a `publicKey` matching one from publicKeysToFind | |
| // - Intentionally slow (configurable delays + jitter) | |
| // - Writes results to ./search-results.json |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const { Connection, Keypair, VersionedTransaction } = require ('@solana/web3.js'); | |
| const bs58 = require ('bs58'); | |
| const axios = require('axios'); | |
| // It is recommended that you use your own RPC endpoint. | |
| // This RPC endpoint is only for demonstration purposes so that this example will run. | |
| const connection = new Connection(''); | |
| const keypair = Keypair.fromSecretKey(bs58.decode('')); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| class DownloadUtil { | |
| static Future<String> downloadAndSaveFile(String url, String fileName) async { | |
| final Directory directory = await getApplicationDocumentsDirectory(); | |
| final String filePath = '${directory.path}/$fileName.png'; | |
| final http.Response response = await http.get(Uri.parse(url)); | |
| final File file = File(filePath); | |
| await file.writeAsBytes(response.bodyBytes); | |
| return filePath; | |
| } |