Smart contract failing to deploy with Hardhat on Sapphire

My environment is configured for Sapphire testnet

    oasistest: {
      url: '',
      accounts: ['0x{64}']

I’ve deployed my contract on EVM (Ethereum and multiple forks), but when I do this for Sapphire testnet it’s returning an error:

ProviderError: core: invalid call format: invalid packed call
    at HttpProvider.request (/home/proj/node_modules/hardhat/src/internal/core/providers/http.ts:78:19)
    at LocalAccountsProvider.request (/home/proj/node_modules/hardhat/src/internal/core/providers/accounts.ts:188:34)
    at processTicksAndRejections (internal/process/task_queues.js:95:5)
    at EthersProviderWrapper.send (/home/proj/node_modules/@nomiclabs/hardhat-ethers/src/internal/ethers-provider-wrapper.ts:13:20)

The callee is the following:

    const K = await hre.ethers.getContractFactory(k);
    const contract = await K.deploy();  // <-- fails here
    await contract.deployed();

Any suggestions what I can do? I noticed responds with a 405, guessing it’s ‘/ GET’ and the system is running fine (testnet explorer is looking good to go)

It works on Emerald! Using that for now

Sapphire looks really good for my use case, would be great if I can get it running there

Try using this plugin: @oasisprotocol/sapphire-hardhat. Also put in chainId: 0x5aff into your oasistest config.

1 Like

plugin didn’t solve it :persevere:

adding chainId caused hardhat to complain, is there a minimum version of hardhat to run?

also, ya it’s local test but FYI:

+ @oasisprotocol/sapphire-hardhat@1.0.3
added 139 packages from 62 contributors, updated 1432 packages and audited 1581 packages in 223.482s

found 154 vulnerabilities (20 low, 45 moderate, 66 high, 23 critical)

That’s really strange. I’m sorry you’re having difficulty. I’d like to help more, but I don’t know where the plugin was included, nor what complaint hardhat is making. Could you please check this code and making sure you’re doing what it’s doing? If you want to post your hardhat config that also works.

Have you followed along with this tutorial and made sure you are using the Sapphire compat lib? It should be very easy to do, but it is slightly different than deploying to other EVM chains.

1 Like

It works, Thanks! :star_struck:

pnpm is awesome, installed and used it to download sapphire-hardhat

the install is much much better than npm install @oasisprotocol/sapphire-hardhat: much faster and secure

I was missing the import/require for sapphire-hardhat in config, updated compiler to 0.8.7 and was able to successfully add chainId without the previous error (Expected a value of type HttpNetworkConfig)

ya it’s awesome–


Awesome! Looking forward to hearing about your usecase and what you are building more in the future