2

How can I add function and array to already deployed contract on the main net.

User[] public registeredArray;

function getAllUsers()public view returns(User[] memory){

return registeredArray;

}

How do I add this array to the struct of the deployed contract and also this new function to it? Need to add to the deployed contract

Dimple
  • 788
  • 1
  • 11
  • 27
  • Read the answer Upgradeable smart contracts here: https://ethereum.stackexchange.com/questions/2404/upgradeable-smart-contracts - unless you are an expert in Solidity my suggestion is that you do not even try it, because it is out of your skill class. – Mikko Ohtamaa Sep 29 '21 at 11:09

1 Answers1

2

In short, you can't change deployed contract code.

Generally, you want to make your contract upgradeable the first time you deploy it, and even with that, you still need to deploy a new contract every time you want some sort of new functionality, what changes is basically that you have a proxy contract that stores the contract that is actually being used.

Worth to give a look at writing-upgradeable

regcostajr
  • 170
  • 2