Token Minted
Description
Authentication
Request
Headers
Content-Type: application/json
Authorization: Bearer <your_jwt_token>
Body Parameters
Parameter
Type
Required
Description
Response
Success Response
Error Response
Example Usage
// Basic implementation
async function confirmTokenMinting(
tokenMintAddress: string,
transactionSignature: string
) {
try {
const response = await fetch('https://api.heyhal.xyz/api/v1/coin/minted', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Bearer ${localStorage.getItem('auth_token')}`
},
body: JSON.stringify({
token: tokenMintAddress,
tx: transactionSignature
})
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const result = await response.json();
return result.success;
} catch (error) {
console.error('Error confirming token minting:', error);
throw error;
}
}
// Complete minting flow manager
class TokenMintingManager {
private wsConnection: WebSocket | null = null;
constructor(private readonly wsUrl: string) {
this.initializeWebSocket();
}
private initializeWebSocket() {
this.wsConnection = new WebSocket(this.wsUrl);
this.wsConnection.onmessage = (event) => {
const data = JSON.parse(event.data);
if (data.type === 'TOKEN_MINTED') {
this.handleMintingComplete(data.token, data.status);
}
};
}
async confirmMinting(
tokenMintAddress: string,
transactionSignature: string
) {
try {
await confirmTokenMinting(tokenMintAddress, transactionSignature);
// Subscribe to WebSocket updates for this token
this.wsConnection?.send(JSON.stringify({
type: 'SUBSCRIBE_TOKEN',
token: tokenMintAddress
}));
} catch (error) {
console.error('Minting confirmation failed:', error);
throw error;
}
}
private handleMintingComplete(token: string, status: string) {
// Implement your success handling logic here
console.log(`Token ${token} minting completed with status: ${status}`);
}
cleanup() {
this.wsConnection?.close();
}
}
Implementation Notes
Best Practices
Last updated