Suppose a contract,which is working with ERC20, lets call it contract-1, is already deployed onchain and functioning properly in real world. I want to add some functionality in it. But as we know smart contracts can't be changed after deployment so i decided to use the interface of that contract in newly created contract, lets call it contract-2, with added functionality. As i said contract-1 already has users and tokens are already distributed, so the added functionality will be like if some one mint 10000 token they will get reward,my question is, is it possible to get the current status, like who has how many tokens, of contract-1 from contract-2 [by calling functions from contract-2] ???? I want to do this. How can do it??
Yeah, this is super simple.
First, you will need the deployed contract address, and second, the contract interface.(interface makes things easier than using call method).
Then you can wrap the address inside the interface like this
interfaceName contract1 = interfaceName(ADDRESS);
And now the contract1 variable will contain every function of the deployed contract, and you can call them like this: (Suppose a function named Balance(address))
This way you can call the functions, but remember only the external and public functions can be called.
Let me know if this was clear or I'll try to improve the answer.