Suppose I have a product with a specific id for sale(so I am the owner) and someone wants to buy the product from me. When he pays the price he will become the new owner of that product.
How can I record multiple owners for one specific asset?
I want to have a result like this (get all the addresses with the id)
56 => [0xcc6Bfe0C579416A6cC8532e984af0e6a, 0xcc6Bfe0C579416A12C8532e984th0e6a,...]
This is the way I did it which is not working as it should.
I summarized it to make it easier to understand.
Thanks in advance.
contract transfer{
mapping(uint => address[]) public owners;
function createAsset(string name, uint price) public
{
uint id = getRandom(); //I use a random generator function for id
Asset memory newAsset = Asset(name, price); //struct to create a new product
owners[id].push(msg.sender);
}
function transferProduct(uint id) public payable {
owners[id].push(address((msg.sender)));
}
}
createAsset
ortransferProduct
.