Getting the amount of assets sent to an account

Check the number of asset units you have sent to an account.

Prerequisites

Method #01: Using the SDK

const rawAddress = process.env.ADDRESS as string;
const originAddress = Address.createFromRawAddress(rawAddress);

const recipientRawAddress = process.env.ADDRESS as string;
const recipientAddress = Address.createFromRawAddress(recipientRawAddress);

const mosaicIdHex = process.env.MOSAIC_ID_HEX as string;
const divisibility = 6;
const mosaicId = new MosaicId(mosaicIdHex);

const accountHttp = new AccountHttp('http://localhost:3000');
accountHttp
    .getAccountOutgoingTransactions(originAddress)
    .pipe(
        mergeMap((_) => _), // Transform transaction array to single transactions to process them
        filter((_) => _.type === TransactionType.TRANSFER), // Filter transfer transactions
        map((_) => _ as TransferTransaction), // Map transaction as transfer transaction
        filter((_) => _.recipientAddress instanceof Address &&_.recipientAddress.equals(recipientAddress)), // Filter transactions from to account
        filter((_) => _.mosaics.length === 1 && _.mosaics[0].id.equals(mosaicId)), // Filter mosaicId transactions
        map((_) => _.mosaics[0].amount.compact() / Math.pow(10, divisibility)), // Map relative amount
        toArray(), // Add all mosaics amounts into one array
        map((_) => _.reduce((a, b) => a + b, 0))
    )
    .subscribe(
        total => console.log('Total '+ mosaicId.toHex() +' sent to account', recipientAddress.pretty(), 'is:', total),
        err => console.error(err)
    );
const rawAddress = process.env.ADDRESS;
const originAddress = nem2_sdk_1.Address.createFromRawAddress(rawAddress);
const recipientRawAddress = process.env.ADDRESS;
const recipientAddress = nem2_sdk_1.Address.createFromRawAddress(recipientRawAddress);
const mosaicIdHex = process.env.MOSAIC_ID_HEX;
const divisibility = 6;
const mosaicId = new nem2_sdk_1.MosaicId(mosaicIdHex);
const accountHttp = new nem2_sdk_1.AccountHttp('http://localhost:3000');
accountHttp
    .getAccountOutgoingTransactions(originAddress)
    .pipe(operators_1.mergeMap((_) => _), // Transform transaction array to single transactions to process them
operators_1.filter((_) => _.type === nem2_sdk_1.TransactionType.TRANSFER), // Filter transfer transactions
operators_1.map((_) => _), // Map transaction as transfer transaction
operators_1.filter((_) => _.recipientAddress instanceof nem2_sdk_1.Address && _.recipientAddress.equals(recipientAddress)), // Filter transactions from to account
operators_1.filter((_) => _.mosaics.length === 1 && _.mosaics[0].id.equals(mosaicId)), // Filter mosaicId transactions
operators_1.map((_) => _.mosaics[0].amount.compact() / Math.pow(10, divisibility)), // Map relative amount
operators_1.toArray(), // Add all mosaics amounts into one array
operators_1.map((_) => _.reduce((a, b) => a + b, 0)))
    .subscribe(total => console.log('Total ' + mosaicId.toHex() + ' sent to account', recipientAddress.pretty(), 'is:', total), err => console.error(err));

If you want to check another mosaic different than the native currency, change mosaicId and divisibility for the target mosaic properties.

const mosaicId = new MosaicId([3562970624, 976072438]);
const divisibility = 6;