- Your spouse is the primary earner
- You had a 1099 side-job earning $15k
- You put all $15k in a solo-401(k) plan
Would you earn any social security credits in this situation?
You'll need to pay self-employment tax, so you can't put all the $15K in 401k. Half of the SE tax is a deduction from your self-employment income (See the IRS website). Contributing to 401k plan only defers the income tax.
Self-employment tax is what determines how many SSA credits you get from self-employment (since the income taxable under SE tax is the income reported to the SSA).
What you do with the income is entirely up to you and you can do with it whatever you want, including contributing it into tax-deferred accounts if allowed.