Episode #125 of the Stack Overflow podcast is here. We talk Tilde Club and mechanical keyboards. Listen now

Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
42
votes
6answers
19k 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/...
28
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 ...
28
votes
3answers
10k 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 ...
26
votes
13answers
23k 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
26
votes
10answers
10k 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(...
26
votes
1answer
16k 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 ...
25
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.
24
votes
14answers
14k 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 ...
22
votes
5answers
7k 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 ...
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 ...
21
votes
6answers
13k 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 ...
20
votes
3answers
4k 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 { ...
20
votes
5answers
17k 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 ...
20
votes
6answers
10k 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 ...
20
votes
3answers
9k 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 ...
19
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
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.
18
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; ...
17
votes
4answers
10k 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 '../../...
16
votes
3answers
3k views

How to check events in Truffle Tests?

What's the best way to check that events were fired in a Truffle test?
15
votes
1answer
7k 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 ...
15
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?
15
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 ...
15
votes
2answers
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 ...
14
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 ...
13
votes
4answers
8k 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 ...
13
votes
3answers
7k 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
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' (...
12
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 ...
12
votes
2answers
13k views

How do Enums work?

I am just starting out with Solidity and JavaScript and am trying to understand Enums. I have a simple contract pragma solidity ^0.4.4; contract SimpleEnum { enum SomeData {Channel} SomeData ...
12
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....
12
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 ...
12
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-...
11
votes
3answers
6k 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 ...
11
votes
1answer
6k 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
937 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
2k views

How to set the timeout for truffle test's before block?

I'm running my tests on a private chain and some of them times out: 1) "before all" hook: Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning ...
10
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 ...
10
votes
3answers
17k views

How to convert BigNumber to Number in Truffle framework?

I have written an ERC20 token contract and deployed it in test network using truffle framework. When I check the token balance for an account using web3 it was giving the result in BigNumber when I ...
10
votes
2answers
4k views

I want to know how to quit the truffle console?

just like the question!! I always kill the progress by kill the main shell. I want to change this way.
10
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....
10
votes
1answer
2k views

What are artifacts in truffle?

Your build artifacts are saved within the ./build directory, along side the compiled deployed contract artifacts in ./build/contracts. What exactly are these artifacts?
10
votes
1answer
542 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-...
9
votes
2answers
2k views

Deploy multiple contracts using truffle

I am very new to developing smart contracts. I have a simple question, do i need to write migration file separately for each contract i deploy from an account using truffle or can i deploy multiple ...
9
votes
2answers
8k 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 ...
9
votes
2answers
3k 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
5answers
822 views

Prevent 'truffle test' from invoking 'truffle deploy (migrate)'

It seems that truffle test automatically invokes truffle deploy (aka truffle migrate). As far as I'm concerned, these two functionalities are completely unrelated. So I cannot quite figure out why ...
9
votes
1answer
7k 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
7k 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
2k 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