Developers Forum for XinFin XDC Network

sudip kumar palit
sudip kumar palit

Posted on • Updated on

Error while compiling the contract file

My .env file's content is XINFIN_NETWORK_URL=https://rpc.apothem.network
XINFIN_PRIVATE_KEY=1234567890.............. (64 character long )
My hardhat.config.js is
require("@nomicfoundation/hardhat-toolbox");
require("dotenv").config({ path: ".env" });

const XINFIN_NETWORK_URL = process.env.XINFIN_NETWORK_URL;
const XINFIN_PRIVATE_KEY = process.env.XINFIN_PRIVATE_KEY;

if (!XINFIN_NETWORK_URL || !XINFIN_PRIVATE_KEY) {
throw new Error("Please set XINFIN_NETWORK_URL and XINFIN_PRIVATE_KEY in the .env file");
}

module.exports = {
solidity: "0.8.24",
networks: {
xinfin: {
url: XINFIN_NETWORK_URL,
accounts: [XINFIN_PRIVATE_KEY ],},
},
};
While trying to compile the .sol file in contract folder of the hardhat project the following error message is shown:
Error: Please set XINFIN_NETWORK_URL and XINFIN_PRIVATE_KEY in the .env file
at Object. (/home/skp/xdc-hardhat/hardhat.config.js:8:9)
at Module._compile (node:internal/modules/cjs/loader:1358:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1416:10)
at Module.load (node:internal/modules/cjs/loader:1208:32)
at Function.Module._load (node:internal/modules/cjs/loader:1024:12)
at Module.require (node:internal/modules/cjs/loader:1233:19)
at require (node:internal/modules/helpers:179:18)
at importCsjOrEsModule (/home/skp/xdc-hardhat/node_modules/hardhat/src/internal/core/config/config-loading.ts:29:22)
at loadConfigAndTasks (/home/skp/xdc-hardhat/node_modules/hardhat/src/internal/core/config/config-loading.ts:95:18)
at main (/home/skp/xdc-hardhat/node_modules/hardhat/src/internal/cli/cli.ts:218:62)

Please help me out from this problem

Discussion (4)

Collapse
gzliudan profile image
Daniel Liu

Please solve this error first:

Error: Please set XINFIN_NETWORK_URL and XINFIN_PRIVATE_KEY in the .env file
Enter fullscreen mode Exit fullscreen mode
Collapse
gzliudan profile image
Daniel Liu

The solidity v0.8.24 is not supported yet. Please switch to v0.8.23 now.

Collapse
sudip_kumarpalit_e0bc553 profile image
sudip kumar palit Author

Thank you for your information

Collapse
sean_ profile image
Sean

Hello Sudip,

Someone would assist you soon. In the mean time, I'd suggest you explore our Coderun Ai tool present on the left side of the landing page and see if you can find any help from that.