Skip to content

Instantly share code, notes, and snippets.

View tundachef's full-sized avatar
🔥
Fire shut in my bones

Ray Zion tundachef

🔥
Fire shut in my bones
View GitHub Profile
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;
}
@tundachef
tundachef / jupiter-full-js-example.js
Created December 5, 2024 07:27 — forked from NotoriousPyro/jupiter-full-js-example.js
Full example of how to swap tokens with jupiter
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(''));