Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
6
votes
1answer
1k views

invalid JUMP after upgrading truffle & testrpc

I have a contract with a method add() where I read the value msg.value and change the contract informations. before upgrading, I was calling this method in my test with return contract.add({from: ...
6
votes
2answers
6k views

Simplest way to integrate Infura with a Web3/Truffle app?

I have a Truffle/Web3 app which has this code in app.js (by default) which runs when the page is loaded: $(document).ready(function () { if (typeof web3 !== 'undefined') { console.warn('Using ...
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'...
6
votes
3answers
1k views

I get error couldn't find module 'ethereumjs-wallet/hdkey'

I was running this code deploy.js const HDWalletProvider = require('truffle-hdwallet-provider'); const Web3 = require('web3'); const { interface, bytecode } = require('./compile'); const provider = ...
6
votes
1answer
3k views

What is the difference between Truffle and Remix?

Please list the differences between Truffle and Remix. Where is the use of both applicable? Can somebody list this using an example?
6
votes
1answer
664 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
2answers
2k views

getData() is not working

I want to call a function of the contract, something like this - module.exports.transfer = function(to,value,){ return token.methods.transfer.getData(to, value); } But I am facing the error ...
6
votes
3answers
1k views

testrpc, contract creating contract not mined?

I'm trying to develop a contract that creates a contract (factory/worker, faucet pattern). Think my issue may be with the tools I'm using: testrpc (local blockchain) Remix Browser Solidity (connected ...
6
votes
1answer
3k views

How to set a sender address when deploying a contract with Truffle?

I don't seem to find the answer to what looks like a really basic question. How does one specify a sender address when deploying a new contract using Truffle ? My contract is owned. So most of my ...
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
2answers
2k views

Cannot read property 'call' of undefined

I am running HelloWorld contract. pragma solidity ^0.4.2; contract HelloWorld { uint public balance; function Helloworld(){ balance = 1000; } } After truffle compile and truffle ...
6
votes
1answer
2k views

How do I manage unlocking accounts in a test in Truffle

I have a test that exercises a contract function across different accounts. How do I unlock these accounts in the context of the test? contract('MyContract', function (accounts) { it("should ...
6
votes
1answer
606 views

Event.watch gets fired infinitely many times

I am trying out truffle + web3 + ethereumjs-testrpc. In the app I have the following code: window.onload = function() { var meta = MetaCoin.deployed(); var event = meta.Transfer({}, {fromBlock: 0,...
6
votes
1answer
853 views

Not enough components (4) in value to assign all variables (6)

This is an exception on compilation I am getting with truffle. The code I am running builds a store from a container contract and then makes a call to get a product from it. Store s = Store(saddress)...
6
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 ...
6
votes
1answer
3k views

Truffle Dapp only works when I first use `truffle migrate --reset`

When I first load my Dapp with testrpc the functionality doesn't work until I use the command truffle migrate --reset Any ideas why?
6
votes
1answer
502 views

Workflow for Dapp Development

There is so much information out there that turns around this point that I decided to make a post, can someone please help out? Does that sound correct as a work-flow for medium/large size projects ?:...
6
votes
2answers
985 views

Getting error message from require()

I know that the latest Solidity supports error messages in require/revert (require(stuff, "problem")). Are there any clients that can get this message? Will I be able to see it if I execute the ...
6
votes
1answer
240 views

Truffle debug on function call show null variables

With a truffle version of 4.1.0, using truffle debug on a call of my contract function below: function Deposit (uint256 timeout, bytes32 hash, address recipient) public payable returns (...
6
votes
1answer
413 views

Reset balance in truffle test accounts after each test

I am writing unit tests for a function where I am sending tokens from one address to other in exchange of ether. I ran these tests a few times and now I am left with 0 ether in one account. I tried ...
6
votes
3answers
368 views

Why does truffle always fail with “Error: Don't set config.from directly. Instead, set config.networks and then config.networks[<network name>].from”

I have a problem that suddenly appeared, and now I get it every time that I try to run truffle test or truffle migrate, regardless of which project it is. I've even tried fetching the Petshop from the ...
6
votes
3answers
1k views

Interacting with a deployed contract: How can I mint a token based on the Open Zeppelin Standard

Please excuse what seems to me a basic question, as I am very new to this: I'm using the truffle framework to deploy a smart contract. Playing around with Open zeppelin standard tokens, I've issued ...
6
votes
2answers
1k views

What are explicit steps to deploy dapp to mainnet?

There doesn't seem to be much documentation on how to transition your truffle DApp from working locally to being migrated to the mainnet. Below are some steps I generally would think are necessary: ...
6
votes
1answer
401 views

Is truffle based on node and is it possible to run some kind of node debugger in order to pause the Javascript tests and examine variables?

I am currently developing a Dapp and using truffle test to verify the contract. However, I find that I am also debugging the Javascript that runs the test with a lot of console.log() statements. This ...
6
votes
2answers
567 views

How to sequence steps in a truffle test?

I'm trying to test contract which rely on a particular state of other deployed contract. For example let say i have a contract wanting to test the "transfer" function of an ERC20 contract. I should ...
5
votes
1answer
6k views

How to get deployed contract address using Truffle 3.x console?

I opened truffle console and when I type my contract's name, I see a very long message on the console but not sure How do I deploy the contract and find the deployed contract address. Kindly advise.
5
votes
3answers
2k 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 { ...
5
votes
2answers
2k views

How to deploy a new version of the contract?

Probably this is not possible, but I still have to ask. Let me follow the example created in truffle init. It contains a contract called MetaCoin.sol. Say, I have deployed it on the network (the ...
5
votes
1answer
1k views

How can I import the accounts from truffle develop into MetaMask?

I use truffle develop. It seems to me that the accounts in truffle develop are persistent. Pleas correct me if I'm wrong. How can I import the accounts from truffle develop into MetaMask?
5
votes
4answers
4k views

How to access the deployed contract's address from Truffle JS tests?

I've written a test that involves returning the token balance that the contract itself holds. In the contract source file I would access the balance using the function getBalanceOf(this). However, ...
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("...
5
votes
1answer
2k views

Get transaction id after contract function call

I'm using truffle. How can I get transaction id before it is mined? For example: contract.purchase(price).then(function(tx) { console.log("Success"); }).catch(function(e){ console.log(e); }...
5
votes
3answers
3k views

Truffle solidity tests: out of gas & exceeds block gas limit

I am trying to run some basic test w/ my contract, written with Truffle's Solidity tests (tests written in Solidity). When runninng truffle test, I get Error: VM Exception while processing ...
5
votes
2answers
3k views

Constructor initializing another contract

I have a contract which is creating an instance of another contract. I am confused about deploying the contracts in Truffle. Does the constructor get initialized when deployed?
5
votes
3answers
1k views

Does deploying a contract mean it will overwrite the last instance?

I must have missed something about deploying contracts, but to be sure: I'm using Truffle, Does deploying a contract mean it will overwrite the last instance? Since I see that it gets a new address ...
5
votes
4answers
892 views

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider

I am trying to Deploy a beginners contract onto the rinkeby test network through Infura node. It is throwing the following error. (node:35183) UnhandledPromiseRejectionWarning: Unhandled promise ...
5
votes
3answers
4k views

Truffle deployer.deploy() not working

I'm having problems deploying the contract via Trufflem, using Parity as my client, on the Kovan network. The contract is a slight variation of this one. When I ran $ truffle migrate using the ...
5
votes
2answers
2k views

Accessing struct fields in Web3 returned by a promise in Truffle

I'm using web3js (via Truffle) to make a call to a contract, to access a struct in a mapping. mapping (bytes32 => entry) public entries; struct entry { Mode status; Deed deed; uint ...
5
votes
4answers
731 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 ...
5
votes
2answers
4k views

How to configure Truffle to use the Ganache GUI instead of ganache-cli (TestRPC)?

I'm using Truffle v4.0.1 (core: 4.0.1) with the default configuration (ganache-cli aka TestRPC) on Ubuntu and it works fine, but I'd like to use the Ganache GUI. However, I can't find any ...
5
votes
1answer
368 views

What Continuous Integration services support running Truffle Solidity tests?

What are the best practices for running a CI server that runs Truffle Solidity tests?
5
votes
1answer
950 views

Web3.js or Web3.py ? What is the more mature API to interact with Ethereum?

I'm started a new Dapp project, and I trying to find the best way for a quick prototype (back and front end dev). I most familiar with Python, so I search every element than I can to build a Dapp in ...
5
votes
2answers
5k views

passing String object with “0x..” value as bytes32 to a solidity function

I'm having trouble to pass bytes32 to a solidity function from javascript. It's converting to an incorrect bytes32 in solidity. The javascript is a test, running with truffle v3.3.1 on testRPC v3.0.5....
5
votes
3answers
2k views

accessing truffle contract abstractions from external JS script

When writing tests in truffle (v3.2.1) I can forget about things like a contract's ABI and address and just use ContractName.deployed() to interact with a contract on my testrpc chain. How can I mimic ...
5
votes
2answers
91 views

Is it safe to commit truffle build files to Github (open source)?

Regarding the json build files that Truffle produces based off of my smart contract, is it safe for this information to be treated as public? I just want to be sure it doesn't contain any sensitive ...
5
votes
1answer
2k views

“this._eth.sendTransaction is not a function” when executing method in Web3

I'm using react-web3 (which basically gives me a web3 object back) and I'm trying to make my contract work. This is the code I'm using: const web3 = window.web3; const contract = new web3.eth....
5
votes
3answers
1k views

How to properly catch events using MochaJs

Good day, I'm using mochajs to test my Solidity code using truffle and testrpc. In my contract I got the following event and function: contract store{ event MoneyIn (address _from, uint256 ...
5
votes
1answer
448 views

Oraclize + Testrpc + Truffle. Results aren't updating in contract

In my contract I am just doing a basic query to WolframAlpha function testOracle(){ oraclize_query("WolframAlpha", "random number between 0 and 100");} I also have the __callback function: ...
5
votes
4answers
2k views

How to use Truffle with Solidity 0.4

I just tried to set up a truffle project and tried to compile a contract I have already written. When I do so I get the following error message: /usr/lib/node_modules/truffle/node_modules/solidity-...