Getting this error when trying to return the newTransacation instance and what is the data type name to use when returning an array as well?
ok theres a few thinsg here. the function your trying to execute is a write function. this means that when you execute this you are changing the state of the blockchain. in these “write” type of functions you cannot read your returned result so the method you are trying to employ wont work.
instead you should keep the function you have as a setter function to set the state of the trasnaction array. this doesnt need to return anything so you can remove your returns in the function header.
to print the transactions you should write a seperate getter function which returns the arrary of transactons and this will be of the format
return transactionLog; }
something like this instead. soldidy is not like any other language in that you can print variabeles. you usually will not return anything from state changing functions, unless you want to return a boolean based on of the function passed or failed, otherwise you only return from functions a value that you will be using directly in another function itself.
Thanks for replying, now I remember you can’t return variables in a write function.
I will create a getter function which should work. cheers.
Also Evan when you make a getter function, you have to set the header of it to view, right?
yep it needs to be view remix will tell u this though
Thanks man you have really helped. What would you say has been the most useful thing to do to really get good at coding solidity. As I haven’t gotten into the flow of programming solidity yet, still getting stuck here and there.