ParserError: Expected identifier but got 'ILLEGAL' - solidity

Error: ParserError: Expected identifier but got 'ILLEGAL'
--> 22omo.sol:560:10:
|
560 | contract 2omo is Context, IERC20, Ownable {
| ^
CODE (to note this is not line 1):
contract 2omo is Context, IERC20, Ownable {
using SafeMath for uint256;
IUniswapV2Router02 private _uniswapV2Router;
IERC20 private WrappedETH;

Related

Hi, I am just learning Solidity and i am getting an error "from solidity: ParserError: Expected identifier but got 'public'" at line 9

//SPDX- license-Identifier:MIT;
pragma solidity ^0.8.7;
uint256 favnumber;
struct People
{
string name;
uint256 numbers;
}
People[] public showdetails;
//mapping (uint256=>string) numbers;
function adddetails(uint256 _numbers) public
{
favnumber=_numbers;
/People newname=People({_name:_numbers});
numbers[_numbers]=[_name];/
}
This code was working fine on the other machine

ParserError: Expected identifier but got 'receive'

How can I call payable function from the A contract in B contract and send msg.value to it when invoking fund function from B contract
interface A {
receive() external payable;
}
contract B {
A a;
constructor() {
a = A("0xE9F920eE6F15739cc3b2Ac5Ea862C6eB9EEE529b");
}
function fund() public payable {
a.receive();
}
}
I get this error:
ParserError: Expected identifier but got 'receive'
--> fallback/fallback.sol:12:11:
|
12 | a.receive();
| ^^^^^^^
The receive() function is similar to the fallback function but makes it explicit that it can only receive ETH, without any implementation.
You cannot call it like that, but instead the receive() function will be called when the calldata is empty.
Change to that:
contract B {
address payable a;
constructor() {
a = payable(0xE9F920eE6F15739cc3b2Ac5Ea862C6eB9EEE529b);
}
function fund() public payable {
a.call{value: msg.value}("");
}
}

Array.push() throwing ParserError: Expected identifier but got '('

I would appreciate some help/explanation on the following error since I can't understand what's wrong.
simpleStorageArray.push(simpleStorage2); is throwing ParserError: Expected identifier but got '('
pragma solidity ^0.6.0;
import "./SimpleStorage.sol";
contract StorageFactory {
SimpleStorage[] public simpleStorageArray;
SimpleStorage public simpleStorage2 = new SimpleStorage();
simpleStorageArray.push(simpleStorage2);
function createSimpleStorageContract() public {
SimpleStorage simpleStorage = new SimpleStorage();
simpleStorageArray.push(simpleStorage);
}
}
You must to put this statement inside a function:
simpleStorageArray.push(simpleStorage2);
All operation in Solidity that change the state about your contract or read some variables you must to write into a function. In this case, because you're modifying a value about state variable, you must to put the statement above into function like this way:
pragma solidity ^0.6.0;
import "./SimpleStorage.sol";
contract StorageFactory {
SimpleStorage[] public simpleStorageArray;
SimpleStorage public simpleStorage2 = new SimpleStorage();
function createSimpleStorageContract() public {
SimpleStorage simpleStorage = new SimpleStorage();
simpleStorageArray.push(simpleStorage);
simpleStorageArray.push(simpleStorage2);
}
}

Definition of base has to precede definition of derived contract (ERC721 implementation)

The top SO or ETH Stack Exchange answers don't seem to apply to my case (I could be wrong of course)
I'm getting the error describer in the title in this file:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC721Metadata.sol";
import "./ERC721.sol";
contract ERC721Connector is ERC721Metadata, ERC721 {
// ^^^^^^^ (Definition of base has to precede definition of derived contract)
constructor(string memory name, string memory symbol) ERC721Metadata(name, symbol) {}
}
Here's what ERC721Metadadata looks like:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract ERC721Metadata {
string private _name;
string private _symbol;
constructor(string memory named, string memory symbolified) {
_name = named;
_symbol = symbolified;
}
function name() external view returns (string memory) {
return _name;
}
function symbol() external view returns (string memory) {
return _symbol;
}
}
And here is what ERC721 looks like:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import "./ERC721Metadata.sol";
import "./ERC721Connector.sol";
contract ERC721 {
event Transfer(
address indexed from,
address indexed to,
uint256 indexed tokenId
);
mapping(uint256 => address) private _tokenOwner;
mapping(address => uint256) private _OwnedTokensCount;
function _exists(uint256 tokenId) internal view returns (bool) {
address owner = _tokenOwner[tokenId];
return owner != address(0);
}
function _mint(address to, uint256 tokenId) internal {
require(to != address(0), "ERC721: minting to the zero address");
require(
!_exists(tokenId),
"ERC721: minting a token that already exists (been minted)"
);
_tokenOwner[tokenId] = to;
_OwnedTokensCount[to] += 1;
emit Transfer(address(0), to, tokenId);
}
}
Do you need to import ERC721Connector contract in your ERC721 contract? If not, you can remove
import "./ERC721Connector.sol"; // line 4, ERC721.sol
from your file and it should work fine. Your imports are causing the issue,
ERC721Connector tries to import ERC721, but ERC721 also needs ERC721Connector so the compiler says
Definition of base has to precede definition of derived contract
Because the base contract doesn't precede the defined contract.

Can you please tell me why I'm getting this error message on solidity

[https://i.stack.imgur.com/uSU0Y.png][1]
from solidity:
DeclarationError: Identifier already declared.
--> contracts/MySimpleStorage.sol:16:5:
|
16 | people[] public people;
|
Note: The previous declaration is here:
--> contracts/MySimpleStorage.sol:11:5:
|
11 | struct people {
| (Relevant source part starts here and spans across multiple lines).
error 2
from solidity:
TypeError: Expected callable expression before call options.
contracts/MySimpleStorage.sol:32:21:
|
32 | people.push(people{favoriteNumber: _favoriteNumber, name: _name});
check the above link for screenshot
here's the main code
`// SPDX-License-Identifier: MIT
pragma solidity >=0.7.0 <0.9.0;
contract MySimpleStorage {
//this will get initilized to 0 since we did not state the number
uint256 public favoriteNumber;
bool favoriteBool;
struct people{
uint256 favoriteNumber;
string name;
}
People[] public people;
mapping(string => uint256) public nameToFavoriteNumber;
function store(uint256 _favoriteNumber) public {
favoriteNumber = _favoriteNumber;
}
function retrieve() public view returns(uint256) {
return favoriteNumber;
}
function addPerson(string memory _name, uint256 _favoriteNumber) public{
people.push(people(_favoriteNumber, _name));
nameToFavoriteNumber[_name] = _favoriteNumber;
}
}`
This issue is from case sensitivity. you have declared struct with lower case here -struct people
You will need to declare same before the dynamic array here-People[]
Lowercase here is your object name that appears on the button in public, and this could be anything -public people
Bottonname.push(structNAME...