vechain / hardhat-plugins

3 stars 2 forks source link

Deployment in default setup fails with "coud not detect network" #4

Closed ifavo closed 1 year ago

ifavo commented 1 year ago

I am trying to deploy a sample contract using the standard libraries based on the instructions on https://docs.vechain.org/vechain-and-hardhat/create-a-hardhat-sample-project-web3

My steps are:

yarn add --dev hardhat @vechain/web3-providers-connex @vechain/hardhat-vechain @vechain/hardhat-web3
$ npx hardhat       
888    888                      888 888               888
888    888                      888 888               888
888    888                      888 888               888
8888888888  8888b.  888d888 .d88888 88888b.   8888b.  888888
888    888     "88b 888P"  d88" 888 888 "88b     "88b 888
888    888 .d888888 888    888  888 888  888 .d888888 888
888    888 888  888 888    Y88b 888 888  888 888  888 Y88b.
888    888 "Y888888 888     "Y88888 888  888 "Y888888  "Y888

👷 Welcome to Hardhat v2.13.1 👷‍

✔ What do you want to do? · Create a TypeScript project
✔ Hardhat project root: · ./hardhat-plain
✔ Do you want to add a .gitignore? (Y/n) · y
✔ Do you want to install this sample project's dependencies with yarn)? (Y/n) · y

hardhat.config.ts

import { HardhatUserConfig } from "hardhat/config";
import "@nomicfoundation/hardhat-toolbox";
import "@vechain/hardhat-vechain";
import "@vechain/hardhat-web3";
import '@nomiclabs/hardhat-truffle5';

const config: HardhatUserConfig = {
  solidity: "0.8.18",
  networks: {
    vechain: {
      url: "https://testnet.veblocks.net",
      accounts: {
        mnemonic: "denial kitchen pet squirrel other broom bar gas better priority spoil cross",
        count: 10,
      },
      restful: true,
      gas: 10000000,
    },
  },
};

export default config;

Then a test deployment is run:

$ npx hardhat run --network vechain scripts/deploy.ts
(node:60350) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
(node:60352) ExperimentalWarning: stream/web is an experimental feature. This feature could change at any time
(Use `node --trace-warnings ...` to show where the warning was created)
Error: could not detect network (event="noNetwork", code=NETWORK_ERROR, version=providers/5.7.2)
    at Logger.makeError (./node_modules/@ethersproject/logger/src.ts/index.ts:269:28)
    at Logger.throwError (./node_modules/@ethersproject/logger/src.ts/index.ts:281:20)
    at EthersProviderWrapper.<anonymous> (./node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:483:23)
    at step (./node_modules/@ethersproject/providers/lib/json-rpc-provider.js:48:23)
    at Object.throw (./node_modules/@ethersproject/providers/lib/json-rpc-provider.js:29:53)
    at rejected (./node_modules/@ethersproject/providers/lib/json-rpc-provider.js:21:65)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  reason: 'could not detect network',
  code: 'NETWORK_ERROR',
  event: 'noNetwork'
}

Is there something wrong with my setup?

ifavo commented 1 year ago

@vechain/hardhat-ethers was missing in the configuration. The example on https://docs.vechain.org/vechain-and-hardhat/create-a-hardhat-sample-project-web3 is missing it too.

Adding an import '@vechain/hardhat-ethers'; solved the deployment.

$ npx hardhat run scripts/deploy.ts --network vechain
Compiled 1 Solidity file successfully
Lock with 0.001ETH and unlock timestamp 1681300079 deployed to 0x00095Df2921b27E01867aFA4BA207a17D3047dfB