This comes up a lot when professors visit other universities, actually. In mathematics it is common to use footnotes on the front page to cover grants and visits. So in the author list you might have
John Q. Public1
University of Wheresistan
with a footnote saying
1This author was partially supported by NSF grant 12345. Research was conducted while visiting the University of Whatsitville.
The exact formatting and content is something that will ultimately be determined by the journal in question, and your particular circumstances. The note may also include a thank you to the hosting university, or it may be split up (one footnote for the funding, another for the hosting/thanks). You can probably find several examples like this just by surveying (the first page of) current research articles.
So I'd suggest using an author footnote on the first page that includes the pertinent information. Use your current contact information and use the footnote to briefly mention the role played by other institutions and grants. You can consult the journal's style guide--and if you're still unsure, ask an editor--to see if they have any specific requests or instructions for this sort of entry. I believe most journals are fairly generous in what they allow here, and leave it up to you to make sure the proper thanks are given.