Possible to get userid on event for entity?

Need help figuring out how to go about getting a user’s id on attack event for an entity. Seems simple enough I just can’t figure out what the command would be to get the userid of the player attacking the ent.

For example (pseudo-code):
get playerid
give playerid money

Thanks for any help, very appreciated.