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: {
...
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 ...
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 ...
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 ...
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/...
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, ...
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 = {
...
...
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 = ...
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 ...
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 ...
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" --...
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 ...
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 ...
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: ...
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.
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 ...
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 ...
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 ...
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....
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 = ...
25
votes
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 ...
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 ...
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 ...
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"
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, ...
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, ...
24
votes
Accepted
Truffle migrate vs Truffle deploy
truffle deploy is an alias for truffle migrate. They both do the same thing.
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 ...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
truffle × 2931solidity × 1219
web3js × 477
truffle-migration × 335
contract-development × 235
ganache × 218
go-ethereum × 214
truffle-test × 208
truffle-contract × 202
testing × 188
contract-deployment × 181
testrpc × 181
javascript × 144
metamask × 140
truffle-deployment × 116
blockchain × 106
remix × 84
nodejs × 78
react × 78
truffle-compile × 75
dapps × 66
ropsten × 64
dapp-development × 59
infura × 59
contract-debugging × 56