HashLips / hashlips_nft_minting_dapp

HashLips minting dapp is a quick and easy way to connect your smart contract and start minting NFTs.
MIT License
1.02k stars 980 forks source link

Address (account) specific fetch data from contract #106

Open Smitkas opened 2 years ago

Smitkas commented 2 years ago

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?

Shawncity commented 2 years ago

hey did you ever fix this issue?

Shawncity commented 2 years ago

I have the same problem

Smitkas commented 2 years ago

hey did you ever fix this issue?

no