Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
43
votes
14answers
41k 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
42
votes
6answers
20k 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/...
42
votes
3answers
14k 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 ...
34
votes
5answers
8k 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 ...
31
votes
1answer
22k 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 ...
30
votes
10answers
12k 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(...
29
votes
4answers
8k 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 { ...
28
votes
4answers
6k 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.
26
votes
6answers
14k 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 ...
26
votes
3answers
20k 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 ...
25
votes
14answers
15k 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 ...
25
votes
6answers
16k 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 ...
24
votes
5answers
10k 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 ...
23
votes
1answer
5k views

What is truffle?

What is the truffle framework? Who can use it, who should use it? And what are the benefits?
22
votes
5answers
19k 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 ...
21
votes
2answers
12k 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; ...
21
votes
3answers
12k views

Difference between Ganache and Truffle

What is the difference between this two? I understand that Ganache is like a fake blockchain, but Truffle has that too ? What are the limitations of each and under which circumstance we use either ...
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
3answers
7k views

How to check events in Truffle Tests?

What's the best way to check that events were fired in a Truffle test?
20
votes
5answers
30k views

Source File requires different compiler version

I am using solidity version "pragma solidity ^0.4.20;". When I checked JSON files of contract, compiler version shows : "compiler": { "name": "solc", "version": "0.4.21+commit.dfe3193c....
19
votes
5answers
11k 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' (...
19
votes
1answer
16k 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.
19
votes
4answers
13k 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 '../../...
18
votes
4answers
30k 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 ...
17
votes
2answers
14k 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 ...
17
votes
2answers
4k 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 ...
16
votes
1answer
10k 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 ...
16
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?
16
votes
3answers
6k 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 ...
16
votes
3answers
10k 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) { ...
16
votes
1answer
5k 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 ...
15
votes
2answers
6k 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 ...
14
votes
4answers
6k 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.
14
votes
2answers
17k 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 ...
14
votes
2answers
6k 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....
14
votes
6answers
2k 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....
13
votes
4answers
9k 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
5answers
2k 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 ...
13
votes
5answers
12k 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 ...
13
votes
2answers
8k views

How to send ether to a contract in truffle test?

For some reason I cant figure out how to send ether to a contract when testing in truffle. This is my attempt: await myContract.send(10, {from: accounts[0]}); the error message is: Error: VM ...
13
votes
4answers
5k 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 ...
13
votes
2answers
5k 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?
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
1answer
4k views

How to choose an account to deploy a contract in truffle

How do you select an account to deploy a contract using: 1)Metamask 2)Parity 3)some config file
12
votes
1answer
7k 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 {
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
2answers
14k views

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

I'm using the $ truffle console. I can see my available accounts using truffle(development)> web3.eth.accounts. But when I run some smart contract code, which account is running the contract? ...
11
votes
6answers
8k views

Undefined results for “web3.eth.accounts” in truffle console

truffle(development)> web3.eth.accounts[0] gives output as "undefined" truffle(development)> web3.eth.accounts instead of showing all accounts details gives the below output Accounts { ...
11
votes
3answers
8k 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
2k views

How to unit test contract private and internal functions?

How can we unit test contract private functions using the Truffle framework? Since Solidity doesn't have package access or reflection language features, standard private testing approaches don't work....

1
2 3 4 5
51