Sun and Moon trade from the Festival Plaza, not with a code: tap Trade, then Link Trade, and pick a player from your Guest List. The GTS and Wonder Trade closed with the 3DS servers in April 2024.
How to trade in Sun & Moon
Open the Festival Plaza from the touch-screen menu.
Tap Trade, then Link Trade.
Choose your partner from the Guest List and pick the Pokémon to send.