Giving you the benefit of the doubt and that you are hearing the traditional rod knock, as mentioned you need to stop driving it before causing more issues and higher repair costs. If you have the ability to swap in a motor, you basically have the ability to rebuild the 22r, it is a rather simple engine design. If this is a truck you plan to drive for years to come I would go head and rebuild the entire motor, but if funds are tight you could get by with just new rod bearings, though it is a lot of work to just replace the bearings, and not rebuild the whole engine. You should be able to rebuild the engine yourself for about $350-600 depending on what machine work/hourly rate is needed on the crankshaft.
Engine Builders will have about the best prices on oem quality Toyota parts and their warranty/customer service is outstanding.