Stack Exchange
Error encoding arguments: Error: types/values length mismatch (count={"types":1,"values":3}
Can you please explain me why it's happening and how I can solve it ?
Error:
call to GameItem.storeWalletAddress errored: Error encoding arguments: Error: types/values length mismatch (count={"types":1,"values":3}, value={"types":["tuple(string,string)[]"],"values":["[ {  wallet_address: ",",     counts: ","   } ]"]}, code=INVALID_ARGUMENT, version=abi/5.5.0)

// contracts/GameItem.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.19;
pragma experimental ABIEncoderV2;

import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol";
import "@openzeppelin/contracts/utils/Counters.sol";

contract GameItem is ERC721URIStorage {
    using Counters for Counters.Counter;
    Counters.Counter private _tokenIds;

    constructor() ERC721("GameItem", "ITM") {}

    struct Test1 {
        string wallet_address;
        string counts;
    }

    mapping(address => uint) public nftOwners;
    mapping(address => uint) public usedCounts;

    function storeWalletAddress(Test1[] memory _arr) public pure {
        // require(arr.length > 0, "array length issue");
        // for (uint i = 0; i < arr.length; i++) {
        //     // nftOwners[arr[i].wallet_address] = arr[i].counts;
        // }
    }
}

Passing this array of object:
[
  {
    wallet_address: "0x592372D2c451c0A49EB11Aec7dD8CaE59f9e1b39",
    counts: "2"
  },
  {
    wallet_address: "0x0b1bc5A246B9aaEEf211e61FBcE7648Fb4e7ed83",
    counts: "3"
  },
  {
    wallet_address: "0xBFa260d49eE2e3457652cb87A143ad8c210F4567",
    counts: "5"
  }
]


How you are passing the values is a correct way for passing it from frontend.
Considering that your passing it in remix IDE, you need to pass the tuple as code following, it  should be array of arrays
[   
   [ "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2", 10 ],
   [ "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2", 10 ],
   [ "0xAb8483F64d9C6d1EcF9b849Ae677dD3315835cb2", 10 ]
]

In the solidity code for storing the counts against the wallet address you need to follow the code:
 struct Test1 {
        address wallet_address;
        uint256 counts;
    }
    
    mapping(address => uint256) public nftOwners;

   function storeWalletAddress(Test1[] memory _arr) public  {
        require(_arr.length > 0, "array length issue");
        for (uint i = 0; i < _arr.length; i++) {
            address owner = _arr[i].wallet_address;
            nftOwners[owner] = _arr[i].counts;
        }
    }

If it works please upvote and accept the answer

I need to pass it from front-end as a parameter so how can I add this as Test1[] there ? and right now I'm using remixIDE and passing params from there, so how can pass this ?

@AksharPrajapati, I have updated my answer follow that way and it'll work

okay this way we are passing array to our function but then I also need to store values in map, mapping(address => uint) public nftOwners; I'm trying in this way but it's wrong.
 function storeWalletAddress(Test1[] memory arr) public  {
        // require(arr.length > 0, "array length issue");
        for (uint i = 0; i < arr.length; i++) {
            nftOwners[arr[i][0]] = arr[i][1];
        }
        // nftOwners[_wallet] = 5;
        // walletAddress.push(_wallet);
    } 


@AksharPrajapati Edited the answer, check it. that will solve your problem
