-
I am on lesson 3, making the StorageFactory. Instead of names and fav numbers, I am doing Token Tickers and prices. I tried resolving this in multiple ways, and ended up copying the whole contract exactly as it is posted, then I went back and changed the variable names to match my scheme and TokenEntry.sol contract from lesson 2. Can you help me figure out why the retrieve term on the last line will not compile? After you find the solution, please explain how I can find solutions like this in the future. pragma solidity ^0.8.0;
import "./TokenEntry.sol";
contract TokenGenerator {
TokenEntry[] public TokenEntryArray;
function createTokenGenerator() public {
TokenEntry TokenEntryCopy = new TokenEntry();
TokenEntryArray.push(TokenEntryCopy);
}
function TokenGenIndex(uint256 _TokenEntryIndex, uint256 _TokenEntryNumber) public {
TokenEntryArray[_TokenEntryIndex].store(_TokenEntryNumber);
}
function TokenGenReader(uint256 _TokenEntryIndex) public view returns(uint256){
return TokenEntryArray[_TokenEntryIndex].retrieve();
}
} |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 5 replies
-
Hello @0xFLT Here is your fixed code: // SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./TokenEntry.sol";
contract TokenGenerator is TokenEntry {
TokenEntry[] public TokenEntryArray;
function createTokenGenerator() public {
TokenEntry TokenEntryCopy = new TokenEntry();
TokenEntryArray.push(TokenEntryCopy);
}
function TokenGenIndex(uint256 _TokenEntryIndex, uint256 _TokenEntryNumber) public {
TokenEntry TokenEntryCopy = TokenEntry(address(TokenEntryArray[_TokenEntryIndex]));
TokenEntryCopy.store(_TokenEntryNumber);
}
function TokenGenReader(uint256 _TokenEntryIndex) public view returns (uint256) {
return TokenEntry(address(TokenEntryArray[_TokenEntryIndex])).retrieve();
}
} Please let me know if it works now. To find errors like this I prefer to code it straight in Remix so I can fix all bugs much easier as Remix points you in which exact line there is error straight. |
Beta Was this translation helpful? Give feedback.
@0xFLT
Just rename your
EntryPrice()
function toretrieve()
. This will fix your problem