When you restore your phone, everything is set back to the factory shipped state. As far as your contacts, if you sync them to your phone with iTunes, they are still on your computer. Just use iTunes to restore them.
Make sure to sync your phone 1st. Click preference on iTunes, go to the iPhone tab just to make sure that it has been backed up. iTunes stores all information of your iPhone everytime you sync it. So the next time you restore your phone it will restore everything back to the time when you last synced your phone.