I read about a couple of solutions for storing within the blockchain, but I was wondering what would be the best approach to storing an array of addresses that have bought an token. I want to be able to call this array and display it on my frontend.


Constant functions don't require creating a transaction. Here is a simple getter/setter pattern:

pragma solidity 0.4.15;

contract Bought {
    address[] bought;

    // set the sender of the transaction as "bought" 
    function setBought()

    function getAllBought()
    constant // you will not need to make a transaction (i.e its free)
        return bought;
| improve this answer | |
  • 2
    If you want to play with a fiddle, I made one here ethfiddle.com/5eSjmUkrF6 – Matthew Campbell Dec 22 '17 at 11:23
  • This answer is terrible. As soon as you have a good amount of addresses the gas fee would be immense. It could be infinity. Boo this man. – M H Nov 17 '18 at 6:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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