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.

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 ...
4
votes
3answers
6k views

Invalid JSON RPC response error for sendTransaction on Infura + Ropsten node + Truffle console

Calls work but transactions throw the error - Error: Invalid JSON RPC response: "" I am using web3 v0.19.0 & Truffle v3.4.9. Deploying contract using truffle, truffle migrate --network ...
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.
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 ...
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 { ...
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; ...
7
votes
1answer
1k views

How can I take a snapshot of Ganache or Truffle Develop state and reload later?

I would like to be able to save the state of my local Ganache or Truffle Develop chains into some sort of file. At a later time, I would like to be able to restart Ganache or Truffle Develop and apply ...
4
votes
4answers
2k views

Truffle for Windows: I can't make it work

I've installed Truffle v3.2.1 for Windows. If I try to run: truffle console Could not find suitable configuration file. If I run: truffle create:contract MyContract I get nothing but command ...
12
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 ...
11
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 ...
23
votes
12answers
20k 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
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 ...
5
votes
4answers
701 views

I can't verify my contract on the Rinkeby etherscan site

I'm getting the following error when verifying on the RINKEBY etherscan site: Error! Unable to verify source code Exception #1 Occured: ERROR|The Contract solidity compilation has exceeded the ...
7
votes
1answer
2k views

Simulating the passage of time with testrpc

Any tips on how to simulate real network conditions on the testrpc testing client using truffle? I have some functions that look at blocknumber and try to deal with passing time. Has anyone come up ...
6
votes
2answers
1k views

Debugging JS unit tests with truffle framework in VS code

Is there a way to debug JS unit tests for smart contracts? I use VS Code for development, and when I try to run a Mocha debugger it complains that artifacts is not defined. I briefly looked at truffle ...
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 ...
3
votes
2answers
2k views

Unit tests written in Solidity, how to change msg.sender address, msg.value,

I would like to know if it's possible to change the address of the message sender of contract's function call when writing unit tests in solidity. It really should be, I was trying to find out how but ...
7
votes
2answers
2k views

What are the best practices to keep your ethereum smart contract code from being copied and reused?

I'm new to smart contract development. I have built a couple of sample projects and deployed those to my private network. So now I am doing some research on best practices in regards to smart contract ...
1
vote
2answers
2k views

Deploy multiple contracts with dependencies - Truffle

Say I have two contracts, an oracle and a reader. How do I test (or even deploy) them both? contract Oracle { struct DocumentStruct{bytes32 name; uint value;} mapping(bytes32 =&...
20
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 ...
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 ...
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 ...
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.
7
votes
1answer
9k 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? ...
5
votes
1answer
3k views

Error calling a function from another contract: Member “*” not found or not visible after argument-dependent lookup in type

I'm having trouble compiling a contract that calls a function of an imported contract. SilverCoin.sol: pragma solidity ^0.4.11; contract SilverCoin { function abc() constant returns (uint) { ...
5
votes
2answers
2k views

How to get the transaction cost in a Truffle unit test?

How can I get the actual gas consumed by a sendTransaction inside a truffle test? In the following test, buyer sends an amount of 50 ETH to a contract: const EmptyContract = artifacts.require("...
2
votes
2answers
7k views

truffle console - invoking contract function usage (Version 3)

I have a simple contract like below. I was able to successfully compile and migrate the same. pragma solidity ^0.4.8; contract A { function A() payable { } function getBal() returns(...
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 ...
1
vote
1answer
316 views

UnhandledPromiseRejectionWarning: Error: Subscriptions are not supported with the CustomProvider [duplicate]

Trying to deploy the newly created contract into rinkeby test network but got struck with the below error. Please check the code, error message and package.json details below. const HDWalletProvider =...
6
votes
1answer
652 views

Truffle exits with “Error: The contract code couldn't be stored, please check your gas amount.” error when migrating the 1_initial_migration.js

I am trying to migrate the basic truffle example (the one created via truffle init) to rospten using Parity but I get the following error even thought the contract is correctly deployed on Rospten: ...
6
votes
3answers
3k views

Truffle + INFURA for deployment

I've recently started to use Truffle to automate/speed up my development. As I'm still getting the grasp of it I've come up with a barrier when trying to use INFURA for migrations. INFURA nodes don'...
1
vote
1answer
349 views

Transaction not found after 50 blocks on mainnet

I updated geth & truffle today. Now I'm getting "Transaction not found after 50 blocks" when trying to deploy to mainnet. I tried setting my gas higher than anything on http://ethgasstation.info/...
1
vote
2answers
968 views

Error in unboxing truffle-react on Windows

I am trying to unbox truffle-react but I am stuck with this error: $ truffle unbox react Downloading... Unpacking... Setting up... Error: Command failed: npm install npm WARN deprecated ethereumjs-...
0
votes
3answers
2k views

I can't run truffle commands in powershell Ise

I am looking around for questions similar to mine but basically I cannot run any truffle commands in the powershell Ise ONLY. I can make it run on the node.js command line. example: > PS C:\Users\...
19
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 ...
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 ...
14
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 ...
10
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 {
9
votes
1answer
646 views

Truffle framework with storage

How can I integrate truffle with swarm or ipfs for permanent document storage? Are there any libraries?
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+...
7
votes
2answers
12k 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 ...
7
votes
2answers
16k 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 ...
6
votes
2answers
3k views

Creating contracts via new doesn't work

According to the official doc, a contract can create a new contract using the new keyword. But it does not work when I test the code from this post. My dev environment is truffle 2.1.1 and testrpc (or ...
6
votes
5answers
7k views

How do I find the exact solidity compiler version used by truffle?

I'm trying to verify a contract I have compiled and deployed onto the network using Etherscan. The contract was compiled using truffle. How do I work out exactly which version of the solidity compiler ...
12
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) { ...
2
votes
1answer
2k views

How to manually initialize a truffle project? (“truffle init”)

I cannot run truffle init on my company PC. (see Cannot run truffle behind proxy?). I used a network sniffer and found that the connection was reset when trying to establish an SSL connection 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
7
votes
3answers
4k views

Error encountered, bailing. Network state unknown. Review successful transactions manually

Problem I get the following error after running $ truffle migrate --reset: Running migration: 1_initial_migration.js Replacing Migrations... ... ...
6
votes
2answers
4k views

How to interact with contracts using the abstraction in truffle

sorry if this is really basic but I'm a bit stuck. I'm playing with the default MetaCoin contract in Truffle and testing it against testrpc. Reading through the truffle docs (http://truffle....
5
votes
1answer
1k views

Accessing testrpc addresses from solidity tests

I'm consulting truffle's docs on how to test contracts directly in solidity. http://truffleframework.com/docs/getting_started/solidity-tests I'd like to figure out a way to refer to existing testrpc ...