This is my very first question on here, hope someone can assist me.

//SPDX-License-Identifier: UNLICENSED
    pragma solidity 0.8.13;
    contract VaultContract {
        struct Vault {
            address creator;
            string name;
            address[] users;
            uint256 amount;
        uint256 totalVaults;
        mapping(uint256 => Vault) public vaults;
        mapping(address => uint256) public balance;
        event VaultDistrubtion(uint256 vaultId, uint256 amount);
        function createVault(
            string memory name,
            address[] memory users,
            uint256 initialAmount
        ) public returns (uint256 vaultId) {
            Vault storage vault = vaults[totalVaults];
            vault.creator = msg.sender;
            vault.name = name;
            vault.users = users;
            vault.amount = initialAmount;
            totalVaults += 1;
            return totalVaults - 1;
        function addAmount(uint256 vaultId, uint256 amount) public {
            Vault storage vault = vaults[vaultId];
            require(msg.sender == vault.creator, "Not vault owner");
            vault.amount = amount;
        function distribute(uint256 vaultId) public {
            Vault storage vault = vaults[vaultId];
            uint256 amountPerUser = vault.amount / vault.users.length;
            if (vault.amount != 0) {
                for (uint8 i; i < vault.users.length; i++) {
                    vault.amount -= amountPerUser;
                    balance[vault.users[i]] = amountPerUser;
            else {
                revert("No Funds Available");
            emit VaultDistrubtion(vaultId, amountPerUser * vault.users.length);

Once I deploy the contract on the JVM, I enter information into the createVault() function call (Vault1, 0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, 500). - Just for a YouTube tutorial I'm trying to follow.

It throws an error when I try and transact, here is the error:

transact to VaultContract.createVault errored: Error encoding arguments: Error: types/values length mismatch (count={"types":3,"values":4}, value={"types":["string","address[]","uint256"],"values":["Vault1","",", 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c","500"]}, code=INVALID_ARGUMENT, version=abi/5.5.0)

I have tried without quotes and double quotes from the createVault() arguments, it throws another error, here is the error message:

 *transact to VaultContract.createVault errored: Error encoding arguments: Error: expected array value (argument=null, value="0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c", code=INVALID_ARGUMENT, version=abi/5.5.0)*

I have tried to format the question as good as I can for anyone, who is able to help in any way.

I'm following a Youtube tutorial and I might be missing something.

Kind Regards

1 Answer 1


Refer to this part in your error message:

Error: types/values length mismatch (count={"types":3,"values":4}

Reading this tells you that you have 3 types (3 expected parameters), but 4 values are being used. This is because you aren't passing your users as an array, instead you're passing them as individual address parameters. You need to change your call to createVault from

(Vault1, 0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c, 500)


(Vault1, [0x03C6FcED478cBbC9a4FAB34eF9f40767739D1Ff7, 0xCA35b7d915458EF540aDe6068dFe2F44E8fa733c], 500)
  • 1
    Cheers for that :) The other issue I did have after I fixed the createVault() call, was that I didn't know about adding double quotes after the array bracket (e.g. ["address1", "address2"] for each address.) Thanks again!
    – Arches9
    Commented Apr 5, 2022 at 18:43

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.