Can you modify a smart contract once deployed?

5
0

Hi, once a smart contract is deployed and NFTs minted, can it be modified? If yes, are there any restrictions on modifications? Thank you!


To post an answer, please !

1 answer

66 views

In general, no. The smart contract that is deployed to the blockchain is immutable, so the code cannot be changed after creation. Any NFTs that are minted are tied to the contract they were minted by, so the code underpinning the NFTs cannot be changed. Some projects have "migrated NFTs" when they realized they needed to upgrade the smart contract, which means re-creating the NFTs using the new contract, airdrop NFTs to holders and burn the NFTs on the old contract (or otherwise disable them). ​ There are ways to work around these limitations by using "proxy contracts" or following the Diamond pattern when developing contracts. Smart contracts can call other smart contracts, for example to check if the user holds an NFT of a different contract. It's possible to write a contract to hold the address of the other contract (which you want to query) in a variable that can be updated by the owner of the contract. This update is done using a regular transaction to change the variable to a new value. That way, that contract can be pointed at a new "version 2" of the other contract when you need to upgrade the other contract. With a bit of planning up front to determine which contracts contain business logic (which you want to upgrade) and which contracts hold NFTs and storage, you'll achieve the ability upgrade the business logic when needed. ​ Here is a simple schematic of how this works, from the BlockMagnates blog post I'm linking below: ​ proxy-contract.jpeg​ Here, the User is querying the proxy contract that also stores the state (for your use-case that would be the ownership details for the NFTs f.ex.). The proxy contract has a pointer to the Logic Contract and uses that to execute any business logic needed as part of the transaction the user initiated. The Logic Contract can be swapped for a new version when needed, while the Proxy Contract stays the same. ​ You can read more about the proxy contract pattern in the official OpenZeppelin docs for example: https://docs.openzeppelin.com/upgrades-plugins/1.x/proxies And the more recent Diamond pattern which takes this approach to the next level, here: https://blog.blockmagnates.com/building-scalable-systems-on-ethereum-using-diamond-eip-2535-44ab83e8c25c

6
0

Great answer, Ethspresso!!

0
0

Not the answer you're looking for? Browse other questions tagged #NFTs #Web3 #General #Smart Contracts or ask your own question.