lesson 6 - addPerson() - passing the arguments in hardhat #411
-
Hi, I have a question about passing the arguments into addPerson() function in lesson 6. This code is inside the hardhat framework:
Function in solidity:
Error message:
Something I am missing to make it work, because I passed to arguments and it says count: 0 |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
const updatedArray = await simpleStorage.addPerson(); What I understand is you are trying to get output after you passed the name and favNumber in "const transactionResponseAddPerson = await simpleStorage.addPerson("Nik", 10);" But most probably, your addPerson function does not have a return statement so how you can expect a return from it. So, this is not the way you should do it. Either you need to call these variables people (array) or nameToFavoriteNumber (list) to get the output of the inputs you sent. |
Beta Was this translation helpful? Give feedback.
const updatedArray = await simpleStorage.addPerson();
Above line is what causing error, you are calling addPerson function but not giving any arguments.
What I understand is you are trying to get output after you passed the name and favNumber in "const transactionResponseAddPerson = await simpleStorage.addPerson("Nik", 10);" But most probably, your addPerson function does not have a return statement so how you can expect a return from it.
So, this is not the way you should do it. Either you need to call these variables people (array) or nameToFavoriteNumber (list) to get the output of the inputs you sent.