1

I have an error when trying to write to a contract by using usePrepareContractWrite by passing a struct, heres my struct

    class Job {
    
      id: BigNumber = BigNumber.from("-1");
      hasFunds: boolean = false;
      profileId: BigNumber = BigNumber.from("-1");
      title: string = "";
      description: string = "";
      documents: string[] = [];
      owner: Address = "0x";
      requester: Address = "0x";
      date: BigNumber = BigNumber.from("-1");
      datePaid: BigNumber = BigNumber.from("-1");
      img: string = "";
      requestedPaymentAmount: BigNumber = BigNumber.from("-1");
      token: Address = "0x";
    }

// js code

  const perp = usePrepareContractWrite({
    ...contractConfig,
    functionName: "createJob",
    args: [new Job()],
    enabled: true,
  });

// ad here's the error

    error: invalid value for array (argument="value", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.7.0)
    at Logger.makeError (index.js:224:1)
    at eval (index.js:71:1)
    at Generator.next (<anonymous>)
    at eval (index.js:8:1)
    at new Promise (<anonymous>)
    at __awaiter (index.js:4:1)
    at resolveAddresses (index.js:57:1)
    at eval (index.js:60:1)
    at Array.map (<anonymous>)
    at eval (index.js:59:1)
    at Generator.next (<anonymous>)
    at eval (index.js:8:1)
    at new Promise (<anonymous>)
    at __awaiter (index.js:4:1)
    at resolveAddresses (index.js:57:1)
    at eval (index.js:67:1)
    at Generator.next (<anonymous>)
    at eval (index.js:8:1)
    at new Promise (<anonymous>)
    at __awaiter (index.js:4:1)
    at resolveAddresses (index.js:57:1)
    at eval (index.js:60:1)
    at Array.map (<anonymous>)
    at eval (index.js:59:1)
    at Generator.next (<anonymous>)
    at eval (index.js:8:1)
    at new Promise (<anonymous>)
    at __awaiter (index.js:4:1)
    at resolveAddresses (index.js:57:1)
    at eval (index.js:120:1)
    at Generator.next (<anonymous>)
    at eval (index.js:8:1)
    at new Promise (<anonymous>)
    at __awaiter (index.js:4:1)
    at populateTransaction (index.js:82:1)
    at eval (index.js:217:1)
    at prepareWriteContract (chunk-VQG3VKOR.js:2136:1)
    at Object.eval [as queryFn] (index.js:1646:32)
    at Object.fetchFn [as fn] (query.mjs:252:1)
    at run (retryer.mjs:101:1)
    at createRetryer (retryer.mjs:149:1)
    at Query.fetch (query.mjs:307:33)
    at QueryObserver.executeFetch (queryObserver.mjs:168:1)
    at QueryObserver.setOptions (queryObserver.mjs:86:1)
    at eval (index.js:184:1)
    at commitHookEffectListMount (react-dom.development.js:23150:1)
    at commitPassiveMountOnFiber (react-dom.development.js:24926:1)
    at commitPassiveMountEffects_complete (react-dom.development.js:24891:1)
    at commitPassiveMountEffects_begin (react-dom.development.js:24878:1)
    at commitPassiveMountEffects (react-dom.development.js:24866:1)
