mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-28 15:45:50 +00:00
Re-level non-docs content to top of repo and rename content→docs
This commit is contained in:
57
_code-samples/quickstart/py/mod3.py
Normal file
57
_code-samples/quickstart/py/mod3.py
Normal file
@@ -0,0 +1,57 @@
|
||||
import xrpl
|
||||
from xrpl.clients import JsonRpcClient
|
||||
from xrpl.wallet import Wallet
|
||||
from xrpl.models.requests import AccountNFTs
|
||||
|
||||
testnet_url = "https://s.altnet.rippletest.net:51234"
|
||||
|
||||
def mint_token(seed, uri, flags, transfer_fee, taxon):
|
||||
"""mint_token"""
|
||||
# Get the client
|
||||
minter_wallet=Wallet.from_seed(seed)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
# Define the mint transaction
|
||||
mint_tx=xrpl.models.transactions.NFTokenMint(
|
||||
account=minter_wallet.address,
|
||||
uri=xrpl.utils.str_to_hex(uri),
|
||||
flags=int(flags),
|
||||
transfer_fee=int(transfer_fee),
|
||||
nftoken_taxon=int(taxon)
|
||||
)
|
||||
# Submit the transaction and get results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.submit_and_wait(mint_tx,client,minter_wallet)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
|
||||
|
||||
def get_tokens(account):
|
||||
"""get_tokens"""
|
||||
client=JsonRpcClient(testnet_url)
|
||||
acct_nfts=AccountNFTs(
|
||||
account=account
|
||||
)
|
||||
response=client.request(acct_nfts)
|
||||
return response.result
|
||||
|
||||
|
||||
def burn_token(seed, nftoken_id):
|
||||
"""burn_token"""
|
||||
# Get the client
|
||||
owner_wallet=Wallet.from_seed(seed)
|
||||
client=JsonRpcClient(testnet_url)
|
||||
burn_tx=xrpl.models.transactions.NFTokenBurn(
|
||||
account=owner_wallet.address,
|
||||
nftoken_id=nftoken_id
|
||||
)
|
||||
# Submit the transaction and get results
|
||||
reply=""
|
||||
try:
|
||||
response=xrpl.transaction.submit_and_wait(burn_tx,client,owner_wallet)
|
||||
reply=response.result
|
||||
except xrpl.transaction.XRPLReliableSubmissionException as e:
|
||||
reply=f"Submit failed: {e}"
|
||||
return reply
|
||||
Reference in New Issue
Block a user