Search code examples
soliditybrownie

Brownie parser error when trying to compile


I'm very new to coding and while testing to see if this contract would compile I ran into this error. I've tried adding a set of parenthesis to the function but it feels like the more I try to listen to brownie the stranger it begins to look to me. Have I missed something? This is the error:

contracts/AdvancedCollectible.sol:28:18: ParserError: Expected '(' but got identifier function createCollectible(uint256 userProvidedSeed, string memory tokenURI) ^---------------^

What I have written so far is below:

pragma solidity 0.6.6;

import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@chainlink/contracts/src/v0.6/VRFConsumerBase.sol";

contract AdvancedCollectible is ERC721, VRFConsumerBase {
    
    bytes32 internal keyHash;
    uint256 internal fee;
    uint256 public tokenCounter;

    enum Color {Red, Blue, Green}
    // add other things
    mapping(bytes32 => address) public requestIdToSender;
    mapping(bytes32 => string) public requestIdToTokenURI;
    mapping(uint256 => Color) public tokenIdToColor;
    mapping(bytes32 => uint256) public requestIdToTokenId;
    event requestedCollectible(bytes32 indexed requestId); 

    constructor(address _VRFCoordinator, address _LinkToken, bytes32 _keyhash) public {
    VRFConsumerBase(_VRFCoordinator, _LinkToken);
    ERC721("Snails", "SNAIL");
        {
            keyHash = _keyhash;
            fee = 0.1 * 10**18; // 0.1 LINK
            tokenCounter = 0;
        }
        function createCollectible(uint256 userProvidedSeed, string memory tokenURI)
        public returns (bytes32)
        {
            bytes32 requestID = requestRandomness(keyhash, fee, userProvidedSeed);
            requestIdToSender[requestId] = msg.sender;
            requestIdToTokenURI [requestId] = tokenURI;
            emit requestedCollectible(requestId);
        }

        function fulfillRandomness(bytes32 requestID, uint256 randomNumber) internal override{
            address snailOwner = requestIdToSender[requestID];
            string memory tokenURI = requestIdToTokenURI[requestId];
            uint256 newItemId = tokenCounter; 
            _safeMint(snailOwner, newItemId);
            setTokenURI(newItemID, tokenURI);
            Color color = Color(randomNumber % 3);
            tokenIDToColor[newItemId] = color;
            requestIdToTokenId[requestID] = newItemId;
            tokenCounter = tokenCounter + 1; 
            }
    }

Thank you all for your help!


Solution

  • You have an extra curly brace { in your constructor. Also the parent constructors calls should not end with a semicolon ;.

    constructor(address _VRFCoordinator, address _LinkToken, bytes32 _keyhash)
    public // removed the extra `{`
    VRFConsumerBase(_VRFCoordinator, _LinkToken) // removed the `;`
    ERC721("Snails", "SNAIL") // removed the `;`
    {
        keyHash = _keyhash;
        fee = 0.1 * 10**18; // 0.1 LINK
        tokenCounter = 0;
    }