The Stack Overflow podcast is back! Listen to an interview with our new CEO.

Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
1
vote
1answer
251 views

Write data to Contract Instance created via Factory

I am trying to run the below app on my private chain using Truffle. I have created an AuctionFactory which would generate new Auction objects for new auctioneers. Auction factory looks like this: ...
1
vote
2answers
856 views

Truffle migrate not updating dependency

I have created a ProductFactory contract which creates instances of another Product contract. Now I change code in the Product contract which is imported into the ProductFactory and run truffle ...
2
votes
1answer
401 views

Understanding Truffle Migration

I'm building my dApp by modifying the pet-shop example, however, I got stuck at the migration step. 1_initial_migration.js runs successfully but 2_deploy_contracts.js gives me the following error ...
0
votes
1answer
220 views

How can i send Ethers from My account to sombody else using Smart contract? from truffle frontend

I am making Dapp in which a user wants to pay or transfer certain number of Ethers to another Account. I am using truffle to build the dapp. In which including other features Users has a frontend to ...
1
vote
0answers
310 views

Truffle (4.0) test multiple contracts

I'm trying to test a contract that wrote and compiled, and I need to use another deployed contract to test it. I am writing a test for a specific contract and trying to invoke another deployed ...
2
votes
3answers
596 views

What's the correct way to reference elements in an array?

I'm going through the Ethereum Pet Shop Truffle tutorial and found this in the test section: address adopter = adoption.adopters(8); A previous section had used adopters[petId] = msg.sender; Why ...
5
votes
1answer
4k views

How to deploy contracts that take parameters in their initialisers using Truffle? [duplicate]

I'm trying to build a smart contract with Truffle. I can compile it just fine, but when I try to deploy it on the network, I don't get an option to pass in the initialiser parameters and thus the ...
1
vote
1answer
357 views

TypeError: Greeter.deployed(…).setGreeting is not a function

I start truffle console and type Greeter.deployed().setGreeting("Hello world!"); I receive the following error: TypeError: Greeter.deployed(...).setGreeting is not a function How can I solve this ...
2
votes
1answer
4k views

Testing contracts with truffle

I'm trying to write tests for contracts using truffle; I have opened an issue here. The workflow is as follows: mkdir truffle_testing truffle init rm -r tests/* contracts/* build/* Next, I create ...
1
vote
2answers
816 views

Using Truffle, Metamask and Ropsten to simulate two users

I'm trying to create an environment where I can test that access to a contract is restricted to a given wallet address, so I'm trying to simulate two users... 1) I'm running geth pointing to Ropsten ...
0
votes
1answer
665 views

Accessing a 3rd party contract's functions using Truffle

I'm trying to build a basic dashboard that will allow me to track the status of any given ICO (assuming the token is ERC20). Right now, I managed to deploy a simple Crowdsale + Coin contract based ...
4
votes
2answers
619 views

Deploy Contract (compiled by Truffle) without using Truffle

A contract SimpleStorage.sol has been compiled by Truffle using truffle compile. Its artifact is found at build/contracts/SimpleStorage.json. However, this contract should only be deployed to the ...
2
votes
2answers
2k views

Truffle: Deploying contract with ether

My contract needs eth to operate, but truffle deploys it with no balance, so I can't execute functions through it. The constructor doesn't require gas, but some other functions do. Is there a way I ...
0
votes
1answer
372 views

Which contract(s) are exceeding block gas limit? (truffle.js)

Similar to this question, I am trying to debug a setup that is exceeding the default gas limit since upgrading to Truffle 4. Turning on the newly disabled (by default) optimizer seems to be a ...
1
vote
0answers
412 views

“Truffle unbox react” Not Working Properly

I am facing problems running the basic official setup of react and truffle. Here's what I did: truffle init truffle unbox react truffle develop truffle(develop)> compile truffle(develop)> ...
5
votes
1answer
1k views

