michaelhly / solana-py

Solana Python SDK
https://michaelhly.github.io/solana-py
MIT License
1.05k stars 271 forks source link

Some questions #264

Open naffam777 opened 2 years ago

naffam777 commented 2 years ago

Hello, I'm pretty new to using solana and had some questions!

I saw this code to mint NFT's when I was checking through the issues

`def MintNft(_key1: PublicKey, _key2: PublicKey, _key3: PublicKey): config = PublicKey("DNnzE5TunUhgZz9JogFtQqrDFn1DqscDVLga8KmrnZKt") candyMachineId = PublicKey("FJPBA6WtXhB2M2p83eE1brevRJjGBsAQAW5Sf6soBG9e") treasury = PublicKey("564fBJG35QTuFxsJat6ynnJPBXjb7EUbXbgCSw6HvWUk") TOKEN_METADATA_PROGRAM_ID = PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s') CANDY_MACHINE_PROGRAM = PublicKey('CMX5tvuWs2rBUL3vqVWiARfcDoCKjdeSinCsZdxJmYoF')

Metadata = PublicKey.find_program_address([b'metadata', bytes(TOKEN_METADATA_PROGRAM_ID), bytes(_key2)],
                                          TOKEN_METADATA_PROGRAM_ID)[0]
masterEdition = PublicKey.find_program_address(
    [b'metadata', bytes(TOKEN_METADATA_PROGRAM_ID), bytes(_key2), b'edition'],
    TOKEN_METADATA_PROGRAM_ID)[0]

keys1 = []
keys1.append(AccountMeta(pubkey=config, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=candyMachineId, is_signer=False,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=_key1, is_signer=True,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=treasury, is_signer=False,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=Metadata, is_signer=False,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=_key2, is_signer=False,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=_key1, is_signer=True,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=_key1, is_signer=True,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=masterEdition, is_signer=False,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=TOKEN_METADATA_PROGRAM_ID, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=TOKEN_PROGRAM_ID, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=SYS_PROGRAM_ID, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=SYSVAR_RENT_PUBKEY, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=SYSVAR_CLOCK_PUBKEY, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=SYS_PROGRAM_ID, is_signer=False,
                         is_writable=True))
keys1.append(AccountMeta(pubkey=SYS_PROGRAM_ID, is_signer=False,
                         is_writable=False))
keys1.append(AccountMeta(pubkey=_key3, is_signer=True,
                         is_writable=False))
return TransactionInstruction(
    keys=keys1,
    program_id=CANDY_MACHINE_PROGRAM,
    data=build_method('mintNft')
)`

My question is, what exactly is the addresss for "config". I uploaded a test collection to test this code out, but couldn't find an address for config. Hope this question isn't that stupid, sorry!

Thank you in advance.

michaelhly commented 2 years ago

Looks like it's the program/account at DNnzE5TunUhgZz9JogFtQqrDFn1DqscDVLga8KmrnZKt1

crypt0miester commented 2 years ago

in candy machines, config is usually the configuration address where the cm data is stored. they are different for every cm.

i.e. price, go live date, etc.

hint search for willy-wonka (it uses the old cmv1)

s3r0v commented 2 years ago

Hello! Where did you find 'MintNft' function?

crypt0miester commented 2 years ago

Hello! Where did you find 'MintNft' function?

you can find one in one of my repos forked from metaplex. there is a python lib for candy machine there. it is still in its infancy and needs more work. but it works.