Building Migrations for 1155 Discussion

i deployed locally into ganache

migrate --network development

i also deployed on ropsten test network:

migrate --network ropsten --skipDryRun

truffle(develop)> (await GameToken.at("0x6d41e3Da1F72840e9B0Ff7D3adeC718BBBCb75A2")).balanceOf("0xD893842417CB9928eD4f27A702a2310cF1fF004a",1).then(bn => bn.toNumber())
Uncaught:
Error: Cannot create instance of GameToken; no code at address 0x6d41e3Da1F72840e9B0Ff7D3adeC718BBBCb75A2
truffle(develop)>

i still have this error:

Error: Cannot create instance of GameToken; no code at address 0x6d41e3Da1F72840e9B0Ff7D3adeC718BBBCb75A2

Hello @patgeek

With Ganache, have you setup your Metamask to connect to the local blockchain? then you have to check the web3 instantiation in your eth.js (browser game) to connect to the local host (where the local blockchain is)

With kind regards

Hello @patgeek,

With Ropsten, beside changing the network of your Metamask, make sure you use Truffle console instead of Truffle develop. With the Truffle console, you can interact with the Ropsten network, so if you deployed the contract there with a migration script you then be able to interact with it.

Hope the information makes it more clear for you
With kind regards

i used truffle console: but error tells me i have not enough funds to test
But in my truffle-config.js file i use the mnemonic of my metamask wallet where there are 3 eth

truffle(ropsten)> (await GameToken.at("0x6d41e3Da1F72840e9B0Ff7D3adeC718BBBCb75A2")).balanceOf("0xD893842417CB9928eD4f27A702a2310cF1fF004a",2)
Uncaught:
{
  code: -32000,
  message: 'err: intrinsic gas too low: have 2000, want 21548 (supplied gas 2000)'
}
truffle(ropsten)>

Hello @patgeek

You can increase the gas limit in your truffle config file, or remove it for testing purposes

     network_id: 3,       // Ropsten's id
     **gas: 5500000,**        // Ropsten has a lower block limit than mainnet
     confirmations: 2,    // # of confs to wait between deployments. (default: 0)

With kind regards

As I don´t use the older ERC1155 version but the current version of openzeppelin.

I have encountered a problem while trying to figure out what the correct way is to get the same result with different tools. I have a problem while migrating.

At the last migration file I get this error
TypeError: (intermediate value).create is not a function at createToken1

What would be the quivalent function there?
I am running everything locally on ganache.
Here is the link to my repository https://github.com/paulsimroth/eth_game

Hello @PaulS96,

If I remember it right, using the current version of Openzeppelin would mean you will skip doing the create part because mint function already does the creation of the token. I think this was done for gas optimization, avoiding a 2-step process in creating the tokens.

Hope the information is useful to you
With kind regards

@alp257 Thanks. I looked through the contract and after that came to the conculsion, that it should work without create so I just commented it out for now.

1 Like