window.console.error @ next-dev.js:20
overrideMethod @ react_devtools_backend.js:2655
onError @ query.mjs:294
reject @ retryer.mjs:63
eval @ retryer.mjs:122
Promise.catch (async)
run @ retryer.mjs:106
createRetryer @ retryer.mjs:149
fetch @ query.mjs:307
executeFetch @ queryObserver.mjs:168
setOptions @ queryObserver.mjs:86
eval @ index.js:184
commitHookEffectListMount @ react-dom.development.js:23150
commitPassiveMountOnFiber @ react-dom.development.js:24926
commitPassiveMountEffects_complete @ react-dom.development.js:24891
commitPassiveMountEffects_begin @ react-dom.development.js:24878
commitPassiveMountEffects @ react-dom.development.js:24866
flushPassiveEffectsImpl @ react-dom.development.js:27039
flushPassiveEffects @ react-dom.development.js:26984
commitRootImpl @ react-dom.development.js:26935
commitRoot @ react-dom.development.js:26682
performSyncWorkOnRoot @ react-dom.development.js:26117
flushSyncCallbacks @ react-dom.development.js:12042
eval @ react-dom.development.js:25651
setTimeout (async)
eval @ utils.mjs:287
sleep @ utils.mjs:286
scheduleMicrotask @ utils.mjs:296
flush @ notifyManager.mjs:59
batch @ notifyManager.mjs:25
dispatch @ query.mjs:439
setData @ query.mjs:44
onSuccess @ query.mjs:322
resolve @ retryer.mjs:54
Promise.then (async)
run @ retryer.mjs:106
createRetryer @ retryer.mjs:149
fetch @ query.mjs:307
executeFetch @ queryObserver.mjs:168
setOptions @ queryObserver.mjs:86
eval @ index.js:184
commitHookEffectListMount @ react-dom.development.js:23150
commitPassiveMountOnFiber @ react-dom.development.js:24926
commitPassiveMountEffects_complete @ react-dom.development.js:24891
commitPassiveMountEffects_begin @ react-dom.development.js:24878
commitPassiveMountEffects @ react-dom.development.js:24866
flushPassiveEffectsImpl @ react-dom.development.js:27039
flushPassiveEffects @ react-dom.development.js:26984
commitRootImpl @ react-dom.development.js:26935
commitRoot @ react-dom.development.js:26682
performSyncWorkOnRoot @ react-dom.development.js:26117
flushSyncCallbacks @ react-dom.development.js:12042
eval @ react-dom.development.js:25651
setTimeout (async)
(anonymous) @ inpage.js:17
write @ inpage.js:17
b @ inpage.js:17
(anonymous) @ inpage.js:17
v.write @ inpage.js:17
g @ inpage.js:17
h @ inpage.js:8
o.emit @ inpage.js:8
_ @ inpage.js:17
w @ inpage.js:17
b.push @ inpage.js:17
_write @ inpage.js:1
b @ inpage.js:17
(anonymous) @ inpage.js:17
v.write @ inpage.js:17
g @ inpage.js:1
h @ inpage.js:8
o.emit @ inpage.js:8
_ @ inpage.js:1
w @ inpage.js:1
b.push @ inpage.js:1
_onData @ inpage.js:1
_onMessage @ inpage.js:1
postMessage (async)
_postMessage @ contentscript.js:1
_write @ contentscript.js:1
v @ contentscript.js:1
(anonymous) @ contentscript.js:1
y.write @ contentscript.js:1
g @ contentscript.js:17
h @ contentscript.js:8
o.emit @ contentscript.js:8
_ @ contentscript.js:17
w @ contentscript.js:17
v.push @ contentscript.js:17
_write @ contentscript.js:17
v @ contentscript.js:17
(anonymous) @ contentscript.js:17
y.write @ contentscript.js:17
g @ contentscript.js:17
h @ contentscript.js:8
o.emit @ contentscript.js:8
_ @ contentscript.js:17
w @ contentscript.js:17
v.push @ contentscript.js:17
_write @ contentscript.js:17
v @ contentscript.js:17
(anonymous) @ contentscript.js:17
y.write @ contentscript.js:17
g @ contentscript.js:17
h @ contentscript.js:8
o.emit @ contentscript.js:8
_ @ contentscript.js:17
w @ contentscript.js:17
v.push @ contentscript.js:17
_onMessage @ contentscript.js:8
(anonymous) @ contentscript.js:8
1
  • I have the same issue Commented Jul 5, 2023 at 9:55

1 Answer 1

1

If you are using wagmi 1.x.x you need to change BigNumber instances: https://wagmi.sh/react/migration-guide#bignumber--native-bigint

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.