Heavily inspired by Minecraft Dungeons, SoulsAPI adds soul currency to the game. The Souls API mod comes with a soul count variable for every player, that you can do what you want with. Souls drop from an entity, even if not killed by a player. When the souls are put in the player's inventory, the soul item gets deleted and adds 1 to the soul count. This is still unstable, and if any issues are found, I would like to hear it.
Variable name: "SoulCount"
Variable type: NUMBER
Variable scope: PLAYER_LIFETIME
Initial value: 0