const TonWeb = require('tonweb');
const tonweb = new TonWeb(
new TonWeb.HttpProvider('https://ton-mainnet.core.chainstack.com/.../api/v2/jsonRPC')
);
// Replace with the actual Jetton master contract address and owner wallet address
const jettonMasterAddress = 'EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs'; // e.g., mainnet USDT
const ownerWalletAddress = 'UQ...';
async function fetchJettonWalletAddress(jettonMasterAddress, ownerWalletAddress) {
try {
const jettonMinter = new TonWeb.token.jetton.JettonMinter(tonweb.provider, {
address: jettonMasterAddress
});
const jettonWalletAddress = await jettonMinter.getJettonWalletAddress(
new TonWeb.utils.Address(ownerWalletAddress)
);
const jettonWallet = new TonWeb.token.jetton.JettonWallet(tonweb.provider, {
address: jettonWalletAddress
});
const jettonData = await jettonWallet.getData();
// Verify that the Jetton Minter address matches
if (jettonData.jettonMinterAddress.toString(false) !== jettonMinter.address.toString(false)) {
throw new Error('Jetton minter address from jetton wallet does not match the expected minter address');
}
console.log('Jetton wallet address:', jettonWalletAddress.toString(true, true, true));
} catch (error) {
console.error('Error fetching jetton wallet address:', error);
}
}
fetchJettonWalletAddress(jettonMasterAddress, ownerWalletAddress);