Distribuisci & Esegui Contratti Proxy
Remix IDE has the functionality to assist in the handling of proxy contracts that use the UUPS pattern.
A UUPS contract is an implementation contract that contains both the business logic and the upgrade mechanism. It is deployed alongside an ERC1967Proxy, which delegates all calls to it.
Distribuzione
To try this out, you will need a UUPS contract. Create a new Workspace in Remix and click the Contract Wizard. In the Wizard’s Upgradeability section check UUPS and in the Access Control section, choose Ownable. Then compile it, and open Deploy & Run.
Nota
UUPS contracts use an initialize function instead of a constructor. Call initialize via the proxy after deployment to set up initial state. The constructor is intentionally disabled with _disableInitializers().
When a UUPS contract is selected in Deploy & Run’s Contract dropdown, you’ll see some switches below the Deploy button:

Turn on the Deploy with Proxy switch. This will create two transactions: one for the implementation (your contract) and the other for the ERC1967 proxy contract. You will get two modals to check through:

e poi

Se si sta eseguendo la distribuzione sulla Macchina Virtuale di Remix, queste finestre compariranno una dopo l’altra. Se si è connessi alla rete principale o a una rete di prova pubblica, il secondo messaggio apparirà dopo che la prima transazione è stata eseguita.
Dopo che il contratto proxy ERC1967 è stato distribuito, nella sezione Contratti Distribuiti, si vedranno due istanze distribuite.

Per interagire con il proprio contratto di implementazione NON utilizzare l’istanza del proprio contratto. Si deve invece usare il Proxy ERC1967. Il proxy avrà tutte le funzioni della tua implementazione.
Aggiornamento
To upgrade, turn on the Upgrade with Proxy switch to reveal the address input:

Dovrai usare l’ultimo contratto ERC1967 distribuito, oppure inserire l’indirizzo del contratto ERC1967 che vuoi utilizzare.
Upgrading deploys your new implementation contract as a separate transaction, then calls upgradeToAndCall on the proxy to point it at the new address. Like deploying, this produces two modals: one to confirm the new implementation deployment and one to confirm the upgrade call on the proxy.
Nota
Your implementation contract must include an _authorizeUpgrade function. Without it, the upgrade transaction will revert. OpenZeppelin’s UUPS base contract requires you to override this function with access control (typically onlyOwner) to prevent unauthorized upgrades.