1

I have a ticket system where you can buy some tickets to an given price. I want to set the amount to the method and send it back to the contract. For this I'm using metamask but I don't really get, how to set the price in my transaction.

import Web3, { utils } from 'web3'    

this.contracts = context.drizzle.contracts
const web3 = new Web3(this.contracts.Ticketmarket.givenProvider)
const { abi, address } = this.contracts.Ticketmarket
this.Ticketmarket = new web3.eth.Contract(abi, address)

 buyTicket(id) {
const connectionID = id
this.stackId = this.contracts.Ticketmarket.methods.buyTicket.cacheSend(
  connectionID ,
  { from: this.props.accounts[0], value: (2,"ether")}
  )
}

and my funtion in the contract looks like this.

contract Ticketmarket is usingOraclize, Ownable{

struct Connection{
    string start;
    string destination;
    uint desttime;
    uint price;
    uint contingent;
    uint soldTickets;
    address[] buyers;
}

uint public connectioncount = 0; 

mapping (uint => Connection) public connectionList;

Connection[] public connectionArray;

function buyTicket(uint _connectionID) public payable returns (uint, uint){
    Connection storage connection = connectionList[_connectionID];

    require(_connectionID < connectioncount && connection.soldTickets<connection.contingent && msg.value >= connection.price);

    connection.buyers[connection.soldTickets] = msg.sender;
    connection.soldTickets++;
    uint passengerNumber= (connection.soldTickets)-1;
    return (_connectionID, passengerNumber); 
}

Trying mu code fail with:

takeEvery has been cancelled 
utils.js:240
callListenForContractEvent has been cancelled 
utils.js:240
takeEvery has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
getAccounts has been cancelled 
utils.js:240
callCreateAccountsPollChannel has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
accountsSaga has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
accountBalancesSaga has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
takeEvery has been cancelled 
utils.js:240
callCreateBlockPollChannel has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
takeEvery has been cancelled 
utils.js:240
blocksSaga has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
drizzleStatusSaga has been cancelled 
utils.js:240
takeLatest has been cancelled 
utils.js:240
takeEvery has been cancelled 
utils.js:240
web3Saga has been cancelled 

uncaught at root 
 at contractsSaga 
 at takeEvery 
 at callSendContractTx 
 numberToHex

Could someone help me?

1
  • use web3.js utils to convert value: web3.utils.toWei('2','ether'); – rstormsf Jul 2 '18 at 1:20

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.