0

What i am attempting to do is elementary, adding a struct to a storage array. But for some reason I am getting the following error

TypeError: Indexed expression has to be a type, mapping or array (is function (struct KYC.Fraud storage ref) returns (uint256))

contract KYC {
    struct Fraud {
         address bank;
         bytes32 accountNumber;
         bytes32 routingNumber;
         uint256 amount;
         uint256 timestamp;
    }

    Fraud[] frauds; 

    function reportFraud (address bank, bytes32 accountNumber, bytes32 routingNumber, uint256 amount) external returns(uint256 fraudID) {
        Fraud memory fraud = Fraud(bank, accountNumber, routingNumber, amount, now);
        frauds.push[fraud];
        return frauds.length - 1;
    }

1 Answer 1

1

push is a function. You're using brackets as if it's an array where you lookup the index of a struct, which is what's causing your error. Just change push[fraud] to push(fraud).

0

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.