Skip to main content
Had to change it a little to make it correct.
Source Link

:)

I hope this will answer your question and help you with your issue.

First of all, structs with nested mappings can only be accessed through storage, so you can not create the "Transaction" struct in memory, which is what you're trying to do here. Secondly, you can't use ".push()" on an array of structs with nested mappings.

So, I'll admit to not have read through your entire source code, but I believe I have a pretty good guess to how, you'll solve this issue. InFirst you need to create a state variable for counting transactions. Let's call this "txCount". Then you'll replace the code in your "spend" function, just add with the following code instead:

Transaction[] storage transaction = transactions[transactions.length + 1];transactions[txCount];

transaction.amount = _amount;
transaction.status = TransactionStatus.Pending;
transaction.approvals[msg.sender] = true;
transaction.approvalsCount++;

txCount++;

I hope this will help you out! :)

:)

I hope this will answer your question and help you with your issue.

First of all, structs with nested mappings can only be accessed through storage, so you can not create the "Transaction" struct in memory, which is what you're trying to do here. Secondly, you can't use ".push()" on an array of structs with nested mappings.

So, I'll admit to not have read through your entire source code, but I believe I have a pretty good guess to how, you'll solve this issue. In the "spend" function, just add the following code instead:

Transaction[] storage transaction = transactions[transactions.length + 1];

transaction.amount = _amount;
transaction.status = TransactionStatus.Pending;
transaction.approvals[msg.sender] = true;
transaction.approvalsCount++;

I hope this will help you out! :)

I hope this will answer your question and help you with your issue.

First of all, structs with nested mappings can only be accessed through storage, so you can not create the "Transaction" struct in memory, which is what you're trying to do here. Secondly, you can't use ".push()" on an array of structs with nested mappings.

So, I'll admit to not have read through your entire source code, but I believe I have a pretty good guess to how, you'll solve this issue. First you need to create a state variable for counting transactions. Let's call this "txCount". Then you'll replace the code in your "spend" function with the following code:

Transaction[] storage transaction = transactions[txCount];

transaction.amount = _amount;
transaction.status = TransactionStatus.Pending;
transaction.approvals[msg.sender] = true;
transaction.approvalsCount++;

txCount++;

I hope this will help you out! :)

Source Link

:)

I hope this will answer your question and help you with your issue.

First of all, structs with nested mappings can only be accessed through storage, so you can not create the "Transaction" struct in memory, which is what you're trying to do here. Secondly, you can't use ".push()" on an array of structs with nested mappings.

So, I'll admit to not have read through your entire source code, but I believe I have a pretty good guess to how, you'll solve this issue. In the "spend" function, just add the following code instead:

Transaction[] storage transaction = transactions[transactions.length + 1];

transaction.amount = _amount;
transaction.status = TransactionStatus.Pending;
transaction.approvals[msg.sender] = true;
transaction.approvalsCount++;

I hope this will help you out! :)