Deploying Game to the Testnet Discussion

@thecil

SimpleGame repo

https://github.com/Uy4n/SimpleGame

You might see there is a migration file outside of the Migrations folder. That’s because its use was unsuccessful for me, but maybe it will work for you.

I’m struggling a bit with deploying to Ropsten. If anybody has some insight into what I might be doing wrong, I would love to hear it :sweat_smile:

I have set up an account, gained 5 ETH via a faucet, and followed the instructions for setting up truffle-config.js.

However, when I run “truffle migrate --network ropsten” I get the following error:

Error: *** Deployment Failed ***
“Migrations” – insufficient funds for gas * price + value

Most answers I have been able to find via Google have suggested that either there is not a high enough ETH balance or that the gas price is set too high.

As far as I can tell, however, 5 ETH should be more than enough even at a high gas price…

Here’s my network config data for Ropsten in case it helps:

ropsten: {
      provider: () => new HDWalletProvider(mnemonic, `https://ropsten.infura.io/v3/${infuraKey}`),
      network_id: 3,       // Ropsten's id
      gas: 5500000,        // Ropsten has a lower block limit than mainnet
      gasPrice: 200,
      confirmations: 2,    // # of confs to wait between deployments. (default: 0)
      timeoutBlocks: 200,  // # of blocks before a deployment times out  (minimum/default: 50)
      skipDryRun: true     // Skip dry run before migrations? (default: false for public nets )
    }

Try setting gas price in truffle.js file.

    gasPrice: 10000000000 // Something price like this

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

@thecil

Still not working unfortunately… I got the same error even with the higher gas price :frowning:

Any ideas for further troubleshooting?

1 Like

You can check here the gas limit that you can also try to change and the gasPrice.

https://ropsten.etherscan.io/blocks

you can play around with those variables so the next miner accept your migration files, thats a common problem with testnet that have different gas limit and prices.

so i suggest to:

  • set gasprice to gwei (10000000000 i think is 1 gwei, get a wei calculator and run some calcs)
  • set gas limit close to the values showed from the blockchain explorer i sent you.

If you have any more questions, please let us know so we can help you! :slight_smile:

Carlos Z.

Figured it out. Turns out I was being a dodo and using the wrong mnemonic phrase… :man_facepalming:

Thank you for your help @thecil!

1 Like

Hey guys. So i made a small post in the first section of the token implementation part of the course documenting the exact process i took to get things runinng and owrking with truffle web3 etc because this course is a few years old and a lot of things are quite outdated and we3 seems to have evolved a lot since 2018. So the purpose of this post is to again, show the exact steps that i took and the changes i made to get things working. Again I am a newbie myself but i like to share this to both reinforce what i have learned and also in hope that this post may be of use to someone who is very stuck. This section posed an ever greater challenge than the first one as there is a lot more intricate parts to get right and it took me the whole morning and afternoon to complete this section.

If you follow this and it does not work then i suggest going back to the first section and look at my first post there so you can see exactly what versions im using and what changes i made back there. Im writing this post on april 22/ 2021, so just scroll to that timeframe in the first section and you should see my post. Anyways

The first step is with the “My ether wallet” part where we create a wallet of addresses that we can use with infura so that we can configure truffle to deploy to the ropsten testnet. Teh myetherwallet website has changed a lot since Filips recording so this is what you can do. Go to the mnumonic code converter website.

https://iancoleman.io/

The first thing you will need to do is to make sure that Coin is selected to Ethereum because the webpage originally defaults to bitcoin and for obvious reasons we dont want to make a wallet of btc addresses for this project.
Mnemonic
generate the seed phrase as Filip does. you can use 12 or 24 it doesnt really matter i chose 12 myself. After the code is generated before you go to the myEtherWallet website first scroll down the page until you see a large list of wallet addresses. Copy anyone of the addresses private keys. (you will see why shortly)
Mnemonic2
Now that you have the private key coped go to the MyEtherWallet websiste

https://www.myetherwallet.com/

When on the home page instead of creating a new wallet, click the option to access wallet. On the next page choose the option
software
After this choose the option to access account via private key and walla you will be brought to you account dashboard. And thats it for this part. However remember to keep your private key and original seed phrase safe if you want to continue testing with this wallet. Note that this is not the securest way to access myEtherWallet, but for dev purposes its fine.

