I have a list of asset Ids and their contract Id and want to track who owns how much of these assets? I was looking into envio indexer where you can track events. The issue is when I was going through the code for asset transfer function:
pub fn transfer_to_address(to: Address, asset_id: AssetId, amount: u64) {
// maintain a manual index as we only have `while` loops in sway atm:
let mut index = 0;
// If an output of type `OutputVariable` is found, check if its `amount` is
// zero. As one cannot transfer zero coins to an output without a panic, a
// variable output with a value of zero is by definition unused.
let number_of_outputs = output_count();
while index < number_of_outputs {
if let Output::Variable = output_type(index) {
if output_amount(index) == 0 {
asm(r1: to.value, r2: index, r3: amount, r4: asset_id) {
tro r1 r2 r3 r4;
};
return;
}
}
index += 1;
}
revert(FAILED_TRANSFER_TO_ADDRESS_SIGNAL);
}
There is no event emitted in this so how do I track this? Do I need to track every transaction of UTXO input/outputs?
Also, there could be assets whose contract id we don’t have what to do in that case?