Class: Solrengine::Tokens::NftService

Inherits:
Object
  • Object
show all
Defined in:
lib/solrengine/tokens/nft_service.rb

Overview

Fetches Metaplex NFTs owned by a wallet via the DAS API (getAssetsByOwner). Requires a DAS-capable RPC endpoint (Helius, Triton, etc.) — the public Solana endpoints do not serve DAS.

Constant Summary collapse

NFT_INTERFACES =
[ "V1_NFT", "V2_NFT", "ProgrammableNFT", "LEGACY_NFT", "MplCoreAsset" ].freeze

Instance Method Summary collapse

Constructor Details

#initializeNftService

Returns a new instance of NftService.



11
12
13
# File 'lib/solrengine/tokens/nft_service.rb', line 11

def initialize
  @client = Solrengine::Rpc.client
end

Instance Method Details

#nfts_for(wallet_address, page: 1, limit: 50) ⇒ Object



15
16
17
18
19
20
21
22
23
24
# File 'lib/solrengine/tokens/nft_service.rb', line 15

def nfts_for(wallet_address, page: 1, limit: 50)
  response = @client.request("getAssetsByOwner", {
    ownerAddress: wallet_address,
    page: page,
    limit: limit
  })

  items = response.dig("result", "items") || []
  items.filter_map { |asset| build_entry(asset) }
end