ethers-io / ethers.js

Complete Ethereum library and wallet implementation in JavaScript.
https://ethers.org/
MIT License
7.99k stars 1.86k forks source link

TypeError: Cannot redefine property: ethereum #4855

Open yudhomax opened 1 month ago

yudhomax commented 1 month ago

Ethers Version

5.7.2

Search Terms

No response

Describe the Problem

when i reload the page this error always occure

Code Snippet

window.ethereum = m,
                        Object.defineProperty(window, "ethereum", {
                            set: function(t) {
                                console.log("Setting value:", t),
                                t.isCoin98 && (this.c98walletAggregator = t)
                            },
                            get: function() {
                                return this.c98walletAggregator
                            },
                            enumerable: !0,
                            configurable: !1
                        }),

Contract ABI

No response

Errors

TypeError: Cannot redefine property: ethereum

Environment

No response

Environment (Other)

No response

ricmoo commented 1 month ago

Is this ethers code?

yudhomax commented 1 month ago

i don't know, but getting error from here Screenshot from 2024-10-08 11-41-57

jasonandjay commented 1 month ago

This error has nothing to do with ethers.js

It indicates that the property ethereum has been defined (probably by a browser plugin) and cannot be defined again. However, there is no logic to hijack ethereum in ethers.js. You need to check your code or disable some plugins

This issue can be closed @ricmoo @yudhomax