Mint POAP
Minting a POAP is an asynchronous process, but with PoapsClient
it can be simplified
to only one method call.
Async
If you prefer to send the minting to the server and then wait for the POAP to be minted, and eventually, once indexed, the token ID can be retrieved.
import { POAP } from '@poap-xyz/poaps';
// Initiate the asynchronous mint process.
await client.mintAsync({
mintCode: 'your_mint_code',
address: 'your_address',
});
// Wait for the mint's status to transition from 'IN_PROCESS' or 'PENDING' states.
await client.waitMintStatus('your_mint_code');
// Wait for the minted POAP to be indexed and fetch the mint code information related to the Mint Code.
const { poapId } = await client.waitPoapIndexed('your_mint_code');
// Retrieve the minted POAP.
const poap: POAP = (
await client.fetch({
offset: 0,
limit: 1,
ids: [poapId],
})
).items[0];
Sync
All the minting processes can be done automatically by PoapsClient
.
import { POAP } from '@poap-xyz/poaps';
const poap: POAP = await client.mintSync({
mintCode: 'your_poap_code',
address: 'your_address',
});
Don't forget to handle custom errors.