python-api icon indicating copy to clipboard operation
python-api copied to clipboard

deploy generating generic account, not a token mint

Open bigbrihh opened this issue 4 years ago • 6 comments

running metaplex_api.deploy(api_endpoint, "<name>", "<symbol>", seller_basis_fees) I should expect a token account to be created however it ends up creating a generic account. '{"jsonrpc": "2.0", "result": "3Z9ez2QjnjgL14haPSXHkeHviYKxomC9m3hb4SmgoUZM6kQfTGYvogK7Bai5uxREEwq1d8VMKpHWbtBBUk7oRFif", "id": 2, "contract": "AMtrrdq3z36vKiUY2a6FxJ6zytgrQDQKBqB59G3zpMX5", "status": 200}' explorer https://explorer.solana.com/address/AMtrrdq3z36vKiUY2a6FxJ6zytgrQDQKBqB59G3zpMX5?cluster=devnet

In the docs the json response is '{"status": 200, "contract": "7bxe7t1aGdum8o97bkuFeeBTcbARaBn9Gbv5sBd9DZPG", "msg": "Successfully created mint 7bxe7t1aGdum8o97bkuFeeBTcbARaBn9Gbv5sBd9DZPG", "tx": "2qmiWoVi2PNeAjppe2cNbY32zZCJLXMYgdS1zRVFiKJUHE41T5b1WfaZtR2QdFJUXadrqrjbkpwRN5aG2J3KQrQx"}' with "Successfully created mint"... and explorer shows the contact as an unknown token. https://explorer.solana.com/address/7bxe7t1aGdum8o97bkuFeeBTcbARaBn9Gbv5sBd9DZPG/metadata?cluster=devnet

Any attempts to mint produce error: TypeError: 'NoneType' object is not subscriptable

bigbrihh avatar Jan 14 '22 21:01 bigbrihh

you are right. Not sure what is the end game in this code and that was my suspicion from the begining. If you see deploy function below: def deploy(api_endpoint, source_account, name, symbol, fees): # Initalize Client client = Client(api_endpoint) # List non-derived accounts mint_account = Keypair() token_account = TOKEN_PROGRAM_ID

the TOKEN_PROGRAM_ID is hardcoded in the class InstructionType

METADATA_PROGRAM_ID = PublicKey('metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s') SYSTEM_PROGRAM_ID = PublicKey('11111111111111111111111111111111') SYSVAR_RENT_PUBKEY = PublicKey('SysvarRent111111111111111111111111111111111') ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL') TOKEN_PROGRAM_ID = PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA')

is this code trying to assign all the minted contracts to the same account. My first one which I minted with real sols went to a wierd account !

mdergueche avatar Jan 16 '22 20:01 mdergueche

I am using devnet and trying to just run through their instructions in the README.md to just walk through the motions of creating an NFT.

Not sure if at some point there has been some drift between metaplex's python module and the version of solana it uses since the deploy part now returns a different json response.

bigbrihh avatar Jan 16 '22 21:01 bigbrihh

you need to do deploy and then mint also

deploy_response = json.loads(api.deploy(api_endpoint, name, symbol, 0)) print("Deploy:", deploy_response) assert deploy_response["status"] == 200 contract = deploy_response.get("contract")

mint_to_response = json.loads(api.mint(api_endpoint, contract, address1, "https://arweave.net/1eH7bZS-6HZH4YOc8T_tGp2Rq25dlhclXJkoa6U55mM/")) print("Mint:", mint_to_response) assert mint_to_response["status"] == 200

you can see this example i have picked up from the test folder . Happy coding :(

nurav97 avatar Jan 17 '22 09:01 nurav97

I did that but it does not work. most of the users are getting the same error: TypeError: 'NoneType' object is not subscriptable

mdergueche avatar Jan 17 '22 20:01 mdergueche

this issue of none type is solved in #8 . it is caused by the change in order of signers .

the PR is still pending you can clone the PR code and solve the issue

nurav97 avatar Jan 18 '22 09:01 nurav97

many thanks @DevVarunn I did the clone but with no great success. I tried afterward the following code which somehow I managed to mint once the contract (previously without even the fix you are proposing). Any help please will be more than welcome. I'm stuck to continue on my project

import base58 import json import os import time from api.metaplex_api import wallet, MetaplexAPI from cryptography.fernet import Fernet from solana.rpc.api import Client from solana.keypair import Keypair

cfg = { "PRIVATE_KEY": WALLET_PRIVATE_KEY, "PUBLIC_KEY": WALLET_PUBLIC_KEY, "DECRYPTION_KEY": SERVER_DECRYPTION_KEY } api = metaplex_api.MetaplexAPI(cfg) api_endpoint ="https://api.mainnet-beta.solana.com"

# requires a JSON file with metadata. best to publish on Arweave
divinity_json_file = "https://arweave.net/lafoms3egQiVeboVVSsgIXRH14DiyxmKLwzD_EWiKv8"
contract_name = 'test'
contract_symbol = 'test'

# deploy a contract. will return a contract key.
Balance = Client(api_endpoint).get_account_info(WALLET_PUBLIC_KEY)['result']['value']['data'][0]
result = api.deploy(api_endpoint, contract_name, contract_symbol,0)

contract_key = json.loads(result).get('contract')
print('Sleep started')
#time.sleep(30)
# conduct a mint, and send to a recipient, e.g. wallet_2
mint_res = api.mint(api_endpoint, contract_key, WALLET_PUBLIC_KEY, divinity_json_file)

mdergueche avatar Jan 21 '22 19:01 mdergueche