Hello,
I am on the part of creating a smart contract and I decided to create a new .sol file for a different token as well as a different .js migration file. I saved them in the same folder as the other .sol files and migration files. I followed the steps in the video and copy-pasted the code from the Morarabletoken.sol file, just changing the names and the solidity version to the most recent. When I use the command truffle migrate --reset
, only the original 3 items migrate. The new file will almost all the same aspects does not migrate, although it does get recognized by the compiler.
I am working off of the repo available of GitHub and have re-watched this episode a few times, I am not sure which part of it I am missing. Has anyone else had this same issue?
Here is the smart contract made along with the video, I just changed the name of the token.
pragma solidity ^0.8.9;
import "../node_modules/@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "../node_modules/@openzeppelin/contracts/utils/Counters.sol";
contract CCCToken is ERC721 {
using Counters for Counters.Counter;
Counters.Counter private _tokenIds;
constructor () ERC721("CCCToken", "CCCT"){}
struct Item {
uint256 id;
address creator;
string uri;
}
mapping (uint256 => Item) public Items;
function createItem(string memory uri) public returns (uint256){
_tokenIds.increment();
uint256 newItemId = _tokenIds.current();
_safeMint(msg.sender, newItemId);
Items[newItemId] = Item(newItemId, msg.sender, uri);
return newItemId;
}
function tokenURI(uint256 tokenId) public view override returns (string memory) {
require(_exists(tokenId), "ERC721Metadata: URI query for nonexistent token");
return Items[tokenId].uri;
}
}
Here is what the terminal looks like when I run the migrate command:
Starting migrations...
======================
> Network name: 'ganache'
> Network id: 5777
> Block gas limit: 6721975 (0x6691b7)
1_initial_migration.js
======================
Replacing 'Migrations'
----------------------
> transaction hash: 0x48bedbe496b3fdbfcc003a729c2345223082e1cd2998380b0b247f48d8783f1e
> Blocks: 0 Seconds: 0
> contract address: 0x922B3cf0771647274b56DA7c9EA2Fd4f85eB4Bf4
> block number: 55
> block timestamp: 1634259550
> account: 0xFC3984c5FbE8bD4a10644680a8832203f25DdA00
> balance: 99.4767495
> gas used: 248854 (0x3cc16)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.00497708 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.00497708 ETH
2_token_migration.js
====================
Replacing 'MorarableToken'
--------------------------
> transaction hash: 0xfd73d5f3b7d57bf6749f6f27e8ce91e6209c5bbadd9bcb001ba27cae32511022
> Blocks: 0 Seconds: 0
> contract address: 0xe63397b7aF631CF2Df971539828E6673Ec21aE85
> block number: 57
> block timestamp: 1634259552
> account: 0xFC3984c5FbE8bD4a10644680a8832203f25DdA00
> balance: 99.42931952
> gas used: 2328986 (0x23899a)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.04657972 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.04657972 ETH
3_marketplace_migration.js
==========================
Replacing 'MorarableMarketContract'
-----------------------------------
> transaction hash: 0x964d1ab8245aca2f88ac50ff3f1a907a0228fa0847255f25923b21b22aad0113
> Blocks: 0 Seconds: 0
> contract address: 0xCA0A7bE275efD4F40Cf07B0a7F9b4Fb26d8025Cb
> block number: 59
> block timestamp: 1634259553
> account: 0xFC3984c5FbE8bD4a10644680a8832203f25DdA00
> balance: 99.40823778
> gas used: 1026574 (0xfaa0e)
> gas price: 20 gwei
> value sent: 0 ETH
> total cost: 0.02053148 ETH
> Saving migration to chain.
> Saving artifacts
-------------------------------------
> Total cost: 0.02053148 ETH
Summary
=======
> Total deployments: 3
> Final cost: 0.07208828 ETH
So it migrates for the other contracts that were made previously in the repo but not for the one I created myself. I followed the steps in the video with linking Ganache, editing and running frps, writing the contract and creating a migration file.