XRPLF / xrpl-py

A Python library to interact with the XRP Ledger (XRPL) blockchain
ISC License
148 stars 84 forks source link

[NFT-Devnet] Request failed, invalid transaction error #344

Closed ObiajuluM closed 2 years ago

ObiajuluM commented 2 years ago

Hello, i am trying to mint an nft, but I keep on getting an error, please help:

code:


from xrpl.wallet import Wallet  
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions.nftoken_mint import NFTokenMint

testnet_url = "https://s.altnet.rippletest.net:51234"
client = JsonRpcClient(testnet_url)

sender_addr = "rhK5YNf4Xh3LQCsyzLMgauomfT862PhevU"
wallet_seed = "seed"

acc_info = AccountInfo(account=sender_addr, ledger_index="validated")
response = client.request(acc_info)
result = response.result
sequence = result["account_data"]["Sequence"]
wallet_obj = Wallet(seed=wallet_seed, sequence=sequence)

my_payment = NFTokenMint(account=sender_addr,
token_taxon=2343)

print(my_payment)

signed_tx = safe_sign_and_autofill_transaction(
    my_payment,
    wallet_obj,
    client)

product = send_reliable_submission(signed_tx, client)

max_ledger = signed_tx.last_ledger_sequence
tx_id = signed_tx.get_hash()

print(product.status)```

#error:
``` NFTokenMint(account='rhK5YNf4Xh3LQCsyzLMgauomfT862PhevU', transaction_type=<TransactionType.NFTOKEN_MINT: 'NFTokenMint'>, fee=None, sequence=None, account_txn_id=None, flags=0, last_ledger_sequence=None, memos=None, signers=None, source_tag=None, signing_pub_key='', txn_signature=None, token_taxon=2343, issuer=None, transfer_fee=None, uri=None)
Traceback (most recent call last):
  File "c:\Users\0xEarl\Desktop\Learn_XRP\nft.py", line 33, in <module>
    product = send_reliable_submission(signed_tx, client)
  File "c:\Users\0xEarl\Desktop\Learn_XRP\venv\lib\site-packages\xrpl\transaction\reliable_submission.py", line 32, in send_reliable_submission
    return asyncio.run(async_send_reliable_submission(transaction, client))
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "c:\Users\0xEarl\Desktop\Learn_XRP\venv\lib\site-packages\xrpl\asyncio\transaction\reliable_submission.py", line 90, in send_reliable_submission
    submit_response = await submit_transaction(transaction, client)
  File "c:\Users\0xEarl\Desktop\Learn_XRP\venv\lib\site-packages\xrpl\asyncio\transaction\main.py", line 142, in submit_transaction        
    raise XRPLRequestFailureException(response.result)
