0xSpaceShard / starknet-hardhat-example

Examples of how Starknet Hardhat plugin can be used.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

StarknetPluginError: Could not perform call on getPublicKey.

lsbyerley opened this issue · comments

When attempting to run npx hardhat test test/quick-test.ts, I am getting the following error:

StarknetPluginError: Could not perform call on getPublicKey.
Got BadRequest while trying to access http://host.docker.internal:5050/feeder_gateway/call_contract?blockNumber=pending. Status code: 500; text: {"code":"StarknetErrorCode.UNINITIALIZED_CONTRACT","message":"Requested contract address 0x000 is not deployed."}

I have set the OZ_ACCOUNT_ADDRESS and the OZ_ACCOUNT_PRIVATE_KEY in the .env file to a starknet account on testnet. Is there another step i'm missing?

Providing the exact command, the exact error message, and the exact config file is usually necessary for debugging. In this case, we're missing your hardhat config file (hardhat.config.ts).

The error indicates that you are using a local network, whereas your bug report mentions an account deployed on testnet. It could be that you are using integrated-devnet as your configured network.

@FabijanC thank you! I am using the exact same config file that is setup in this repo. I have the cloned the repo, added env variables and changed nothing else. So yes, I guess it is using integrated-devnet

import { HardhatUserConfig } from 'hardhat/types';
import '@shardlabs/starknet-hardhat-plugin';
import '@nomiclabs/hardhat-ethers';
import * as dotenv from 'dotenv';
dotenv.config();

/**
 * @type import('hardhat/config').HardhatUserConfig
 */
const config: HardhatUserConfig = {
  solidity: '0.6.12',
  starknet: {
    dockerizedVersion: '0.10.3', // alternatively choose one of the two venv options below
    // uses (my-venv) defined by `python -m venv path/to/my-venv`
    // venv: "path/to/my-venv",

    // uses the currently active Python environment (hopefully with available Starknet commands!)
    // venv: "active",
    recompile: false,
    network: 'integrated-devnet',
    wallets: {
      OpenZeppelin: {
        accountName: 'OpenZeppelin',
        modulePath:
          'starkware.starknet.wallets.open_zeppelin.OpenZeppelinAccount',
        accountPath: '~/.starknet_accounts',
      },
    },
  },
  networks: {
    devnet: {
      url: 'http://127.0.0.1:5050',
    },
    integratedDevnet: {
      url: 'http://127.0.0.1:5050',
      // venv: "active",
      // dockerizedVersion: "<DEVNET_VERSION>",
      args: [
        // Uncomment the lines below to activate Devnet features in your integrated-devnet instance
        // Read about Devnet options here: https://shard-labs.github.io/starknet-devnet/docs/guide/run
        //
        // *Account predeployment*
        // "--seed",
        // "42",
        // "--accounts",
        // "1",
        // "--initial-balance", <VALUE>
        //
        // *Forking*
        // "--fork-network",
        // "alpha-goerli2"
        // "--fork-block", <VALUE>
        //
        // *Chain ID*
        // "--chain-id", <VALUE>
        //
        // *Gas price*
        // "--gas-price", <VALUE>
      ],
    },
    hardhat: {},
  },
};

export default config;

In the link I provided above, you can see how you can specify alpha-goerli or devnet. The runtime network can be specified both via the network: property and by supplying --starknet-network <NETWORK_NAME> to npx hardhat test.

But integrated-devnet can be really useful, as its a hardhat-wrapper of starknet-devnet, whose features can be found here.

@FabijanC awesome thanks!