I tested my contract code on the Ropsten test network and everything seemed to work fine. I was able to run all my scripts and call functions on the contract on Ropsten. I then proceeded to deploy to the mainnet and etherscan says the contract deployment was successful: Contract Etherscan link

However I am unable to access the contract or any of its functions and I keep getting this error:

Error: invalid hex string (argument="value", value="-0x02b4a8", code=INVALID_ARGUMENT, version=bytes/5.0.10) at Logger.makeError (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\logger\src.ts\index.ts:205:28) at Logger.throwError (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\logger\src.ts\index.ts:217:20) at Logger.throwArgumentError (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\logger\src.ts\index.ts:221:21) at hexStripZeros (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\bytes\src.ts\index.ts:296:16) at Object.hexValue (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\bytes\src.ts\index.ts:287:21) at C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:547:27 at Array.forEach () at Function.JsonRpcProvider.hexlifyTransaction (C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:545:52) at C:\Users\marti\Martin\Projects\CEEU\node_modules@ethersproject\providers\src.ts\json-rpc-provider.ts:186:60 { reason: 'invalid hex string', code: 'INVALID_ARGUMENT', argument: 'value', value: '-0x02b4a8' }

Not really sure where the value is "-0x02b4a8" coming from. The code that calls the smart contract function is below:

const CEEU = (await bre.ethers.getContractFactory('CEEU')).connect(deployer)
const ceeuInstance = CEEU.attach(CEEUAddress)
await ceeuInstance.setMonetaryPolicy(PolicyAddress)

I know this code works because i tested on ropsten so i'm thinking that there is some mainnet config that i might be missing. but i'm relatively new to blockchain development so any help would be appreciated!

EDIT: The stack trace shows the error occuring in sendUncheckedTransaction function of json-rpc-provider.ts

sendUncheckedTransaction(transaction: Deferrable<TransactionRequest>): Promise<string> {
    transaction = shallowCopy(transaction);

    const fromAddress = this.getAddress().then((address) => {
        if (address) { address = address.toLowerCase(); }
        return address;

    return resolveProperties({
        tx: resolveProperties(transaction),
        sender: fromAddress
    }).then(({ tx, sender }) => {
        if (tx.from != null) {
            if (tx.from.toLowerCase() !== sender) {
                logger.throwArgumentError("from address mismatch", "transaction", transaction);
        } else {
            tx.from = sender;

 // next line is where the stack trace show the error is coming from

        const hexTx = (<any>this.provider.constructor).hexlifyTransaction(tx, { from: true });

        return this.provider.send("eth_sendTransaction", [ hexTx ]).then((hash) => {
            return hash;
        }, (error) => {
            return checkError("sendTransaction", error, hexTx);
  • 1
    The traceback mentions that it's getting the negative hex value at line 186 of your code - could you point to which line that is? Commented Mar 21, 2021 at 9:22
  • 1
    @TheRenaissance Updated the post with the stacktrace. The problem occurs when you try to convert the transaction object into hex format but i'm really baffled at where this negative hex is coming from when i'm simply calling a function of the contract.
    – Ghost
    Commented Mar 21, 2021 at 12:44
  • Did you ever work this out?
    – seb
    Commented Feb 9, 2022 at 17:22

1 Answer 1


This maybe due to your gas configuration in hardhat.config.js. In my case I got the following error when upgrading a deployed smart contract in fuji network using hardhat-upgrades plugin.

{reason: 'invalid hex string', code: 'INVALID_ARGUMENT', argument: 'value', value: '-0x0ee98f'}

and my config was,

  url: `https://api.avax-test.network/ext/bc/C/rpc`,
  accounts: [process.env.ACCOUNT_PRIVATE_KEY],
  gas: 25,
  gasPrice: 30000000000,

After changing the gas the issue was solved.

  url: `https://api.avax-test.network/ext/bc/C/rpc`,
  accounts: [process.env.ACCOUNT_PRIVATE_KEY],
  gas: 8000000,
  gasPrice: 30000000000,

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.