Advertisement
Guest User

Get current mint number

a guest
Nov 24th, 2021
662
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.26 KB | None | 0 0
  1. package pandas;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.InputStreamReader;
  5.  
  6. import com.google.gson.JsonObject;
  7. import com.google.gson.JsonParser;
  8.  
  9. public class Minted {
  10.    
  11.     public static void main(String[] args) {
  12.         while (true) {
  13.             try {
  14.                 String command = "curl https://api.mainnet-beta.solana.com -X POST -H \"Content-Type: application/json\" -d {\\\"jsonrpc\\\":\\\"2.0\\\",\\\"id\\\":\\\"1\\\",\\\"method\\\":\\\"getTokenAccountBalance\\\",\\\"params\\\":[\\\"CheWJgRCqpEXiEGVdh4HHiQdprtrzrVjgXazuCfCFM1P\\\"]}";
  15.                
  16.                 Process process = Runtime.getRuntime().exec(command);
  17.                 String result = "";
  18.                
  19.                 try (BufferedReader input = new BufferedReader(new InputStreamReader(process.getInputStream()))) {
  20.                     String line = null;
  21.                    
  22.                     while ((line = input.readLine()) != null) {
  23.                         result += line;
  24.                     }
  25.                 }
  26.    
  27.                 JsonParser jsonParser = new JsonParser();
  28.                 JsonObject root = (JsonObject) jsonParser.parse(result);
  29.                 int minted = root.get("result").getAsJsonObject().get("value").getAsJsonObject().get("amount").getAsInt();
  30.                
  31.                 System.out.println(new java.util.Date(System.currentTimeMillis()) + " > " + minted);
  32.                
  33.                 Thread.sleep(500);
  34.             } catch (Exception e) {
  35. //              e.printStackTrace();
  36.             }
  37.         }
  38.     }
  39.  
  40. }
  41.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement