You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If the contract ABI not passed the smart contract constructor does not accept parameters
Expected behavior
If the ABI was not passed (technically it is given as []) then the type checking for the constructor should allow passing parameters. And also no error is thorwn.
Actual behavior
If the ABI was passed as [], the developer can call the deploy; But there will be an error if parameter(s) where passed.
If the user tried to work around this by using // @ts-expect-error, an error will come at runtime:
Web3ContractError: The number of arguments is not matching the methods required number. You need to pass 0 arguments.
125 | console.log(abi);
126 | if (inputLength !== args.length) {
> 127 | throw new Web3ContractError(
| ^
128 | `The number of arguments is not matching the methods required number. You need to pass ${inputLength} arguments.`,
129 | );
130 | }
at encodeMethodABI (src/encoding.ts:127:9)
at dataInputEncodeMethodHelper (src/utils.ts:45:14)
at dataInputEncodeMethodHelper (src/utils.ts:94:20)
at Contract._contractMethodDeploySend (src/contract.ts:1112:14)
at Object._contractMethodDeploySend [as send] (src/contract.ts:640:17)
at test/unit/contract.test.ts:288:6
at test/unit/contract.test.ts:47:71
at Object.<anonymous>.__awaiter (test/unit/contract.test.ts:43:12)
Steps to reproduce the behavior
constfromAccount='0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1';constcontract=newweb3.eth.Contract([]);constcontractDeployed=awaitcontract.deploy({arguments: [1000],// Error: Type 'number[]' is not assignable to type 'undefined'.}).send({from: fromAccount,gas: '1000000',});
Environment
web3 v4
The text was updated successfully, but these errors were encountered:
Muhammad-Altabba
changed the title
If the contract ABI not passed, the types of the contract constructor and the methods does not accept parameters
If the contract ABI not passed, the deploy method (the smart contract constructor) does not accept parameters
Dec 3, 2023
If the contract ABI not passed the smart contract constructor does not accept parameters
Expected behavior
If the ABI was not passed (technically it is given as
[]
) then the type checking for the constructor should allow passing parameters. And also no error is thorwn.Actual behavior
If the ABI was passed as
[]
, the developer can call thedeploy
; But there will be an error if parameter(s) where passed.If the user tried to work around this by using
// @ts-expect-error
, an error will come at runtime:Steps to reproduce the behavior
Environment
web3 v4
The text was updated successfully, but these errors were encountered: