0

I need to build up a large string array in solidity through web3js, 1000's of elements.

  • Solidity functions don't seem to accept a string array as arguments. I also tried abicoder 2, as I've read that by using that, this would be possible, but when I execute the function, ethereum reverts the transaction.
  • Defining a function that takes a fixed amount of strings. There it seems solidity is limited to 16 arguments, so I will need to execute that function in web3js 100's of times, which costs loads of gas.

Anyone has any good ideas?

1
  • "when I execute the function, ethereum reverts the transaction" are you sure you're not just running out of gas? You pay for each byte of calldata so if you pass in thousands of strings, you can easily exceed the gas limit. The abicoder v2 supports string arrays just fine, both statically- and dynamically-sized ones. Commented Nov 29, 2021 at 0:07

1 Answer 1

1

Solidity accepts string array as a function argument.

pragma solidity ^0.8;

contract MyContract {
    function foo(string[] memory _arg) external {
    }
}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.