Next we want to link this account with metaMask so just simply follow the steps Filip goes through as there is nothing different here

After this we have to set set up infura. This is straight forward and again you can copy the steps that Filip has in the video. The infura website has changed a little but alls your doing is making a new project. When you have made your account and created a new GameToken project just simply copy the infura key

Now this is where things get harder. I am going to share the exact code an changes that i made. There are a few little things we need to change from Filips video. The first step that we do after copying the infura key is to go to our truffle-config.js file to set up infura wit truffle. The only change that i had to make here was to change the format of the HDWalletProvider. In the video Filips code shows it to be

'truffle-hdwallet-provider'

However for me to get things to work laster when we npm install the truffle hd wallet provider i had to change the above to

't@ruffle/hdwallet-provider'

Here is the exact code
hdcode

Next we uncomment the ropsten object in the truffle-config.js file since we are connecting to the ropsten testnet. Now this is where i was running into so many errors originally. When using Filips original code i kept getting an “'ETIMEDOUT” timeout error when trying to migrate to the ropsten testnet. Eventually i got it fixed by changing his code to the code below

ropcode

The only real changes are the addition of the netWorkCheckTimeout: 1000000, line and also change the link in the first line to include v3 followed by the infura key. I think it was the netWorkCheckTimeout that stopped the above error but i also thing it may have been to do with my internet connection at the time but i cant say for sure.

The next thing that Filip does is to npm install the truffle hardware wallet in the terminal. When i installed using the command he provides which is

npm install truffle-hdwallet-provider

i kept getting errors when trying to later migrate to ropsten. I think for me there were a few reasons for this. Firstly being that i think that specific npm command points to an older version of the wallet perhaps. The command that i used is given as

npm install --save-dev @truffle/hdwallet-provider

the most important thing here is the --save-dev part as running this install without it also did not work for me. I think the addition of --save-dev allows specific dependencies to be included but im not really sure why this works i need to loook into the actual meaning of --save-dev more.

Note that i work using GitBash on windows so i didnt come across the fatal error that Filip mentions in the video. I assume this is because im using Gitbash but maybe i was just lucky i dont know.

So when the truffle hd wallet is installed, if you followed the changes that i made and run the command

truffle migrate --network ropsten

everything should work perfectly. I think when i did it i actually did a truffle migrate reset before runing the ropsten command. Not sure if this is nessecary however.

The last part of this section involved making changes in the eth.js file to change our web3 provider to work with metaMask instead of the local truffle develop blockchain which is run locally on our computer. The code in Filips video is outdated so i will show you the changes that i made to get it to work. At the top of the file intead of writing

web3 = new Web3(web3.currentProvider)

(which is currently deprecated) instead use what i have in my code below

web3

And with that everything else that Filip does doesnt need any changing. If you followed my exact path from the beginning of the web3 section of the course then things should work for you. I hope this post becomes of use to someone who is struggling because i sure was for hours.

Evan

4 Likes

Hi All,

I am not sure if this is the right place to post. I hope to get some insight from experts on the forum. Forgive me if i didn’t explain well.

My situation is like this:

I have tried to deploy my game to the Ropsten Testnet. I have obtain a Ropsten endpoint in infura.

I have generated a wallet on myetherwallet, selected the first account generated from the seed phase, picked the ropsten network, and deposited around 1.98 ETH inside.

https://ropsten.etherscan.io/address/0xDb4371C2cFCe0023D71438f69dd6e0A72ef434d0

However, when i try to deploy the smart contract to the testnet, it gives me the error message “Migrations” – insufficient funds for gas * price + value.

I am a bit puzzled because ropsten.etherscan.io says I have 1.98 ETH already, why am I getting insufficient fund for gas?

I have tried truffle migrate --network ropsten --reset but with no luck. It still gives me the same error message.

One thing I am puzzled about is that when I input my seed phase in mnemonic, is it getting the fund from 0xDb4371C2cFCe0023D71438f69dd6e0A72ef434d0? After all, there are alot of different account with zero balance corresponds to the seed phase.

192-168-1-104:Solidity marcochu$ truffle migrate --network ropsten --reset

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.



