ERC721 Assignment Code

Hello! @
I am unable to compile this code of mine as it throws this error:
Different number of components on the left hand side (1) than on the right hand side (0).
Here’s My code;


// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./IERC721.sol";
import "./Ownable.sol";

contract Kittycontract is IERC721, Ownable  {

   uint256 public constant CREATION_LIMIT_GEN0 =10;
    string public constant name="ETHKitties";
    string public constant symbol="EK";

    event Birth (address owner,
                 uint256 kittenId,
                 uint256 mumId, 
                 uint256 dadId,
                 uint256 genes)

    ; struct Kitty{
        uint256 genes;
        uint64 birthTime;
        uint32 mumId;
        uint32 dadId;
        uint16 generation;
    Kitty[]  kitties;

   mapping (uint256=> address) public kittyIndexToOwner;
    mapping (address=> uint256) ownershipTokenCount;
    uint256 public gen0Counter;

    function getKitty(uint256 _id) external view returns(
        uint256 genes,
        uint256 birthTime,
        uint256 mumId,
        uint256 dadId,
        uint256 generation
    Kitty storage kitty= kitties[_id];

    birthTime = uint256 (kitty.birthTime);
    mumId= uint256 (kitty.mumId);
    generation= uint256 (kitty.generation);

    function createKittyGen0(uint256 _genes) public onlyOwner returns (uint256){
        require(gen0Counter < CREATION_LIMIT_GEN0);


        //GenO have no owners they are owned by the master contract
        return _createKitty(0, 0, 0, _genes, msg.sender);


    function _createKitty(
        uint256 _mumId,
        uint256 _dadId,
        uint256 _generation,
        uint256 _genes,
        address _owner
    ) private returns (uint256) 
        Kitty memory _kitty= Kitty({
            genes: _genes,
            generation:uint16 (_generation)


        uint256 newKittenId = kitties.push(_kitty) -1;

        require(newKittenId == uint256(uint32(newKittenId)));
        emit Birth (_owner, newKittenId, _mumId, _dadId,_genes);

        _transfer(address(0), _owner, newKittenId);
        return newKittenId;

    function balanceOf(address owner) external view returns (uint256 balance){
        return ownershipTokenCount[owner];

    function totalSupply() public view returns(uint256 total)
        return kitties.length;

    function ownerOf(uint256 _tokenId) external view returns(address)
        return kittyIndexToOwner[_tokenId];
    function transfer (address _to, uint256 _tokenId) external
        require(_to != address(0));
        require (_to != address(this));
        require (_owns(msg.sender, _tokenId));

        _transfer(msg.sender, _to, _tokenId);

     function _transfer( address _from,address _to, uint256 _tokenId) internal{
        kittyIndexToOwner [_tokenId] = _to;
        if (_from != address(0))

        // Emit the transfer function event.
        emit Transfer (_from, _to, _tokenId);

      function _owns(address _claimant, uint256 _tokenId) internal view returns (bool)
            return kittyIndexToOwner[_tokenId]== _claimant;

Look forward for quick help concerning this matter.

1 Like

the error its on codeline 75, trying to get a number from 2 different operators.

uint256 newKittenId = kitties.push(_kitty) - 1;

You cant push and operate the result of it.

You could try this instead:

        kitties.push(_kitty); // we add the new kitty into array
        uint256 newKittenId = kitties.length - 1; // get the length of the array and decrement 1

Carlos Z

Thanks a lot, good sir.
It worked.

1 Like