I get the following error when I run “truffle migrate”
ReferenceError: Token is not defined
at module.exports (/Users/Eleanor/Desktop/Blockchain/DAPP/academy-kitties-template-master/migrations/1_initial_migration.js:4:19)
at Migration._load (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:55:1)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at Migration.run (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:217: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/run.js:76:1)
at Object.module.exports [as run] (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/commands/migrate/run.js:44:1)
This is my code in the migrations file:
const Token = artifacts.require("Santacontract");
module.exports = function (deployer) {
deployer.deploy(Token);
};
This is my contract code:
pragma solidity ^0.8.0;
import "./IERC721.sol";
contract Santacontract is IERC721 {
//Token name
string public constant _name = "SantaFactory";
//Token symbol
string public constant _symbol = "SF";
struct Santa {
uint256 genes;
uint64 birthTime;
uint32 mumId;
uint32 dadId;
uint16 generation;
}
Santa[] santas;
// constructor(
// uint256 memory totalSupply_,
// string memory name_,
// string memory symbol_
// ) {
// _totalSupply = totalSupply_;
// _name = name_;
// _symbol = symbol_;
// }
// Mapping from token ID to owner address
mapping(uint256 => address) public santaIndexToOwner;
// Mapping owner address to token count
mapping(address => uint256) ownershipTokenCount;
function balanceOf(address owner) external view returns (uint256 balance) {
return ownershipTokenCount[owner];
}
function totalSupply() public view returns (uint256) {
return santas.length;
}
function name() external pure returns (string memory tokenName) {
return _name;
}
function symbol() external pure returns (string memory tokenSymbol) {
return _symbol;
}
function ownerOf(uint256 _tokenId) external view returns (address) {
address owner = santaIndexToOwner[_tokenId];
return owner;
}
function transfer(address _to, uint256 _tokenId) external {
require(_to != address(0), "ERC721: owner query for nonexistent token");
require(
_to != address(this),
"ERC721: owner query for contract address"
);
require(_owns(msg.sender, _tokenId));
_transfer(msg.sender, _to, _tokenId);
}
function _transfer(
address _from,
address _to,
uint256 _tokenId
) internal {
ownershipTokenCount[_to]++;
santaIndexToOwner[_tokenId] = _to;
if (_from != address(0)) {
ownershipTokenCount[_from]--;
}
//Emit the transfer event
emit Transfer(_from, _to, _tokenId);
}
function _owns(address _claimant, uint256 _tokenId)
internal
view
returns (bool)
{
return santaIndexToOwner[_tokenId] == _claimant;
}
}
May I also check if we still need to install ganache as if I run truffle dev I can receive the 9 addresses and private keys already