Difference between revisions of "Setting up Truffle to interact with Ganache"

From rbachwiki
Jump to navigation Jump to search
Line 21: Line 21:
  app.setGreetings("hello",{from: web3.eth.accounts[0]})
  app.setGreetings("hello",{from: web3.eth.accounts[0]})


Get additional information on a transaction
# In Ganache, get the transaction hash
web3.eth.getTransaction("0x7c2e6806df6f1a50a4fff22ca371938be5a0059b1c4c7887ed8e63694ca2e377")


==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Solidity_ethereum_Language|Category]]==
==[[#top|Back To Top]]-[[Main_Page| Home]] - [[Solidity_ethereum_Language|Category]]==

Revision as of 00:16, 14 March 2018

Setting up Truffle to interact with Ganache GUI

Edit the truffle.js file. add:

networks: {
ganache: {
 host: "localhost",
 port: "7545",
 netork_id: "*"
}
}

Go to the project directory in terminal. we have to tell truffle to migrate the contract to the ganache network

truffle migrate --compile-all --reset --network ganache

Interact with ganache

truffle console --network ganache

Interact with the contract

Greetings.address
Greetings.deployed().then(function(instance){app=instance;})
app.getGreetings()
app.setGreetings("hello",{from: web3.eth.accounts[0]})

Get additional information on a transaction

  1. In Ganache, get the transaction hash
web3.eth.getTransaction("0x7c2e6806df6f1a50a4fff22ca371938be5a0059b1c4c7887ed8e63694ca2e377")

Back To Top- Home - Category