I'm trying to use this contract https://etherscan.io/address/0x1756438d0038fae9d9566b54a93a4014f4b38953#writeContract.

More specifically, createSplit function. I'm struggling to understand what to plug for an input.

Here's what the contract claims for that part:

"inputs": [{
        "components": [{
            "internalType": "address payable",
            "name": "recipient",
            "type": "address"
        }, {
            "internalType": "uint256",
            "name": "percentInBasisPoints",
            "type": "uint256"
        "internalType": "struct PercentSplit.Share[]",
        "name": "shares",
        "type": "tuple[]"
    "name": "createSplit",
    "outputs": [{
        "internalType": "contract PercentSplit",
        "name": "splitInstance",
        "type": "address"

Any ideas on what should go for the input? An example would be great.

3 Answers 3


You can simple pass them as array of two elements but as a string that should work


For struct imported within a struct just declare more arrays inside this array.


When you write a struct in Solidity, it gets mapped as tuple in the ABI. The actual structure of the struct can be seen in the components field (which may be recursive).

In your case, the struct seems to be:

struct Share {
    address payable recipient;
    uint245 percentInBasisPoints;

And the function takes in an array of Share

So you should create a JavaScript object which reflects the above structure and pass that to the function.



struct StructData {
    uint256 x;          
    bytes32 h3;         

function registerStructData(
    uint256 _N, 
    StructData[] memory _c
    ) public payable
  returns (uint256) 
      for(uint i = 0; i < _c.length; i++){

        ph = doSomething(_N, _c[i].x, _c[i].h3);

and for the typescript code calling this:

let overrides = {
          value: ethers.utils.parseEther("1.0"),    // it gets very expensive
          gasLimit: 20000000, 
          gasPrice: 20000000000 

        let structdata: { 
          x: bigint,      
          h3: string,     
         }[] = [];

        for (let idx = 0; idx < CHAIN; idx++) {
            x: datasource.x[idx],
            h3: datasource.h3[idx],

        let txConfirm: any = undefined;
        const setChainTx = await contract.registerStructData(
          datasource.N,       // uint256
        txConfirm = await setChainTx.wait(); 

I had a hard time figuring out the exact type needed by the values pushed to the array. bigint seemed to work fine, string maps to bytes32 well and you may have to use ethers.BigNumber to cast the value for the price.

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.