한 번에 여러 개의 NFT를 채굴하는 애플리케이션을 생성하고, for 루프를 사용해 트랜잭션을 차례로 전송할 수 있습니다. 가장 좋은 방법은 티켓을 사용해 트랜잭션 시퀀스 번호를 예약하는 것입니다. 티켓을 사용하지 않고 NFT를 생성하는 애플리케이션을 만들 경우, 어떤 이유로든 트랜잭션이 실패하면 애플리케이션이 오류와 함께 중지됩니다. 티켓을 사용하는 경우 애플리케이션은 트랜잭션을 계속 전송하며, 나중에 개별 실패의 원인을 조사할 수 있습니다.
기존 계정 시드를 사용하지 않으려면 Get Standby Account Info를 클릭합니다.
Get Standby Account Info를 클릭하여 현재 XRP 잔액을 확인합니다.
Batch Mint NFTs
이 예시를 통해 하나의 고유 아이템에 대해 여러 개의 NFT를 발행할 수 있습니다. NFT는 오리지널 아트워크의 "프린트", 이벤트 티켓 또는 기타 한정된 고유 아이템 세트를 나타낼 수 있습니다.
To batch mint non-fungible token objects:
NFT URI를 입력합니다. 이는 NFT 객체와 관련된 데이터 또는 메타데이터를 가리키는 URI입니다. 고유한 URI가 없는 경우 이 샘플 URI를 사용할 수 있습니다: ipfs://bafybeigdyrzt5sfp7udm7hu76uh7y26nf4dfuylqabf3oclgtqy55fbzdi.
flage 필드를 설정합니다. 테스트 목적으로 값을 8로 설정하는 것이 좋습니다. 이렇게 하면 tsTransferable 플래그가 설정되어 NFT 객체를 다른 계정으로 전송할 수 있습니다. 그렇지 않으면 NFT 개체는 발행 계정으로만 다시 전송할 수 있습니다. 사용 가능한 NFT 발행 플래그는 NFTokenMint를 참조하세요.
Enter the Transfer Fee, a percentage of the proceeds that the original creator receives from future sales of the NFT. This is a value of 0-50000 inclusive, allowing transfer fees between 0.000% and 50.000% in increments of 0.001%. If you do not set the Flags field to allow the NFT to be transferrable, set this field to 0.
값은 0-50000을 포함하여 0.000%에서 50.000% 사이의 전송 수수료를 0.001% 단위로 허용합니다. NFT를 양도할 수 있도록 플래그 필드를 설정하지 않은 경우 이 필드를 0으로 설정합니다.
Enter the Taxon for the NFT. If you do not have a need for the Taxon field, set this value to 0.
Enter an NFT Count of up to 200 NFTs to create in one batch.
Click Batch Mint NFTs.
Get Batch NFTs
Click Get Batch NFTs to get the current list of NFTs for your account.
The difference between this function and the getTokens() function used earlier is that it allows for larger lists of tokens, sending multiple requests if the tokens exceed the number of objects allowed in a single request.
Code Walkthrough
You can download or clone the Quickstart Samples to try each of the samples locally.
Import dependencies and define the testnet_url variable.
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"
Batch Mint
Pass the values seed, uri, flags, transfer_fee, taxon, and count.
for x in range(int(count)):
tickets[x] = acct_objs[x]['TicketSequence']
Initialize variables to be used in the mint loop.
reply=""
create_count=0
Use a for loop to send repeated mint requests, using the ticket_sequence field to uniquely identify the mint transactions.
for x in range(int(count)):
mint_tx=xrpl.models.transactions.NFTokenMint(
account=wallet.classic_address,
uri=xrpl.utils.str_to_hex(uri),
flags=int(flags),
transfer_fee=int(transfer_fee),
ticket_sequence=tickets[x],
sequence=0,
nftoken_taxon=int(taxon)
)
This version of getTokens() allows for a larger set of NFTs by watching for a marker at the end of each batch of NFTs. Subsequent requests get the next batch of NFTs starting at the previous marker, until all NFTs are retrieved.
def get_batch(seed, account):
"""get_batch"""
Get a client instance. Since this is a request for publicly available information, no wallet is required.
client=JsonRpcClient(testnet_url)
Define the request for account NFTs. Set a return limit of 400 objects.
While there is a marker value in the response, continue to define and send requests for 400 account NFTs at a time. Capture the result from each request in the responses variable.