Newbie question about Mix

LantianLantian Member Posts: 1
edited April 2016 in Mix
Hi everybody,

I was asked by my teacher to use the Mix IDE in order to develop an application using Ethereum's blockchain.

As a newbie, my question will probably sound stupid to many of you but I couldn't find the answer in the wiki...

Here's the problem. Let's assume that we have the following simple contract:

contract Test { struct Item { uint ID; address owner; } uint public numItems; mapping (uint => Item) public items; function Test() { numItems = 0; } function createItem() returns (uint itemID) { itemID = numItems++; Item i = items[itemID]; i.ID = itemID; i.owner = msg.sender; } function giveItem(uint itemID, address to) { Item i = items[itemID]; i.owner = to; } }

and the simple html file:

<!doctype> <html> <head> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css"> <link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"> </head> <body> <div> <h4> Give Item: </h4> <input id="itemID" type="number"/> <button onClick="giveItem()"> Give </button> </div> <script type='text/javascript'> web3.eth.defaultAccount = web3.eth.accounts[0]; var recipient = '0x06400992be45bc64a52b5c55d3df84596d6cb4a1'; function giveItem() { var itemID = parseInt(document.getElementById("itemID").value); contracts["Test"].contract.giveItem.sendTransaction(itemID, recipient); } </script> </body> </html>


The contract enables to create an Item (which has an ID and an owner) and to give it to someone else thanks to the "giveItem" function.
I would like the HTML file to create an interface that allows the user to use the giveItem function and to store this transaction in the blockchain.
However, the following line contracts["Test"].contract.giveItem.sendTransaction(itemID, recipient); does create a transaction but it is immediately marked as "to be deleted", whereas when I do it manually in the blockchain view it is immediately marked as "to be stored" (see figure below).



Does this mean that when I deploy my app, all the transactions made via the JavaScript API won't be stored in the blockchain or have my teacher and I completely misunderstood how Mix actually works?

Thanks for your time!

Comments

Sign In or Register to comment.