0

When we redeploy a smart contract , Is the smart contract updated on the same block of the blockchain where the first smart contract was created or it is stored on a new or different block ?

2 Answers 2

1

from wikipedia

A blockchain is a growing list of records, called blocks, that are securely linked together. Each block contains a cryptographic hash of the previous block, a timestamp, and transaction data

Each block contains information about the block previous to it, they form a chain, with each additional block reinforcing the ones before it. Therefore, blockchains are resistant to modification of their data because once recorded, the data in any given block cannot be altered retroactively without altering all subsequent blocks.

Smart contracts code is compiled to byte code and the resulting bytes are sent within a transaction to be persisted onto the Ethereum blockchain. This is done once when you deploy the smart contract so the contract becomes forever a part of the blockchain and its address never changes.

When you deploy a new version of your smart contract, again the code is compiled and sent within a transaction to the blockchain, a new account is created with a different address and in order to interact with this version you need to use the new address (unless you use upgradability)

Upgrading smart contracts

Smart contracts can be upgraded to modify their behavior, while preserving their address, state, and balance, but you need to use more than one smart contract to achieve this. The basic idea is to use a proxy, the first contract is a simple wrapper or “proxy” which users interact with directly and is in charge of forwarding transactions to and from the second contract, which contains the logic

take a look at this article

0

Blocks once created can not be modified, hence the new deployment is stored on a new block.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.