/soltracker

Tracking Solana transactions

Primary LanguageElixirMIT LicenseMIT

SolTracker

Start a websocket client to listen for logs or programs, or use the RPC directly. Parse Blocks by slot ID, Transactions, and filter for NFT transfers.

Decoding token metadata encoded under the Metaplex standard is done via a Rust metaplex-decoder, which we call via Rustler. Therefore you will need Rust installed to compile the project.

SolTracker.Transfers.track() # spawns a websocket in a supervised process 
SolTracker.Block.fetch(108379233) # fetch a block via RPC by its slot number

Query and parse a block for "transfer" types from the token program.

iex(1)> SolTracker.Transfers.parse_transfers_from_slot(109742643)
%{
  lamports: 2039280,
  owner: "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
  program: %{
    "parsed" => %{
      "info" => %{
        "isNative" => false,
        "mint" => "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
        "owner" => "HoDhphLcgw8hb6GdTicv6V9are7Yi7xXvUriwWwRWuRk",
        "state" => "initialized",
        "tokenAmount" => %{
          "amount" => "65839344362",
          "decimals" => 6,
          "uiAmount" => 65839.344362,
          "uiAmountString" => "65839.344362"
        }
      },
      "type" => "account"
    },
    "program" => "spl-token",
    "space" => 165
  },
  slot: 108520863
}

Hawku

This project was sponsored by Hawku.

Installation

def deps do
  [
    {:soltracker, "~> 0.1.0"}
  ]
end

Nix

A Nix flake and shell are made available under the nix/ folder. Run nix develop to load an environment with all Elixir, Rust, and Postgres dependencies. The flake is there for convenience: it cannot compile a full mix release as it needs to build the Rust part independently (todo).