Contract migration error: The contract code couldn't be stored, please check your gas amount

I am trying to deploy my simple ERC20 token with locally installed Truffle, but received this error: truffle migrate --reset Using network 'development'. Running migration: 1_initial_migration.js ...
0
votes
1answer
243 views

Unable to deploy contracts through truffle and local geth

I get the contracts through truffle to post but seems to hang, and getting the following warnings in the local geth. all seems ok, but contract does not Deploy. Version: 1.7.2-stable Git Commit: ...
0
votes
1answer
354 views

Testing contract withdrawal pattern with Truffle

I'm trying to write a test in Truffle to test the following Solidity code: function withdrawFunds() { uint funds = withdrawals[msg.sender]; withdrawals[msg.sender] = 0; msg.sender....
0
votes
1answer
275 views

Casting from msg.sender address to a Contract compiles but causes test failure

I have the following simple contracts: contract HasOwner { address public owner; function HasOwner() public { owner = msg.sender; } } and import './HasOwner'; contract ...
0
votes
1answer
72 views

How Do I Compile a Smart Contract from GitHub?

Our Smart Contract developer has provided our smart contract repo via GitHub The GitHub repo has the following folders: -keys -scripts -src And these files: -.gitignore -Disclaimer.md -LICENSE -README....
3
votes
3answers
1k views

Deploying from Truffle to Infura.io

I'm trying to use the Infura or any other public provider to compile and migrate a simple test contract. I don't get any errors when I run truffle compile --network test but it seems to hang and ...
0
votes
1answer
630 views

web3.js doesn't return all accounts

I'm trying to put together a simple application using Truffle, Metamask and ASP.NET. I've created a bunch of test accounts in Metamask, I then start testrpc explicitly specifying a couple of those ...
0
votes
1answer
437 views

Truffle not returning address [duplicate]

I'm trying to return sender address and value in truffle under private blockchain. When function is called from truffle console I'm not getting proper msg.sender address. Contract code pragma ...
1
vote
1answer
458 views

Getting async/await to work in truffle JS tests

I see many examples are happily using async/await in their JS tests, but it looks like mine doesn't seem to be using ES8? I'm not sure how to check. I installed truffle using "npm install truffle" ...
1
vote
2answers
196 views

Deployed Contract Instance Isn't Detected in Testrpc via MetaMask

When MetaMask tries to access my local testrpc, I'm getting the following error in the browser: contract.js:424 Uncaught (in promise) Error: UnitManager has not been deployed to detected network (...
5
votes
1answer
5k views

truffle migrate: How to deploy a contract whose constructor takes a parameter

I'm using Truffle Version 4 to develop a simple smart contract and am stuck on something I think reflects a very basic misunderstanding that I just can't get my head around. Here's my simple contract,...
0
votes
1answer
905 views

Why does a test that passes in Truffle fail when run against testrpc

Using Truffle and testing against both Truffle's own blockchain and against testrpc yields different results. I am trying to test that my deployed contract is setting its owner correctly (owner being ...
9
votes
3answers
6k 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 ...
4
votes
0answers
504 views

How can I retrieve transaction hashes using web3 batch requests?

When I send a transaction using Truffle's contract wrappers - or using plain web3 sendTransaction() - I get a tx hash back that I can use to confirm the tx has completed. While using batch requests (...
3
votes
1answer
647 views

Having to set reset flag with truffle migrate

I am having a weird issue where my migrations are not being deployed when I run truffle migrate --network development. But when I run truffle migrate --network development --reset, the contracts are ...
0
votes
1answer
2k views

Truffle Console not working, opens truffle.js instead. [duplicate]

Am currently trying to learn Dapps, and trying to initiate Truffle. But, when I use the command "truffle console" in the Git CMD window, rather than opening the console, it opens up the 'truffle.js' ...
1
vote
0answers
124 views

Transaction consumes more gas using MetaMask's injected web3

