Comments (7)
Yes you can load totalSupply just by pulling from your contract.
If you find the line in your rendered code
{data.totalSupply}
I removed it and added this HTML in the same place
`<s.TextTitle
id="totalNumbers"
style={{
textAlign: 'center',
fontSize: 50,
fontWeight: 'bold',
color: 'var(--accent-text)',
}}
Minted VS Total Supply
</s.TextTitle>`
Then I wrote a function to update that HTMLID with the contract values instead of the config file
`async function passMaxNFT() {
var x = myContract.methods.MAX_NFT().call();
return x;
}
async function passTotalMinted() {
var y = myContract.methods.totalSupply().call();
return y;
}
async function showTotalMax() {
await passTotalMinted()
await passMaxNFT()
document.getElementById('totalNumbers').innerHTML =
(await passTotalMinted()) + '/' + (await passMaxNFT());
}
showTotalMax();`
from hashlips_nft_minting_dapp.
where are you dropping these functions ? in blockchainactions.js or in app.js ?
from hashlips_nft_minting_dapp.
where are you dropping these functions ? in blockchainactions.js or in app.js ?
In app.js
from hashlips_nft_minting_dapp.
Hi heisenbergpromotions, thanks for your solution! Unfortunately its not working when i just paste ist under the Line "{data.totalSupply} / {CONFIG.MAX_SUPPLY}"
It would be very nice if you could sent more infos where exactly you did rewrite to app.js !
Thank you
from hashlips_nft_minting_dapp.
Could you please elaborate or provide the full code changes. Thanks in advance.
from hashlips_nft_minting_dapp.
i solved this problem creating an API that calls the supply number and pasting it on the script/head of the index.html file.
Follow this:
Paste the code below on the of your HTML (dont forget to replace the CONTRACTHERE and APIHERE by your NFT contract address and API (create an API by loging on etherscan):
<script>
function getTokenSupply() {
const apiUrl = `https://api.etherscan.io/api?module=stats&action=tokensupply&contractaddress=CONTRACTHERE&apikey=APIHERE`;
fetch(apiUrl)
.then(response => response.json())
.then(data => {
const result = parseInt(data.result);
document.getElementById("result").innerHTML = result + '/10000';
});
}
getTokenSupply();
Now go to your APP.JS file and replace this code:
```
<s.TextTitle
style={{
textAlign: "center",
fontSize: 60,
color: "var(--accent-text)",
fontFamily: "Beachday",
}}
>
{data.totalSupply} | {CONFIG.MAX_SUPPLY}
</s.TextTitle>
By this new code
```
<s.TextTitle
id="result"
style={{
textAlign: "center",
fontSize: 60,
color: "var(--accent-text)",
fontFamily: "Beachday",
}}
>
Conect...
</s.TextTitle>
Certify that you have to turn down adblocker to make sure that this code will gonna work correctly. I use brave browser and i had to deactivate the protection to my dapp minting site, but now its working perfectly.
Hope it helps.
from hashlips_nft_minting_dapp.
HI Thanks for your help! Now I have one Problem ... it just shows only "Conect" where the Minting Amount should be.
Do you have any tips? Thanks!
from hashlips_nft_minting_dapp.
Related Issues (20)
- gas limit too high?
- Issue with parameter vs to: address
- interaction with thirdweb HOT 2
- Looking for a way to display totalSupply from the contract before connecting wallet HOT 1
- Error: Unhandled Rejection (Error): No "from" address specified in neither the given options, nor the default options.
- Confused about storage part
- error unsupported network HOT 3
- Logo error
- No option for whitelisting and pre-sale
- Code modification HOT 2
- Gas fee estimation error in polygon network
- Can't Get Minting Dapp to work with polygon Testnet HOT 1
- 71 vulnerabilities (13 low, 19 moderate, 36 high, 3 critical....
- Page Blank on Hostinger HOT 1
- Why from mobie the connect button don't open the metamask app?
- Issue deploying on Netlify
- npm warn deprecated
- Error Assertion failled HOT 1
- Uncaught runtime errors if i cancel the minting transaction.
- Error: Invalid number of parameters for "addData". Got 1 expected 4!
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from hashlips_nft_minting_dapp.