Rahul Trivedi
@rahultrivedi180
3.2.
actually i am trying embark from their website tutorial ok token factory
in console it was said that use EmbarkJS.Blockchain.Contract but i am on simulator
Iuri Matias
@iurimatias
@rahultrivedi180 sorry about that, it’s our fault, we should update that tutorial
EmbarkJS makes no difference in regards to using the simulator or blockchain
however I recommend you just use blockchain/geth
Rahul Trivedi
@rahultrivedi180
and when i tried EmbarkJS.Blockchain.Contract then it says eth undefined in index.js file of embark framework
Rocky Fikki
@rfikki
@iurimatias yeah, I am familiar with the placement inside package.json, that should be a standard feature.
Iuri Matias
@iurimatias
it’s running on dev mode, so it’s not CPU heavy or anythig, and it’s much more realiable
Rahul Trivedi
@rahultrivedi180
okay... so i should use geth?
Iuri Matias
@iurimatias
Yes IMO
that’s the default when you do embark run
no need to run embark blockchain or embark simulator first anymore, embark run will do everything
Rahul Trivedi
@rahultrivedi180
so no need to run embark simulator before???
@rahultrivedi180 no need anymore
if you have geth installed and working well, just embark run will do
Rahul Trivedi
@rahultrivedi180
okay let me try. And thanks so much for quick support.
Iuri Matias
@iurimatias
np
Dave Appleton
@DaveAppleton
Magic. Thanks.
Rahul Trivedi
@rahultrivedi180
hello, I am now directly using embark run. now this is the error: Uncaught TypeError: Cannot read property 'methods' of undefined
Rahul Trivedi
@rahultrivedi180
please help me guys
@iurimatias It is not working bro. it now logs Uncaught TypeError: Cannot read property 'eth' of undefined in blockchain.js
Rahul Trivedi
@rahultrivedi180
@llSourcell hello siraj sir, i had seen your build dapp in 3 mins. Now i am stuck with this amazing error that no one is able to solve
Iuri Matias
@iurimatias
The Siraj video is really really old, a lot has changed
Do you have a repo we can look at?
Have you tried ‘embark demo’
It generates a sample dapp, pretty much the one from that video
Rahul Trivedi
@rahultrivedi180
@iurimatias i am using latest version of everything. Following tutorial available here: https://embark.status.im/tutorials/token_factory_2.html
embark version 3.2.7
@iurimatias you should make that tutorial available on git repo
Iuri Matias
@iurimatias
@rahul does embark demo work for you?
Rahul Trivedi
@rahultrivedi180
@iurimatias yes
@iurimatias how can i send you a short screen recording i made?
Iuri Matias
@iurimatias
Can upload it here or through ipfs or something like that
Rahul Trivedi
@rahultrivedi180
Screenshot from 2018-12-08 23-24-51.png
import $ from 'jquery'
import EmbarkJS from 'Embark/EmbarkJS'
import Token from 'Embark/contracts/Token'

let currentToken

$(document).ready(function() {
  EmbarkJS.onReady(error => {
    $('#useToken button').click(function() {
      var address = $('#useToken input').val()
      currentToken = new EmbarkJS.Blockchain.Contract({
        abi: Token.options.jsonInterface,
        address: address
      })
    })

    web3.eth.getAccounts(function(err, accounts) {
      $('#queryBalance input').val(accounts[0])
    })

    $('#queryBalance button').click(function() {
      var address = $('#queryBalance input').val()
      currentToken.methods
        .balanceOf(address)
        .call()
        .then(function(balance) {
          $('#queryBalance .result').html(balance)
        })
    })

    $('#transfer button').click(function() {
      var address = $('#transfer .address').val()
      var num = $('#transfer .num').val()

      currentToken.methods
        .transfer(address, num)
        .send()
        .then(function() {
          $('#transfer .result').html('Done!')
        })
    })
  })
})
@iurimatias this is my code and response in a log
Rahul Trivedi
@rahultrivedi180
@iurimatias may be this is a bug in blockchain.js file of a framework!! you should check it out by running that tutorial by yourself
Iuri Matias
@iurimatias
@rahultrivedi180 you have a working version here https://github.com/embark-framework/dapp-bin/tree/master/TokenFactory2
Jonathan Rainville
@jrainville
@rahultrivedi180 when you ran embark on the terminal, did it have any errors? Also, which command did you use to run embark?
Rahul Trivedi
@rahultrivedi180
@iurimatias embark 3.2.7 have some issues.
Rahul Trivedi
@rahultrivedi180
@iurimatias this is the repo of my code. run it with embark 3.2.7: https://github.com/rahultrivedi180/TokenFactory
node: 10.14.1
npm: 6.4.1
Rahul Trivedi
@rahultrivedi180
@jrainville no errors in console. I use embark run
@jrainville this is the repo: https://github.com/embark-framework/dapp-bin/tree/master/TokenFactory2
run with embark 3.2.7, node 10.14.1
Rahul Trivedi
@rahultrivedi180

Screenshot from 2018-12-09 14-15-43.png

This is what i am saying. @iurimatias

Rahul Trivedi
@rahultrivedi180
@iurimatias problem solved!!
Rahul Trivedi
@rahultrivedi180
@iurimatias will make a PR!
Rahul Trivedi
@rahultrivedi180
how do i connect metamask?
Pascal Precht
@PascalPrecht
@rahultrivedi180 you make your dapp connect through Metamask by putting $WEB3 in your dappConnection config at the first item in the list.