You can easily determine IMEI and serial number by going to Settings app → General → About and search for fields named IMEI and Serial Number (along with the host of other information).
The other key step to be taken before giving away your iPhone is to make sure you have synchronized all your important data (Contacts, Pictures, Notes, etc.) to iCloud. Also, make a backup of iPhone if you want to restore it to a new iPhone. The backup can be created either on iCloud or a Mac or Windows computer that uses iTunes.
After backing up all important user data, make sure that logs out by iCloud. To log out of iCloud, go to the Settings app, tap your name shown with profile image (this should be the first item just below the search box), scroll down and tap Logout (last item shown in red). You can also be asked to turn off Find My iPhone . Do it by tapping iCloud on the same screen and clicking Find My iPhone. Switch to turn off the switch shown in front Find my iPhone.
When you log out, iPhone asks you to choose between deleting or storing data (Contacts, Notes, Reminders, etc.) locally on the device. It is recommended to delete the data from your device when you give it away. As an additional safety measure, it is recommended to reset the factory device. Do it by going to Settings app → General → Reset and touch Delete All Content and Settings. You may be asked to enter the password for the device.
Once the device has been deleted, do not reset it before deleting. It is possible to see the IMEI number on an iPhone that is not configured.
It is recommended to review the Apple Support Document. What to do before selling, giving away or shopping on iPhone, iPad or iPod? Touch and make sure to follow all of the official guidelines.