Hello,
I want to check if a wallet contain an NFT by its address, but when I try to import keypair module I get an error that it does not exist.
import os
import json
from solana.rpc.api import Client
from solana.keypair import Keypair
from nft_addresses import nft_addresses
# Set up Solana RPC endpoint
rpc_endpoint = 'https://api.mainnet-beta.solana.com'
client = Client(rpc_endpoint)
# Set up Solana wallet keypair
wallet_keypair = Keypair.from_secret_key(bytes.fromhex(os.environ.get('WALLET_SECRET_KEY')))
# Define Discord bot command
async def check_nft(ctx):
# Get user's Solana wallet address
user_address = 'user-address-here'
# Check if user holds one of the NFTs
for nft_address in nft_addresses:
token_account_info = await client.get_account_info(nft_address)
token_data = json.loads(token_account_info['data'][0])
for account in token_data['accountList']:
if account['account'] == user_address and account['amount'] > 0:
await ctx.send('You hold one of the NFTs in our collection!')
return
await ctx.send('Sorry, you do not hold any NFTs in our collection.')
# Add Discord bot command to client
client.add_command('check_nft', check_nft)
# Connect bot to Discord server
client.run(os.environ.get('DISCORD_BOT_TOKEN'))
Hello, I want to check if a wallet contain an NFT by its address, but when I try to import keypair module I get an error that it does not exist.
The error that I get is
Details
Cannot find reference 'keypair' in 'init.py'