dex.sol(contract A)
//SPDX-License-Identifier: MIT
pragma solidity 0.8.19;
import "./storage.sol";
contract dex1{
storage_contract public contractaddress;
constructor(address _storageContract){
contractaddress = storage_contract(_storageContract);
}
function addmoney(uint amount)public returns(uint){
uint balance = contractaddress._addmoney(amount);
return balance;
}
function getbalance(address _address)public view returns(uint) {
uint balance = contractaddress._getbalance(_address);
return balance;
}
}
storage.sol (contract B)
//SPDX-License-Identifier:MIT
pragma solidity 0.8.19;
contract storage_contract{
mapping(address => uint) public balances;
function _addmoney(uint _money)public returns(uint) {
return balances[msg.sender] += _money;
}
function _getbalance(address _address)public view returns(uint){
return balances[_address];
}
}
Here when i tried to store a value from dex1 using addmoney() and try to retrieve the value by getbalance() but i'm not getting any.Here i want to access the values stored in the storage contract from the dex1 contract?
I have tried to many importing techiniques like using direct addressess and .call functions but they didnt workout but when i removed the parameters in getbalance() in dex1 and _getbalance() in storage_contract and changed the return balances[_address]; as return balances[msg.sender];we can able to retrevieving but i dont want this method of retreiving