Cyfrin Updraft.

Post

Share your knowledge.

Cyfrin Moderator Pst.
Mar 29, 2024
Expert Q&A

Error while running script to compile smart contract with .env file configuration

I have set up a .env file with private key and RPC URL for compiling a smart contract. When I try to run the script using the command:

forge script script/DeploySimpleStorage.s.sol --rpc-url $RPC_URL --broadcast --private-key $PRIVATE_KEY

I encounter the following error:

Error: 
error sending request for url (https://127.0.0.1:8545/): error trying to connect: received corrupt message of type InvalidContentType

Context:

  • Error #0: error trying to connect: received corrupt message of type InvalidContentType
  • Error #1: received corrupt message of type InvalidContentType I have already run Anvil and other necessary components as shown in a video tutorial, but I still face this issue. Any assistance would be appreciated.
  • Transaction
  • Security
  • Solidity
  • Smart Contract
  • Gas
0
1
Share
Comments
.

Answers

1
Cyfrin Moderator Ans.
Mar 29 2024, 08:28

The issue is likely due to using https instead of http in the RPC_URL environment variable.

Additionally, it appears to be an Anvil URL. Ensure that Anvil is running in another terminal window as Anvil must be active to execute tasks on it.

0
Official Answer
Comments
.

Do you know the answer?

Please log in and share it.

Cyfrin Updraft is an education platform specializing on teaching the next generation of smart contract developers

200Posts201Answers
Sui.X.Peera.

Earn Your Share of 1000 Sui

Gain Reputation Points & Get Rewards for Helping the Sui Community Grow.