starknet-hardhat-plugin: HardhatPluginError: Could not deploy contract. Check the network url in config. Is it responsive?

Hello team. I updated to the latest 0.5.2 and tried to run the tests.

I have one test passing but one not. I get this error HardhatPluginError: Could not deploy contract. Check the network url in config. Is it responsive?

My current configuration has been for a while:

  networks: {
    devnet: {
      url: 'http://127.0.0.1:5000/',
    },
  },

This is the output:

yarn hardhat test
yarn run v1.22.18
$ /Users/claudio/Dev/web3/starknet-video-network-poc/hardhat/node_modules/.bin/hardhat test
Starknet plugin using the active environment.
Using network devnet at http://127.0.0.1:5000/
...
  1) VNChannel
       constructor
         should have stored correctly the name and symbol:
     HardhatPluginError: Could not deploy contract. Check the network url in config. Is it responsive?
      at StarknetContractFactory.<anonymous> (node_modules/@shardlabs/starknet-hardhat-plugin/src/types.ts:354:19)
      at Generator.next (<anonymous>)
      at fulfilled (node_modules/@shardlabs/starknet-hardhat-plugin/dist/types.js:24:58)

This is the test failing:

import { expect } from 'chai'
import { starknet } from 'hardhat'
import { StarknetContract, StarknetContractFactory } from 'hardhat/types/runtime'

const { getContractFactory, shortStringToBigInt } = starknet

describe('VNChannel', () => {
  let contract: StarknetContract

  const setupContract = async () => {
    const contractFactory: StarknetContractFactory = await getContractFactory('VNChannel')
    contract = await contractFactory.deploy({
      name: shortStringToBigInt('VNChannel'),
      symbol: shortStringToBigInt('VNChannel'),
      owner: 1n,
    })
  }

  describe('constructor', () => {
    it('should have stored correctly the name and symbol', async () => {
      // Given
      await setupContract()
      // When
      const { name } = await contract.call('name')
      const { symbol } = await contract.call('symbol')
      // Then
      expect(name).to.be.deep.equal(shortStringToBigInt('VNChannel'))
      expect(symbol).to.be.deep.equal(shortStringToBigInt('VNChannel'))
    })
  })
})

Ideas why?

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 30

Most upvoted comments

After a week of battles with docker, with remote VMs and other stuff, it seems that I found a way to make it work with the active environment. the only thing different this time around was that I used the latest latest version of python, the 3.10.3. I also had to downgrade

cd hardhat/

brew install pyenv

# Install specific version of python and set it as local default
pyenv install 3.10.3
pyenv local 3.10.3

# Create a local venv
python -m venv .venv

# Activate it (execute this command for every terminal for the project)
source .venv/bin/activate

# Setup the python venv:
brew install gmp

# macOS with M1
CFLAGS=-I`brew --prefix gmp`/include LDFLAGS=-L`brew --prefix gmp`/lib pip3 install ecdsa fastecdsa sympy

# Install Cairo
pip install cairo-lang

# Install Starknet Devnet
pip install starknet-devnet

# Downgrade faulty package
pip install werkzeug==2.0.3

# Start devnet with persistent state (subsequent)
starknet-devnet \
  --dump-on transaction \
  --dump-path ~/.starknet_devnet \
  --load-path ~/.starknet_devnet

In another terminal:

# Compile
yarn hardhat starknet-compile contracts/public

# Test
yarn hardhat test

# Deploy
yarn hardhat starknet-deploy ExampleContract --starknet-network devnet --inputs "123"

# Deploy an account
yarn hardhat starknet-deploy-account --starknet-network devnet --wallet Deployer

And everything works!!