Skip to main content
이 노트북의 목적은 Blockchain용 LangChain Document Loader의 기능을 테스트하는 방법을 제공하는 것입니다. 초기에 이 로더는 다음을 지원합니다:
  • NFT 스마트 컨트랙트(ERC721 및 ERC1155)에서 NFT를 Document로 로드
  • Ethereum Mainnnet, Ethereum Testnet, Polygon Mainnet, Polygon Testnet (기본값은 eth-mainnet)
  • Alchemy의 getNFTsForCollection API
커뮤니티가 이 로더에서 가치를 발견하면 확장할 수 있습니다. 구체적으로:
  • 추가 API를 추가할 수 있습니다 (예: 트랜잭션 관련 API)
이 Document Loader를 사용하려면 다음이 필요합니다: 출력은 다음과 같은 형식을 취합니다:
  • pageContent= 개별 NFT
  • metadata={‘source’: ‘0x1a92f7381b9f03921564a437210bb9396471050c’, ‘blockchain’: ‘eth-mainnet’, ‘tokenId’: ‘0x15’}

Document Loader에 NFT 로드하기

# get ALCHEMY_API_KEY from https://www.alchemy.com/

alchemyApiKey = "..."

옵션 1: Ethereum Mainnet (기본 BlockchainType)

from langchain_community.document_loaders.blockchain import (
    BlockchainDocumentLoader,
    BlockchainType,
)

contractAddress = "0xbc4ca0eda7647a8ab7c2061c2e118a18a936f13d"  # Bored Ape Yacht Club contract address

blockchainType = BlockchainType.ETH_MAINNET  # default value, optional parameter

blockchainLoader = BlockchainDocumentLoader(
    contract_address=contractAddress, api_key=alchemyApiKey
)

nfts = blockchainLoader.load()

nfts[:2]

옵션 2: Polygon Mainnet

contractAddress = (
    "0x448676ffCd0aDf2D85C1f0565e8dde6924A9A7D9"  # Polygon Mainnet contract address
)

blockchainType = BlockchainType.POLYGON_MAINNET

blockchainLoader = BlockchainDocumentLoader(
    contract_address=contractAddress,
    blockchainType=blockchainType,
    api_key=alchemyApiKey,
)

nfts = blockchainLoader.load()

nfts[:2]

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I