2

I am working on several contracts and I can deploy and test fine on hardhat-network. However whenever I switch to Ganache or Rinkeby I get the following behaviour:

  • The contract deploys fine
  • Whenever I try to access one of the contract methods I get the following error:
Error: invalid hex string (argument="value", value="-0x0e8800", code=INVALID_ARGUMENT, version=bytes/5.5.0)
    at Logger.makeError (/home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:225:28)
    at Logger.throwError (/home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:237:20)
    at Logger.throwArgumentError (/home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/logger/src.ts/index.ts:241:21)
    at hexStripZeros (/home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/bytes/src.ts/index.ts:304:16)
    at hexValue (/home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/bytes/src.ts/index.ts:295:21)
    at /home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:646:35
    at Array.forEach (<anonymous>)
    at Function.JsonRpcProvider.hexlifyTransaction (/home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:644:100)
    at /home/augustin/tokenart/tokenart-contracts/node_modules/@ethersproject/providers/src.ts/json-rpc-provider.ts:210:60 {
  reason: 'invalid hex string',
  code: 'INVALID_ARGUMENT',
  argument: 'value',
  value: '-0x0e8800'
}

I didn't use to get this error so it is really baffling to me. It started around last week with seemingly no changes to my development environment.

Here's the code:

    const FirstContract = await ethers.getContractFactory("FirstContract");
    const firstContract = await FirstContract.deploy();
    console.log("Contract deployed to:", firstContract.address);
    
    const SecondContract = await ethers.getContractFactory("SecondContract");
    const secondContract = await SecondContract.deploy();
    console.log("Contract deployed to: ", secondContract.address) ;

    console.log(await firstContract.whitelistProxy(secondContract.address));

Im am on WSL Ubuntu 20.4 and here's my package:

{
  "devDependencies": {
    "@nomiclabs/hardhat-ethers": "^2.0.4",
    "@nomiclabs/hardhat-waffle": "^2.0.1",
    "chai": "^4.3.4",
    "ethereum-waffle": "^3.4.0",
    "ethers": "^5.5.3",
    "hardhat": "^2.8.2"
  },
  "dependencies": {
    "@openzeppelin/contracts": "^4.4.2"
  }
}
1
  • Did you work this out?
    – seb
    Commented Feb 9, 2022 at 17:21

1 Answer 1

0

try to add below code after .deploy() call:

await contract.deployed();

for example:

const FirstContract = await ethers.getContractFactory("FirstContract");
const firstContract = await FirstContract.deploy();
await firstContract.deployed();
console.log("Contract deployed to:", firstContract.address);

OR change your testing network and use Goerli or Sepolia, because the Rinkeby testnet will be deprecated soon

please vote me up if it's useful :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.