'The event 'close' is deprecated and may be removed in the future

I want the best method to implement these two lines. Goal: Obtain the object of a smart contract named dev-token.

async function ... {
    ...
    const web3 = new Web3(Web3.givenProvider);
    const devtoken = await new web3.Contract(abi,address);
    ...
}

Warning during execution:

MetaMask: The event 'close' is deprecated and may be removed in the future. Please use 'disconnect' instead. For more information, see: https://eips.ethereum.org/EIPS/eip-1193#disconnect

Cordially



Solution 1:[1]

I had the same problem due to an out-of-date version of the web3.js library. I was using version 1.2 imported from the jsdelivr CDN like this:

<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/web3.min.js"></script>

The warnings went away when I updated to the current version of web3.js (1.7.3 at the time of this writting). However, the version distributed in the jsdelivr CDN has other problems, so I had to deliver from my own server the one downloaded by npm:

<script src="./web3.min.js"></script>

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jorge M. Londoño P.