0

I've developed a UI in Visual Studio. The UI is a simple HTML with some CSS and also, Javascript code. To interact with my Ethereum Private Network, I've included the web3.min.js.

Firts of all, I've developed and deployed my Smart Contract via Remix. The Smart Contract registry an entry each day, no more, so the date is the "identifier". Here is the Smart Contract.

struct Product {
        string concept;
        uint256 quantity;
}
mapping (uint => Product) allProducts;
uint[] public productDates;
function setProduct(string _concept, uint256 _quantity, uint _date) public {
     var newproduct = allProducts[_date];
     newproduct.concept = _concept;
     newproduct.quantity = _quantity;
     productDates.push(_date) -1;
 }
function getProducts() view public returns (uint[]) {
     return productDates;
}
function getProduct(uint date) view public returns (string, uint256) {
    return (allProducts[date].concept, allProducts[date].quantity);
}

Then, I interact with my Smart Contract via the Remix interface without any problem.

However, when I try to interact with the Smart Contract with my UI, it doesn't work. I try to add new "products", but I can't.

  • If I delete the "concept" from the Product struct, and I only create Products with a quantity, it goes ok.

Why happens this? I've done many changes and proofs but it doesn't work.

Edit 1:

My private network is created via geth. I only have a node, where I créate some accounts.

  • What do you mean "it does not work". What is the error you get? – Florian Castelain Jan 24 '18 at 8:57
  • I don't get any error. The transaction is submitted to the Blockchain, but then, once it's mined, the inputs aren't available. However, if I execute the same transaction via Remix, the info is available. – Urko Jan 24 '18 at 13:36
  • Are you sure the transaction succeed? Can you do "getCode()" with the address of the contract? Does it return the bytecode? – Florian Castelain Jan 25 '18 at 0:43
  • I've found the issue. I used Ganache to "debug" my DAPP. I have to set a Gas Limit for each transaction. Depending on the type of transaction, you have to set a different value. I solved it. – Urko Feb 21 '18 at 9:01

Your Answer

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

Browse other questions tagged or ask your own question.