xrpl.asyncio.clients.exceptions.XRPLRequestFailureException: Request failed, invalidTransaction: Unknown field```
JST5000 commented 2 years ago

Hey @ObiajuluM, it seems you're connected to the wrong server :)

There's a dedicated NFT sandbox server at this url: wss://xls20-sandbox.rippletest.net:51233 (I got the link from this tutorial on how to play around with NFT's in the sandbox here: https://xrpl.org/nftoken-tester-tutorial.html)

You'll want to replace the testnet_url you have with wss://xls20-sandbox.rippletest.net:51233 Additionally you'll have to get credentials for the NFT-Devnet specifically, which you can get by going to this faucet website and clicking "Generate NFT-Devnet Credentials": https://xrpl.org/xrp-testnet-faucet.html (Then replacing your sender_addr and wallet_seed with the values generated)

Hopefully this helps!

ObiajuluM commented 2 years ago

You'll want to replace the testnet_url you have with wss://xls20-sandbox.rippletest.net:51233 Additionally you'll have to get credentials for the NFT-Devnet specifically, which you can get by going to this faucet website and clicking "Generate NFT-Devnet Credentials": https://xrpl.org/xrp-testnet-faucet.html (Then replacing your sender_addr and wallet_seed with the values generated)

thanks but the devnet faucet returns this error, There was an error with the NFT-Devnet faucet. Please try again.

JST5000 commented 2 years ago

Oh, thanks for letting me know! I'll let you know when that's fixed :)

mvadari commented 2 years ago

Relevant issue: https://github.com/XRPLF/xrpl.js/issues/1895

JST5000 commented 2 years ago

@ObiajuluM you should be able to generate credentials from the faucet now (The issue @mvadari linked is a feature request to get the faucet wallet in code, but for now the manual method should work :) )

ledhed2222 commented 2 years ago

Closing - the issue was that @ObiajuluM connected to the wrong server

ObiajuluM commented 2 years ago

hello @JST5000 the error remains😥

image
JST5000 commented 2 years ago

@ObiajuluM Huh, I think this might be a new issue with the same symptoms, I'll look into it :)

For reference, and I should have mentioned this earlier, I think the cause last time was not enough validators on the NFT Devnet network agreeing on the ledger. (AKA we had less than quorum) - If you want to check that, you can look at the NFT Devnet explorer here and ensure there are ledgers getting a green checkmark still :) (Since that seems to be working fine now, I think it's a new cause)

mvadari commented 2 years ago

@ObiajuluM it should be working now.

ObiajuluM commented 2 years ago

Hello, I need help in creating an NFT but I always end up in an error HELP:

Traceback (most recent call last):
  File "c:\Users\0xEarl\Desktop\Learn_XRP\apeft.py", line 23, in <module>
    wallet_obj = create_WalletObject(sender_addr, wallet_seed)
  File "c:\Users\0xEarl\Desktop\Learn_XRP\apeft.py", line 17, in create_WalletObject
    response = client.request(acc_info)
  File "c:\Users\0xEarl\Desktop\Learn_XRP\venv\lib\site-packages\xrpl\clients\sync_client.py", line 28, in request
    return asyncio.run(self.request_impl(request))
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 642, in run_until_complete
    return future.result()
  File "c:\Users\0xEarl\Desktop\Learn_XRP\venv\lib\site-packages\xrpl\asyncio\clients\json_rpc_base.py", line 39, in request_impl
    return json_to_response(response.json())
  File "c:\Users\0xEarl\Desktop\Learn_XRP\venv\lib\site-packages\httpx\_models.py", line 1415, in json
    return jsonlib.loads(self.text, **kwargs)
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\json\__init__.py", line 346, in loads
    return _default_decoder.decode(s)
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 337, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "C:\Users\0xEarl\AppData\Local\Programs\Python\Python39\lib\json\decoder.py", line 355, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

code:

from xrpl.models.requests.account_info import AccountInfo
from xrpl.wallet import Wallet  
from xrpl.transaction import safe_sign_and_autofill_transaction, send_reliable_submission
from xrpl.clients import JsonRpcClient
from xrpl.models.transactions.nftoken_mint import NFTokenMint

testnet_url = "https://xls20-sandbox.rippletest.net:51233"
client = JsonRpcClient(testnet_url)

sender_addr = "rDAUZJogeeprHnJFzsTz6xz9piXPfUHCgv"
wallet_seed = "key"

def create_WalletObject(wallet_addr: str, wallet_seed: str) -> Wallet:
    """creates a wallet object for signing transactions"""
    acc_info = AccountInfo(account=wallet_addr, ledger_index="validated")
    response = client.request(acc_info)
    result = response.result
    sequence = result["account_data"]["Sequence"]
    wallet_obj = Wallet(seed=wallet_seed, sequence=sequence)
    return wallet_obj

wallet_obj = create_WalletObject(sender_addr, wallet_seed)

my_payment = NFTokenMint(account=sender_addr,
token_taxon=0)

print(my_payment)

signed_tx = safe_sign_and_autofill_transaction(
    my_payment,
    wallet_obj,
    client)

product = send_reliable_submission(signed_tx, client)

max_ledger = signed_tx.last_ledger_sequence
tx_id = signed_tx.get_hash()

print(product.status)
print(product.result)
JST5000 commented 2 years ago

@ObiajuluM there's a couple things I notice:

  1. When using the JsonRpc client you actually need a slightly different port - JsonRPC is on 51234 instead of 51233, which is causing the issue you're seeing. (That error is because nothing is being returned, which causes the decoder to crash on an empty input)

To fix that use this JsonRPC url: http://xls20-sandbox.rippletest.net:51234

  1. Your secret is just labeled "key" (That might just be because you're uploading it here, but that needs to be a real value from the faucet)

Hopefully that helps!

ObiajuluM commented 2 years ago

thanks @JST5000 you are a true bro 🤜🤛

JST5000 commented 2 years ago

Closing since it seems things are sorted out now :)