js/etc/wallet/farm.js
// This buys P3C from the crop, but with you as the referrer
This buys P3C from the crop, but with you as the referrer
This buys P3C from the crop but with you as the referrer
function buyFromCrop(amountToBuy, referrer) {
    farmContract.myCrop.call(function (err, cropAddress) {
        amount = web3.toWei(amountToBuy)
        cropAbi.at(cropAddress).buy.sendTransaction(
            referrer, {
                from: web3.eth.accounts[0],
                value: amount,
                gas: 223287,
                gasPrice: web3.toWei(1, 'gwei')
            },
            function (error, result) { 
                if (!error) {
                    if (typeof gtag !== 'undefined'){gtag('event', 'Wallet', {'event_label': 'Usage', 'event_category': 'BuyP3C', 'value': Number(amountToBuy)});};
                    alertify.success('<h3>' + amountToBuy + " ETC dihabiskan. Silakan tunggu transaksi Blockchain sedang memproses.</h3>")
                    $("#buy").transition({
                        animation: 'tada',
                        duration: '1s',
                    });
                    $('#buyAmount').hide();
                } else {
                    console.log(error);
                }
            })
    })
}
function buyFromCrop ( amountToBuy , referrer ) { farmContract . myCrop . call ( function ( err , cropAddress ) { amount = web3 . toWei ( amountToBuy ) cropAbi . at ( cropAddress ) . buy . sendTransaction ( referrer , { from : web3 . eth . accounts [ 0 ] , value : amount , gas : 223287 , gasPrice : web3 . toWei ( 1 , 'gwei' ) } , function ( error , result ) { if ( ! error ) { if ( typeof gtag !== 'undefined' ) { gtag ( 'event' , 'Wallet' , { 'event_label' : 'Usage' , 'event_category' : 'BuyP3C' , 'value' : Number ( amountToBuy ) } ) ; } ; alertify . success ( '<h3>' + amountToBuy + " ETC dihabiskan. Silakan tunggu transaksi Blockchain sedang memproses.</h3>" ) $ ( "#buy" ) . transition ( { animation : 'tada' , duration : '1s' , } ) ; $ ( '#buyAmount' ) . hide ( ) ; } else { console . log ( error ) ; } } ) } ) }
This buys P3C from the crop, but with you as the referrer
This buys P3C from the crop but with you as the referrer
// your crop is the referrer //get callback from function which is your transaction key // playSound('register');