Deploying Game to the Testnet Discussion

So I was able to get everything working correctly earlier today, but noticed that after the game finished there is something wrong with the number of tokens that get minted. After playing the game and getting a score of 46, you can see that 0.000000000000000000046 tokens are minted.

I suspect the issue is that because I’m using a newer version of OpenZeppelin wherein the number of decimals is set automatically to 18, while Filip manually set his number of decimals to zero.

Is it possible to redeploy contracts to the Ropsten network, much like we did in our local truffle server? I figure I could redeploy and set the number of decimals in the ERC20.sol file to zero.

1 Like

Hello @CaliCrypto22
You got it, I had the same result.
More or less, you have to deploy a new contract with the modifications (spending some testnet eth in the process) and changing the token address in your frontend code - this is because of the immutability nature of a blockchain.

A solution you can explore is creating proxy contracts (check Ethereum Smart Contract Security course) where you replace an old contract with a new one to have a seamless transition with your users and without any data loss.

So I made the backend changes to my solidity code (changing from default 18 decimals to zero decimals). Then I created a new project in infura, inserted the new infurakey into the appropriate places in my truffle config file, and then tried to redeploy (truffle migrate --network ropsten).

For some reason that didn’t work. This is the error message I got:

Well, it’s not really an error message; it’s telling me that the modified contract didn’t get redeployed to a new address.

I’m not sure what I did wrong? Do I need to create a whole new mneumonic phrase and Metamask account too?

Should be fine using the same Metamask account to fund the deployment.
Based on the message, since the Truffle migration tracks the deployment of smart contracts you made in the blockchain it recognizes the first deployment you made. To reset the migration you have to add in the
‘–reset’ (with the double dash) command: truffle migrate –reset --network ropsten

1 Like

That worked. Thanks!!

1 Like

very helpful thanks!
Now it even works for me and minted tokens :smiley:

1 Like

When I type this line ‘npm install --save-dev @truffle/hdwallet-provider’ I get this error.

Also some different commands I typed tried connecting me to git. Is that supposed to happen?

1 Like

Those are just warning messages, is not related directly to your installation, you should be fine to continue :nerd_face:

Carlos Z

1 Like

Hey. I’m really enjoying the course but have ran into some trouble when I connected to Ropsten. When I open my game, I am able to connect to metamask, however once I input the address it doesnt do anything except ask me to input the address again. Any reasons as to why this is the case?

Hello @TypicalGamer,

You may be on the right track with the course. Are there any errors shown in the console of the browser after interacting with your Metamask wallet? Have you gotten to the point of the course where you put in code to mint tokens?

With kind regards

1 Like

Hi. I checked the console of the browser and realised there was an error regarding the mint function I had. It has been resolved excpet I get many decimals for my tokens when they are minted. Also whilst using infura with the ropsten test network, does it mean that we are not using truffle? Is there some sort of diagram showing how they interact by any chance?

Hello @TypicalGamer,

Writing it down for you (instead of a diagram):

Developer workflow:

Write your code in VS Code (or something similar) -> Truffle (using this for compilation, deployment) -> Infura (Node provider to interact with the blockchain) -> Ropsten test network (blockchain where smart contract is deployed)

User workflow:

Interact with the browser (i.e. Chrome + Metamask) <-> Web server (i.e. where the website/app is hosted) <-> Infura (Node provider to intereact with the blockchain) <-> Ropsten test network (blockchain where smart is deployed)

Hope this is helpful to you.
With kind regards

2 Likes

Thats very helpful. Do you have a discord by any chance? @alp257

Same problem SOLVED !

1 Like

Hello @TypicalGamer

Yes, I do. Recommending also asking around at Moralis Discord for insights, especially the Troubleshooting channels or the Moralis Academy channel there. There are several Moralis Mages ready to help community members. It’s a habit that I’m also active here in the Academy forum.

Adding a note: Instead of Infura as a node provider, you can use Moralis’ speedy nodes.

With kind regards

whta faucet is recommended for the new testnetworks like Goerli or Sepolia? Thanks in advance

Hello @PaulS96,

You can get Goerli Eth in https://goerlifaucet.com/ but you need to create and login with an Alchemy account (there’s a free plan tier, and you might use it anyway in the future).

With kind regards

2 Likes

Take a look at this guide :nerd_face:

Carlos Z

2 Likes

Thanks for the information !

Thanks for the information !