dfx dev here, I likely cannot help with anything besides the wallets.json file.
The code above assumes that
you have a wallet configured and
you have it configured for the identity called default
Every identity that has a wallet configured has the file ~/.config/dfx/identity/<identity name>/wallets.json.
If you have no identity with a configured wallet, please follow the instructions here to create a wallet yourself (or go through the faucet).
If you have an identity with a wallet already, you just have to navigate to the right identity’s folder.
If you have a wallet, but it’s not configured in dfx, you can use dfx identity set-wallet (choose the right network with --network).