Cannot compile smart contract due to solidity/openzeppelin version mismatch problem

Hello there. I am following the 3rd tutorial " How to Build Serverless Dapps Part 1 - Web3.js & Moralis Programming Tutorial". I am up to the part where flipcontract.sol is first compiled. I get this error like in the tutorial…

Compiling your contracts…
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/flipcontract.sol

/home/blair/Moralis_tutorials/build_serverless_dapp/truffle/contracts/flipcontract.sol:4:1: ParserError: Source file requires different compiler version (current compiler is 0.5.16+commit.9c3226ce.Emscripten.clang - note that nightly builds are considered to be strictly less than the released version
pragma solidity ^0.7.5;
^---------------------^

I adjusted the solidity version in compiler settings of the truffle_config.js file to 0.7.5; although when running it I got this error

Compiling your contracts…
===========================
> Compiling ./contracts/Migrations.sol
> Compiling ./contracts/flipcontract.sol
> Compiling ./node_modules/@openzeppelin/contracts/access/Ownable.sol
> Compiling ./node_modules/@openzeppelin/contracts/math/SafeMath.sol
> Compiling ./node_modules/@openzeppelin/contracts/utils/Context.sol

> Compilation warnings encountered:

** /home/blair/Moralis_tutorials/build_serverless_dapp/truffle/contracts/flipcontract.sol: Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier: " to each source file. Use “SPDX-License-Identifier: UNLICENSED” for non-open-source code. Please see https://spdx.org for more information.**
,/home/blair/Moralis_tutorials/build_serverless_dapp/truffle/node_modules/@openzeppelin/contracts/access/Ownable.sol:26:5: Warning: Visibility for constructor is ignored. If you want the contract to be non-deployable, making it “abstract” is sufficient.
** constructor () internal {**
** ^ (Relevant source part starts here and spans across multiple lines).**

/home/blair/Moralis_tutorials/build_serverless_dapp/truffle/contracts/flipcontract.sol:54:1: DeclarationError: Identifier already declared.
contract FlipContract is Ownable {
^ (Relevant source part starts here and spans across multiple lines).
/home/blair/Moralis_tutorials/build_serverless_dapp/truffle/contracts/flipcontract.sol:6:1: The previous declaration is here:
contract FlipContract is Ownable {
^ (Relevant source part starts here and spans across multiple lines).

Compilation failed. See above.

Is there a known way around this? thank you

server URL:
https://qud0iwyowkil.moralis.io:2053/server

Hi. Can you please post your contract code?

Be sure to follow this guide for formatting when posting code and error messages as it makes it much easier to read. Thanks.

Did you try loading npm install @openzeppelin/[email protected]? Current version does not match version in the video. @blairh

I have a different compile issue related to the same video. When I try and compile I get this.

Error: Failed to complete request to: https://solc-bin.ethereum.org/bin/soljson-v0.7.5+commit.eb77ed08.js. Are you connected to the internet?

Error: EACCES: permission denied, open ‘/usr/local/lib/node_modules/truffle/node_modules/.cache/truffle/soljson-v0.7.5+commit.eb77ed08.js’
at CompilerSupplier.errors (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier.js:535:1)
at CompilerSupplier.getByUrl (/usr/local/lib/node_modules/truffle/build/webpack:/packages/truffle-compile/compilerSupplier.js:279:1)
Truffle v5.0.1 (core: 5.0.1)
Node v14.16.1

Is this an issue with Linux of Visual Studio not letting me reach the link?

Sounds like a permissions issue. I’m not that familiar with Linux/Macs. I’d recommend reposting your issue in separate thread to make sure it gets seen.

You make a good point about the Openzeppelin version. If you’re using Solidity version 0.6.x or 0.7.x then use Openzeppelin version 3.4.0 instead of the latest.