I have a simple contract: pragma solidity ^0.4.4; contract Counter { uint public count; function Counter() { count = 0; } function inc() { count++; } } And some javascript that ...
2
votes
0answers
326 views

Using Truffle with Ethercamp Ethereum Studio

I'm trying to use the Truffle development environment inside of EtherCamp Ethereum Studio. My main reference is this issue in the Truffle issue tracker. It suggests using eth-lightwallet and hooked-...
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 ...
1
vote
2answers
1k views

Truffle build isn't working

I installed truffle via this command: sudo npm install -g truffle Then I installed testrpc via this command sudo npm install -g ethereumjs-testrpc Then I started testrpc via this command ...
1
vote
1answer
368 views

Invalid Address Error when interacting with a smart contract & Why it works with metacoin

I solved the error accroding to Invalid Address solution PriceContract.web3.eth.defaultAccount=PriceContract.web3.eth.coinbase The contract I run was a very simple set-get variable which I adapted ...
1
vote
1answer
476 views

Correct syntax for contract.method.send() function?

I have a problem understanding the web3 documentation at the readthedocs especially here: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#id12 myContract.methods.myMethod([param1[, param2[...
4
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 ...
0
votes
1answer
422 views

Where truffle save the compiled contract

I'm trying to find where truffle store the compiled code. I'd like to take this bytecode and to deploy it manually with MyEtherWallet
2
votes
1answer
259 views

truffle migrate restarts from first migration after restarting testrpc

I’m trying to create sort of private chain on testrpc so i use testrpc -u 0 -d --db /path/to/db to start testrpc each time. The thing is that if I restart testrpc (kill it and start it again) truffle ...
2
votes
3answers
5k views

How to set default address in truffle?

I made four accounts and lost the passwords to the first three. I am trying to run truffle migrate, but I am worried that truffle is trying to use the first address that I created rather than the ...
0
votes
1answer
392 views

truffle-contract Contract.new() produce an empty contract(no state)

I am making a new copy of a already deployed contract. I am using truffle, truffle-contract to do so. From JS front end var conf = contract(MyContract) conf.setProvider(this.state.web3....
0
votes
1answer
358 views

Events are not getting recognised TypeError: Contract.events.event is not a function

I am trying to get older state of a contract. I have deployed contract using truffle. my contract is pragma solidity ^0.4.15; contract NDA { bytes32 party1name; bytes32 party2name; bytes32 ...
0
votes
1answer
45 views

How can we get the older state of a contract?

What I have I have my private ehtereum chain running on an AWS EC2 instance. I am able to deploy contracts on my private chain. I am able to call functions of smart contract. I am using truffle ...
1
vote
1answer
164 views

Syntax error on official Ethereum ERC20 Code?

I copy and pasted the code found here: https://www.ethereum.org/token into a file called TokenERC20.sol When I run truffle compile I get this error: SyntaxError: Expected "contract", "import", "...
0
votes
0answers
191 views

Why does truffle console not start?

Trying to follow the tutorial on Medium, I would like to open the truffle console (Ubuntu 16.04). I get the following output: mzh@021-voting $ truffle console Error: Invalid JSON RPC response: "" ...
6
votes
1answer
665 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: ...
3
votes
1answer
4k views

How to pass argument/parameter to a payable function of a contract that has been already deployed, via web3 / javascript / truffle?

I'm wondering how to pass argument to a payable function of a contract that has already been deployed, via web3 / javascript / truffle. For instance, I see the following piece of code at: http://...
7
votes
1answer
1k views

Truffle — testing enum values

I am using truffle to develop a simple smart contract. I have the following contract: contract Puppy { enum State { good, bad } State public status; State public constant INITIAL_STATUS = ...
1
vote
0answers
132 views

Truffle: How to test for inheritance

I have a Contract B which should inherit from contract A. Using Truffle, how can I test that this is indeed the case?