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

Viewed 150

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

1 Answers

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

Related