1

I have the following problem, I'm trying to call a function from Solidity function to Solidity modifier:

contract B is A

function checkIfIsValid()
    external pure onlyValidAddresses([manually put few addresses]) // what to put here?
{
    // some work
}

(abstract) Contract A

modifier onlyValidAddresses(address[] memory pAddresses)
{
    //work in a loop
    _;
}
1

I'm not 100% sure I understood the question.

This?

pragma solidity 0.5.4;

contract A {

    modifier onlyValidAddresses(address[] memory pAddresses)
    {
        //work in a loop
        _;
    }    
}   

contract B is A {
    function checkIfIsValid(address[] calldata addresses)
        external pure onlyValidAddresses(addresses) // what to put here?
    {
        // some work
    }
}

Hope it helps.

| improve this answer | |
  • Your solution will work but it needs to put data from outside for example via web3js. I would like to put data inside solidity from inherited contract to the base contract. – Radeg90 Feb 24 '19 at 0:49
  • I'm afraid I don't understand what you want. As it is, it would go Web3/other contract => B.checkIfIsValue([addressList]) => A.onlyValidAddresses => // work in a loop. The addresses passed into B's function wind up in A's modifier and I thought that was what you wanted to accomplish. – Rob Hitchens Feb 24 '19 at 2:28
  • I simply want to build a dynamic array in solidity function and send it to modifier. If it were C# it would look like this: /*external pure*/ onlyValidAddresses(new int[] {0x04Wblabla, 0xadkljgkadljgad, etc}); – Radeg90 Feb 24 '19 at 12:04

Not the answer you're looking for? Browse other questions tagged or ask your own question.