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);
});
});
}