How to write a contract for a token