Starting migrations...
======================
> Network name:    'ropsten'
> Network id:      3
> Block gas limit: 16732371 (0xff50d3)


1_initial_migration.js
======================

   Deploying 'Migrations'
   ----------------------

Error:  *** Deployment Failed ***

"Migrations" -- insufficient funds for gas * price + value.

    at /usr/local/lib/node_modules/truffle/build/webpack:/packages/deployer/src/deployment.js:365:1
    at processTicksAndRejections (internal/process/task_queues.js:93:5)
    at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:74:1)
    at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:61:1)
    at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:212:1)
    at Object.runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:150:1)
    at Object.runFrom (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:110:1)
    at Object.runAll (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:114:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/index.js:79:1)
    at runMigrations (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:258:1)
    at Object.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate.js:223:1)
    at Command.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/command.js:147:1)
Truffle v5.3.6 (core: 5.3.6)
Node v14.15.4
192-168-1-104:Solidity marcochu$ truffle migrate --network ropsten --reset

Thx.

I think I solve it. I just put the private key in mnemonic. :grinning:

3 Likes

Hey thanks for your assistance I cannot find the private key on the dashboard any idea where it is?

1 Like

Hello, having some trouble with the Mew Wallet. Anybody have a work around or a different wallet provider? Apparently they won’t show you private keys. Also tried to export the wallet as a JSON but that didnt work either said it had to be V3.

1 Like

Hey are you on about the that site where u make a wallet for ropsten. Theres actually much better way to do this. Have you ganache. Or if this is one of your first course have you used ganache before?

I remeber what i did with this part was i went to that iancoleman website and just copied the private key from the site and made my wallst that way. I explain how to do it in that post above. If yoy do it the way in the video youll cant get the private key which isnso weird i also ran into that hiccup so juat try follow my guide above or else just use ganache and import one if the accounts into metamask when u deploy to ropsten and get an ether faucet. If you havent done it with gamache before let me know ill explain more

Hi guys I have a problem with deploying my token to the testnet (ropsten). I got these error messages:

Schermafbeelding 2021-07-19 om 15.39.06

I don’t understand where the problem is.

https://github.com/theavaragejoe/EthereumGame.git

If my question is unclear please let me know.

Hahaha you legend.

I reckon this could’ve kept me up for COUNTLESS hours.
So boy do I appreciate you :kiss:

1 Like

hey @jak no worries dude

Set the file eth.js to .currentProviders but a connection to MetaMask/Ropsten Test Network is not made

Code:

web3 = new Web3(Web3.currentProviders);
ethereum.enable();

Would appreciate any help. Thank you.

At the end of the game, I get a prompt asking for my eth address, I put my eth address but I do not receive the confirmation of “transaction completed”. I played the game many times and on different days to await the case was slow network but after all, looking at Etherscan and there are no minted tokens. I appreciate any help. Thank you!

1 Like

Could you please share the code you are using to connect the game instance with web3? Could be the index.js file right?

Our amazing @mcgrane5 has done a very nice quick guide on the process he take to connect truffle and web3 by this date, maybe this could be helpful for your case :nerd_face:

Carlos Z

1 Like

I wasn’t able to find the link for classic MEW and this lecture is too old to be useful, so here’s what I did instead:

I generated the mnemonic through the BIP39 site, then went to privatekeys.pw/mnemonic/ethereum to convert the mnemonic into a private key, and then I used that private key to import the address into Metamask. From there I visited:

faucet.ropsten.be

to obtain test coins. That seems to work.

I think it is extremely important to point out that your Metamask generates one seed phrase for your addresses, so do NOT use your Metamask seed phrase to generate the private key if you are connected to your main Metamask wallet (the one that would hold your valuables)! You must use the BIP39 site to generate a whole new key that has nothing to do with your actual Ethereum wallet. After all, you are sending your seed phrase over the internet to a website, there’s no knowing what kind of security they are running or if anyone is listening to user inputs. If you use your actual Metamask seed phrase then you run the risk of someone grabbing it and using it to steal all your funds!

So, now I get to decide if I’m going to spend the ETH to move $4000 of tokens to my hardware wallet or if I’m going to let it go and hope nobody was listening when I put my seed phrase into the private key generator… :\