This is just to ensure that no transfer will be made considering the origin account as destination. This is a problem if we use a batch operation (two conditional updates to execute the transfer).
This will do:
random_transfer(){
from=$((RANDOM % N_ACCOUNTS))
to=$((from + 1))
if [[ $to -ge $N_ACCOUNTS ]]; then
to=0
fi
amount=1
transfer ${from} ${to} ${amount}
}