Building Migrations for 1155 Discussion

hey @jelle_van_der_meer , no worries at all, My pleasure. Glad you find them helpful!!

1 Like

Hello everyone, I am trying to deploy a erc-1155. I am encountering 2 issues. I want to deploy a erc-1155 with a uri, is there any good docs about implementing that ? Secondly, I am following the walkthrough and I am encountering a problem when I do a truffle migrate, It seems that .create is deprecated, anyone knows the new function that is implemented , Here is the problem : Capture dā€™eĢcran 2021-07-07 aĢ€ 22.11.27 Thanks in advance for your help :slight_smile:

2 Likes

Hey @Tumbleur, hope you are well.

Based on the console message, there could be an issue in your 4_create_tokens_migrations.js file at code line 13. maybe you have a simple typo error.

Carlos Z

1 Like

Okay, so hereā€™s the latest issue/problem Iā€™ve encountered: When I try to compile and migrate my files (creating and deploying the 1155 token) I get the following error message:

Error: Cannot find module ā€˜@babel/registerā€™

I can see that I pulled in ā€œBabelrcā€ when I cloned the ERC1155 github repository (see screenshot below) . . . so my guess is that I need to install Babel, or something like that.

How do I do that? I found something via Google that told me to run the following code:

npm install babel-register --save-dev

I tried it but that didnā€™t work. Any ideas?

Hello @CaliCrypto22 ,
Unfortunately, I did not experience the same error. Only now I realize I also pulled in ā€˜.babelrcā€™ which is also included with the code we need to clone for the course. I donā€™t remember it will be used in any part in the course. My guess it is just part of the ERC1155 standard that was proposed 2 years before it got finalized by Ethereum.

Hope this is helpful.
With kind regards,

Hey @CaliCrypto22, hope you are well.

Could you please share the link of the github repo that you cloned?

Maybe you just have to install all the packages with npm install

You can also delete the package-lock.json to try to download a new version of the dependencies.

Carlos Z

Thanks . . . I went back and started from scratch, using all of Filipā€™s code at the following link: https://github.com/filipmartinsson/Ethereum-Game-Programming-Course/tree/master/Building-our-ERC1155-Token/Setting%20Up%20the%20Environment

I cloned all the github files using this link: https://github.com/filipmartinsson/erc-1155

It seems to be working now (I was able to migrate the files). I have no idea why, but my best guess is that the code (via the link above) got updated while the code in the video did not (my original code, which did not work, was created by following Filip in the video).

2 Likes

I donā€™t quite understand the part about the 3_marketplace_migration.js from ā€œBuilding Migrations Part 2ā€

If the constructor of the Marketplace Contract takes ā€œIERC1155 tokenā€ as an input why do we need to specify the address of GameToken instead? What is the connection there?

Hello @Konzaih

In this case, since GameToken is already deployed (thereā€™s already an instance of it) and you need that instance to be used in the marketplace, you can simply pass the address of that contract instance. And, you only have to use ā€˜IERC1155ā€™ since GameToken (can be other ERC1155 token as well) is expected to support the ERC1155 standard so the functions stated in the interface is callable within the marketplace contract.

Hope this makes it a bit more clear for you.
With kind regards

1 Like

In case someone struggles with the .balanceOf call, execute the command with square brackets around the tokenId unlike the code in the video.

(await GameToken.at(ā€œGameTokenContractAddressā€)).balanceOf(ā€œMarketplaceContractAddressā€, [TokenId]).then(bn=> bn.toNumber())

1 Like

having issues with trying to migrate.
See image below.

Hello @Scott815,

For further analysis, can you share your code?

Could be one of the ff:

  • ā€˜Tokenā€™ in the migration script should be the name of the smart contract (not the file name)
  • Check if the smart contract (*.sol) has compile errors before running the migration
  • Truffle configuration

With kind regards

What does it seem like is going wrong here? May it be something with my truffle-config file? Itā€™s a problem with the minting functionality.

Hello @limitlessandrew

Try separating minting the 3 different tokens. Do the mint one at a time like you did with .create. mint and await Token1 first then proceed to mint Token2.

Hope that helps.
With kind regards

No, unfortunately I got the same error. It says that the tx doesnā€™t have the correct nonceā€¦

Hello @limitlessandrew

Commonly, such error is network-related (blockchain to node interaction). What testnet are you deploying? Have you tried using a different wallet? or, redeploying your smart contracts.

With kind regards

1 Like

I figured it out. I think I was missing an await somewhere. I could use some help on my post in the Unity Blockchain Programming course though. Iā€™m not seeing my script show up in the Components drop down. Which TA is assigned to that course?

Hello @limitlessandrew

Great work, you managed to figure it out. I think thecil or maybe someone else is checking that course, not sure. Iā€™ll try to check it out.

With kind regards

i am stucked when interacting with GameToken in truffle:

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

Here is my GameToken contract:

 
pragma solidity >=0.4.22 <0.9.0;

import "../lib/ERC1155.sol";
import "../lib/ERC1155Mintable.sol";

contract GameToken is ERC1155, ERC1155Mintable{

  constructor() public{

  }

}

when i interact with GameToken:

truffle(develop)> (await GameToken.at("0xD899196527bE27e48D86631b05BB61C2695d49dF")).balanceOf("0xcdb92A6f4DCa0A69e6EB0C118a6F70BD50e869c5",1).then(bn => bn.toNumber())

i have this error:

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

0xD899196527bE27e48D86631b05BB61C2695d49dF is the contract address of GameToken

Hello @patgeek, greetings

Have you deployed the contract using a migration script in Truffle?
Where have you deployed the contract, in testnet or locally?

With kind regards