Hot answers tagged

69 votes
Accepted

Truffle Migrate doesn't work: Error: No network specified. Cannot determine current network

Make sure that you have configured your network in truffle.js. It should look something like this for the setup mentioned above: module.exports = { networks: { development: { ...
user1491307's user avatar
  • 1,221
53 votes
Accepted

Contract should be marked as abstract

Overview of the issue You get this error whenever there are functions you need to implement in your contract from an inherited contract. For example, if you have a contract that inherits an interface ...
Markus - soliditydeveloper.com's user avatar
50 votes

What is the real price of deploying a contract on the Mainnet?

The cost of your deployment is based on 5 things, with a 6th affecting the estimated cost of deployment: The flat fee of 32k gas. The CREATE op code, which is called during contract creation, costs a ...
natewelch_'s user avatar
  • 11.6k
50 votes
Accepted

how to catch "revert" error in truffle test javascript?

Answer by example: Suppose you have a function that can be invoked only by the owner (deployer) of the contract. If it's invoked by anyone other than the owner, then it reverts (require with a false ...
goodvibration's user avatar
45 votes

How to upgrade solidity compiler in truffle

You can force truffle to use a specific solc version by installing that version directly in the truffle directory. For example on Ubuntu the following with force truffle to use 0.4.15 $ cd /usr/...
Adam Lemmon's user avatar
38 votes
Accepted

How to update a deployed smart contract?

Contract code is permanent. There is no way to alter the code of a deployed contract except by destroying it altogether by the SELFDESTRUCT opcode (selfdestruct() in solidity.) There's four ways, ...
Matthew Schmidt's user avatar
36 votes

How to upgrade solidity compiler in truffle

If you're using ^v5.0.0 (including beta releases), you can bring your own compiler by adding this in your truffle config file (in this example it's set to 0.4.25): module.exports = { ... ...
Paul Razvan Berg's user avatar
34 votes
Accepted

In the truffle console, how to set and get current account?

In truffle console: var accounts; // in web front-end, use an onload listener and similar to this manual flow ... web3.eth.getAccounts(function(err,res) { accounts = res; }); var account1 = ...
Rob Hitchens's user avatar
  • 54.3k
33 votes
Accepted

Difference between Ganache and Truffle

Ganache allows you to create a private Ethereum blockchain for you to run tests, execute commands, and inspect state while controlling how the chain operates. It gives you the ability to perform all ...
Shane Fontaine's user avatar
32 votes

Oracle (oraclize.it) with Truffle and Testrpc

It is very possible to use the Oraclize service with testrpc alongside truffle. Firstly, you need to follow the naming convention of contract filenames in truffle. As per their docs: Truffle ...
DenisM's user avatar
  • 1,021
32 votes
Accepted

Steps to deploy a contract using MetaMask and Truffle

Solution 1: With you own node You can easily deploy on the ropsten network if you own a full node running on your machine. i. Run geth $ geth --fast --cache=1048 --testnet --unlock "0xmyaddress" --...
Greg Jeanmart's user avatar
31 votes
Accepted

Error while compiling: Stack too deep

You're hitting a StackTooDeepException. The Solidity code doesn't appear to be consistent in the number of variables it sees as a problem, but you've got a limit of around 16 or 17. (Though clearly ...
Richard Horrocks's user avatar
30 votes
Accepted

truffle migrate: How to deploy a contract whose constructor takes a parameter

You can add the constructor parameters as extra arguments to the deploy() call const BaconMaker = artifacts.require('./BaconMaker.sol') module.exports = (deployer, network, accounts) => { const ...
Ismael's user avatar
  • 30.3k
29 votes

Truffle deployment on test network says: Error: exceeds block gas limit

Inside truffle.js, add ,gas: 4600000 Don't forget the little "," so it looks like networks: { development: { host: "localhost", port: 8545, network_id: "*", gas: ...
Russo's user avatar
  • 1,720
29 votes
Accepted

Truffle does not work - could not find suitable configuration file

Very noob mistake from my part. I have actually to initialize the project before migrating it. truffle init after that truffle migrate sorry.
EAzevedo's user avatar
  • 671
28 votes
Accepted

What are truffle migrations?

The Migrations contract stores (in last_completed_migration) a number that corresponds to the last applied "migration" script, found in the migrations folder. Deploying this Migrations contract is ...
Xavier Leprêtre B9lab's user avatar
28 votes

how to catch "revert" error in truffle test javascript?

Most of these answers are straightforward enough, but the ones that do an inline try catch make for quite a bit of boilerplate, and the creation of the utility functions is not really something you ...
Rosco Kalis's user avatar
  • 2,097
27 votes
Accepted

How to convert BigNumber to Number in Truffle framework?

If your token have 18 decimals like an ether you can use then(function(balance) { console.log(web3.fromWei(balance.toNumber(), "ether" ) ); }) Use fromWei to convert your bigNumber to ether ...
0xCrema.eth's user avatar
  • 1,182
27 votes
Accepted

Member function "transfer" not found or not visible after argument-dependent lookup in contract?

This is due to some breaking changes in Solidity version 0.5. Namely that an address has to be marked as payable - otherwise it won't have the transfer function. More info here: https://solidity....
Lauri Peltonen's user avatar
26 votes
Accepted

Truffle migrate fails

This seems to occur if you're trying to deploy contract A that depends on contract B before contract B has actually finished deploying. You probably have something like this: module.exports = ...
Mike Shultz's user avatar
  • 1,172
25 votes

I want to know how to quit the truffle console?

The command ".exit" also will exit the console.
bingyu's user avatar
  • 441
25 votes
Accepted

how to know the contract address which truffle is deploying with

There are a few ways to do this: 1) In your blockchain node (testrpc|ganache or your test/live network with geth/parity), the contract deployments will be logged and you can see the address created ...
carlolm's user avatar
  • 2,306
25 votes

How to check events in Truffle Tests?

I wrote the truffle-assertions package just for this. It has an assertion to check that an event has been emitted. Essentially, it is similar to the older answer here, but it does not need to check a ...
Rosco Kalis's user avatar
  • 2,097
25 votes
Accepted

Truffle: how to get balance of any address or contract's address

Try contract('CreeptomaPresale', function(accounts) { describe("adopted over allow quantity", function () { it("test get balance", async function () { let ...
Rob Hitchens's user avatar
  • 54.3k
24 votes
Accepted

How to pass constructor parameters to a contract using Truffle?

In Truffle, constructor params go in /migrations. So, something like: deployer.deploy(User, "foo"); User.deployed() will be a User contract that was deployed with _name="foo"
Rob Hitchens's user avatar
  • 54.3k
24 votes
Accepted

Problem with Truffle Console: Cannot read property 'call' of undefined

If you are running the latest version of Truffle (v.3.x), the way to call a function or variable in your contract has evolved a little bit according to the Upgrading documentation In Truffle 2.0, ...
Greg Jeanmart's user avatar
24 votes
Accepted

Truffle Webpack starts with error: MetaCoin has not been deployed to detected network

One thing to check would be the network ID. It doesn't matter what network ID you use for your local test node, but Truffle needs to agree about what you're using with testrpc. With testrpc running, ...
Edmund Edgar's user avatar
  • 16.7k
24 votes
Accepted

Truffle migrate vs Truffle deploy

truffle deploy is an alias for truffle migrate. They both do the same thing.
Edmund Edgar's user avatar
  • 16.7k
24 votes
Accepted

Truffle configuration file name - is it 'truffle.js' or 'truffle-config.js'?

On windows systems having truffle.js in your main folder may create a conflict when you try to execute truffle. Windows first try for executables in your current directory, and .js files are ...
Ismael's user avatar
  • 30.3k
23 votes
Accepted

What is truffle?

What is Truffle? Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. It is one of the most widely used IDEs ...
Hudson Jameson's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible