Hi all!
I can’t figure out why the data is not returned when requesting data from the contract that is specific to a specifically connected wallet.
At the same time, data is read correctly through remix and the "READ" function in the contract itself.
For example, I can fetch cost values to dapp from the function:
function cost() public view returns (uint256)
{
if (publicStartDate < block.timestamp) {
return publicsalePrice;
} else {
if (presaleStartDate < block.timestamp) {
return presalePrice;
}
}
But when trying to fetch remainToken values from this function to dapp:
function remainToken() external view returns (uint256) {
uint256 rCount = tokenToMint[msg.sender];
return(rCount);
}
it returns 0 to me!!!
There is such a suspicion that the request comes from the contract address, and not from the wallet address, therefore the correct value is not returned
If I understand correctly, the data fetching takes here, in the file dataActions.js
export const fetchData = () => {
return async (dispatch) => {
dispatch(fetchDataRequest());
try {
let maxSupply = await store
.getState()
.blockchain.smartContract.methods.maxSupply()
.call();
let totalSupply = await store
.getState()
.blockchain.smartContract.methods.totalSupply()
.call();
let cost = await store
.getState()
.blockchain.smartContract.methods.cost()
.call();
let tokenToMint = await store
.getState()
.blockchain.smartContract.methods.tokenToMint()
.call();
dispatch(
fetchDataSuccess({
totalSupply,
maxSupply,
cost,
tokenToMint,
})
);
} catch (err) {
console.log(err);
dispatch(fetchDataFailed("Could not load data from contract."));
}
};
};
Hi all! I can’t figure out why the data is not returned when requesting data from the contract that is specific to a specifically connected wallet. At the same time, data is read correctly through remix and the "READ" function in the contract itself.
For example, I can fetch cost values to dapp from the function:
function cost() public view returns (uint256) { if (publicStartDate < block.timestamp) { return publicsalePrice; } else { if (presaleStartDate < block.timestamp) { return presalePrice; } }
But when trying to fetch remainToken values from this function to dapp: function remainToken() external view returns (uint256) { uint256 rCount = tokenToMint[msg.sender]; return(rCount); }
it returns 0 to me!!! There is such a suspicion that the request comes from the contract address, and not from the wallet address, therefore the correct value is not returned
If I understand correctly, the data fetching takes here, in the file dataActions.js
export const fetchData = () => { return async (dispatch) => { dispatch(fetchDataRequest()); try { let maxSupply = await store .getState() .blockchain.smartContract.methods.maxSupply() .call(); let totalSupply = await store .getState() .blockchain.smartContract.methods.totalSupply() .call(); let cost = await store .getState() .blockchain.smartContract.methods.cost() .call(); let tokenToMint = await store .getState() .blockchain.smartContract.methods.tokenToMint() .call(); dispatch( fetchDataSuccess({ totalSupply, maxSupply, cost, tokenToMint, }) ); } catch (err) { console.log(err); dispatch(fetchDataFailed("Could not load data from contract.")); } }; };
There is a solution?