Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [truffle]

Questions regarding the implementation and use of the Truffle development and testing environment.

39
votes
6answers
18k views

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

When I try to run my migration with truffle migrate the following error message appears: Error: No network specified. Cannot determine current network. at Object.detect (/usr/local/lib/...
26
votes
1answer
15k views

How to update a deployed smart contract? [duplicate]

I've started developing smart contracts with Truffle and when I edit a contract I always redeploy it by adding another migration script. There are two things that I wonder about: Is this the way it ...
26
votes
4answers
6k views

Error while compiling: Stack too deep

When trying to compile, I am getting the following error: "Internal compiler error: Stack too deep, try removing local variables." Is there any way around this? I'm not sure if I'll be able to ...
25
votes
10answers
9k views

How can you handle an expected throw in a contract test using truffle and ethereum-testRPC?

Is it possible to write a test using truffle that attempts to confirm that a throw occurs in a contract? For example, if I had a contract with function... contract TestContract { function testThrow(...
24
votes
3answers
9k views

What are truffle migrations?

As written in Truffle docs: Migrations are Javascript files that help you deploy contracts to the Ethereum network. These files are responsible for staging your deployment tasks, and they're ...
22
votes
12answers
19k views

How to upgrade solidity compiler in truffle

I couldn't find a way to upgrade a version of truffle solidity compiler. Also curious how to see that information for deployed contracts in truffle console
22
votes
4answers
4k views

what does `deploy.link` exactly do in `truffle`

Please explain use cases for deploy.link() function in migrations in truffle framework. How would you use it and for what.
21
votes
2answers
5k views

Oracle (oraclize.it) with Truffle and Testrpc

As I understood in the blockchain, it is "not" possible to interact with webservices outside the blockchain. This must be done over oracles in order to verfiy that the request is secure, and the state ...
20
votes
14answers
13k views

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

I seem to have followed the truffle guide to a T. But when I open my app in a browser for the first time, I'm getting this error in the console: Error: MetaCoin has not been deployed to detected ...
19
votes
3answers
3k views

how to catch “revert” error in truffle test javascript?

How can I catch "revert" error in truffle test written in javascript? Error: VM Exception while processing transaction: revert Here is part of test contract, function doRevert() public { ...
19
votes
5answers
16k views

How to listen for contract events in JavaScript tests?

I'm trying to trigger events in my solidity contract to output some debug information in my javascript tests. However the events seem to get never caught. That's the relevant contract code: pragma ...
19
votes
5answers
5k views

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

Truffle configuration file is mentioned in several places on the web (GitHub, truffle package on npm, solidity-coverage package on npm, etc.). Some refer to it as 'truffle.js, others refer to it as ...
19
votes
6answers
12k views

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

I'm trying to deploy a sample contract (following this guide) but I'm receiving an error of not enough gas. I changed the numbers a little but could not fix it. I saw this question in stack exchange ...
18
votes
1answer
4k views

What is truffle?

What is the truffle framework? Who can use it, who should use it? And what are the benefits?
18
votes
6answers
9k views

truffle has not been deployed to detected network

Is it possible to referer to a contract that has been deployed with Contract.new() with Contract.deployed() ? When referencing .deployed() in my test it throws : has not been deployed to detected ...
18
votes
3answers
6k views

How do I specify a different Solidity version in a Truffle contract?

I've got a contract where I want to use <address>.transfer(), which was released in the latest Solidity version 0.4.10. I have as the first line of my contract: pragma solidity 0.4.10; but ...
16
votes
2answers
10k views

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

I´m having problem with the basic HelloWorld example coded in Solidity and managed with truffle with testrpc. pragma solidity ^0.4.2; contract HelloWorld { uint public balance; ...
16
votes
1answer
14k views

Steps to deploy a contract using MetaMask and Truffle [closed]

i'm noob, I want to deploy my contract on Ropsten network with MetaMask & Truffle, plz explain to me the steps to deploy it.
14
votes
2answers
2k views

What is the reason for writing truffle tests in .sol and .js files?

What is the reason that tests can be written in both? Is there any distinct advantage to using one over the other? Or is one in general easy to work with?
14
votes
4answers
9k views

'Error: base fee exceeds gas limit' When creating new contract instance (Using Truffle, Web3Js and testrpc)

I have the following code in app.js file of my truffle project. import { default as Web3} from 'web3'; import { default as contract } from 'truffle-contract' import conferrence_artifacts from '../../...
13
votes
1answer
5k views

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

I am having a problem with my smart contract making value transfers. My current environment: Truffle v5.0.0-beta.2 (core: 5.0.0-beta.2) Solidity v0.5.0 (solc-js) Node v8.11.1 I created the ...
13
votes
2answers
5k views

Truffle Migrations Account Locked Error with --network command

I have started a private blockchain using the command, geth --networkid 1337 --datadir ~/home/xyz/testnet --ipcpath /home/xyz/.ethereum/geth.ipc --rpc --rpcapi eth,web3 --rpcport 8545 --rpcaddr ...
12
votes
2answers
3k views

How to check events in Truffle Tests?

What's the best way to check that events were fired in a Truffle test?
12
votes
1answer
3k views

How do I control compiler settings with truffle?

I'm using truffle development environment for prototype contract development and I need to change compiler setting (e.g. turn optimization on and off). The documentation for the development ...
12
votes
3answers
6k views

Truffle console - How can I get and print the value returned by a contract function?

This is an absolute newbie question. Given this simple Hello World contract: pragma solidity ^0.4.4; contract Greeter { function Greeter() {} function sayHello() returns(string) { ...
12
votes
1answer
2k views

Etherscan: How can I verify a contract with multiple imports deployed with Truffle?

When I deploy a contract with Truffle that has an import statement, and try to verify it on etherscan, my understanding is that I need to paste in the contents of the imported file. I get an error on ...
11
votes
4answers
2k views

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

I'm trying to deploy a contract on the mainnet, but I've been getting some issues deploying with Truffle. ➜ ballot git:(master) ✗ truffle migrate --network mainnet --dry-run Using network 'mainnet' (...
11
votes
3answers
7k views

“SyntaxError: Unexpected token import” on truffle test

I get an "SyntaxError: Unexpected token import" error when I do 'truffle test'. I am trying to import a function declared in another file into the java-script test file. I have been searching about ...
11
votes
2answers
4k views

How to pass constructor parameters to a contract using Truffle?

I am using testrpc and truffle for deploying contracts.I want to pass constructor parameters while deploying. contract User { string public userName; function User(string ...
11
votes
1answer
5k views

Defining constructors as functions with the same name as the contract is deprecated. Use “constructor(…) { … }” instead [duplicate]

The warning is from running sample code from Mastering Ethereum, I get the above error and it says Use "constructor(...) { ... }" instead. function Migrations() public {
11
votes
5answers
805 views

what is a standard .gitignore for truffle?

I'm using the latest Truffle. Very nice, after having to roll my own dev environment in early 2016! But there is no obvious documentation as to what parts of the project need to be checked into Github....
11
votes
3answers
3k views

Truffle & Web3 1.0.0-beta : does it work for anyone?

I'm trying to make the latest Truffle (3.4.3) and Web3 (1.0.0-beta11) to work together in a React app. It fails when I try to call myContractInstance.deployed() import { default as Eth} from 'web3-...
10
votes
4answers
2k views

Running truffle migrate just opens my truffle.js file and does nothing

I am following this tutorial: http://truffleframework.com/tutorials/building-dapps-for-quorum-private-enterprise-blockchains. I am trying to run truffle migrate on my project but it just opens my ...
10
votes
3answers
5k views

Truffle invalid address

With Truffle 3.0 when I call one of my contract's function, in console I have this error: Uncaught (in promise) Error: invalid address I found this workaround, and in my code I try this with no ...
10
votes
1answer
4k views

Truffle migrate fails

I am using testrpc. While running truffle migrate I get the following error: /usr/local/lib/node_modules/truffle/node_modules/truffle-contract/contract.js:671 throw new Error(this....
10
votes
2answers
2k views

Truffle: Hanging on “Deploying Migrations…”

I am deploying a contract on a private testnet. I am using Parity. When I type: $ truffle migrate --network my-network-name I get a popup in the Parity interface for a password to my account. I ...
9
votes
2answers
3k views

truffle + testrpc time manipulation [duplicate]

I use truffle + testrpc for testing my contracts and I need to test some time-dependant code (I guess that situation is quite common). I set some objects, check some conditions, then I need to ...
9
votes
2answers
2k views

Truffle + Infura on Mainnet: Nonce too low error

I have the following code: const Contract = artifacts.require('./Market.sol'); module.exports = async function(callback) { let instance = await Contract.deployed(); for(var i = 0; i <=200; i+...
9
votes
2answers
5k views

Manually execute transactions using testrpc and truffle

I started doing a bit of work in the geth console: geth --dev console but have moved to developing using truffle. To debug in the geth console, I'm used to executing the following: eth....
9
votes
1answer
6k views

Could somebody please explain in detail what this Ethereum contract is doing?

I am new to ethereum & blockchain technology and trying to understand somethings(Etheruem, Truffle, DApps etc.) here and there from the internet. From Ethereum official website, Create a ...
9
votes
3answers
837 views

trouble matching gas used in transaction with difference in account balance

I've fired up my testrpc and deployed a simple HelloWorld contract using truffle. I send a simple transaction to my contract and I log my account balance before and after the transaction. ...
9
votes
3answers
6k views

TRUFFLE: What is the best way to to get the JSON ABI code after deploying a contract with truffle to Ganache or Kovan?

Remix makes it so easy to get the json abi code. Does anyone have any recommendation on how best to get he json abi code after successfully deploying a contract using truffle without having to ...
9
votes
1answer
1k views

how can I run a truffle test in a debugger? [duplicate]

as a developer I want to run my javascript test in a debugger so as to be able to step through tests and inspect the values of variables. The goal is to run it in a Mocha debug mode
9
votes
1answer
2k views

Custom balance accounts testrpc?

I am setting up unit tests with for my contracts using truffle. I am using also testrpc, but having accounts with 2.123...... *10^37 Wei is not very helpful to visualise and debug things. I am trying ...
9
votes
3answers
5k views

truffle migrate fails with: Error encountered, bailing. Network state unknown

Could someone point out what is happening with truffle. "truffle compile" works fine. Please find the below truffle migrate reset output Ubuntu#truffle version Truffle v3.1.2 Ubuntu#truffle migrate ...
9
votes
1answer
643 views

Truffle framework with storage

How can I integrate truffle with swarm or ipfs for permanent document storage? Are there any libraries?
9
votes
1answer
500 views

Configure Truffle Compiler: Default Import Folder

I want to use an external library. I guess it is good to load the library in production from a CDN because this requires less space and should be faster. import "github.com/Arachnid/solidity-...
8
votes
2answers
7k views

How do you get the balance of an account using truffle/ether-pudding?

Is there an ether-pudding way to get the balance of a contract/account, or should I just use web3.eth.getBalance(account)?
8
votes
2answers
7k views

Truffle does not work - could not find suitable configuration file

I have searched some answers here and on google as well but none of them actually apply to my case. I tried on console and power shell to run truffle migrate but I keep getting could not find ...
8
votes
1answer
3k views

Return Token Contract address on truffle deploy

I am trying to figure out how to return the address of a contract when I deploy it with truffle's deployer.deploy. So the goal is that when I deploy a contract that is a custom token, I want to ...