The grace comes through a faith that is not dead. .............
Step one, study Romans 4 really slow.
Perhaps you need to review Revelation 22:18-19.
Romans 4:5 does not contradict James 2 in any way, since that’s about works alone.