import { initialise, Chain, Token } from '@prudra/core';
import { transfer, getTransaction } from '@prudra/wallet';
initialise({ apiKey: process.env.PRUDRA_API_KEY! });
// Initiate bridge
const tx = await transfer({
fromWalletId: 'mwt_clx1abc123',
fromWalletType: 'master',
fromToken: Token.USDC,
toAddress: '0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045',
toChain: Chain.POLYGON,
toToken: Token.USDC,
amount: '10.00',
});
console.log(tx.status); // 'pending'
console.log(tx.txHash); // source chain tx hash
// Poll until confirmed (prefer webhooks instead)
let current = tx;
while (current.status === 'pending') {
await new Promise(r => setTimeout(r, 30_000));
current = await getTransaction({ transactionId: tx.id });
}
console.log(current.status); // 'confirmed'
console.log(current.confirmedAt); // ISO timestamp