I'd like to return to the first issue:
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at http://localhost:8545/. (Reason: CORS request did not succeed).
If you're trying to connect to localhost:8545, I assume that you're trying to connect MetaMask to a local node.
Essentially, MetaMask is trying to connect to ...
Your two ABI-encoded objects are:
If the encoded function changes the state of the contract, then ...
I had the same issue and using once for events filtering also didn't work.
I had to stop provider from polling events.
You can do it like this:
bytesContract.provider.polling = false
This is what ethers documentation says about it
If the provider is currently polling because it is actively watching
for events. This may be ...