Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
9
votes
5answers
892 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

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 ...
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 ...
9
votes
2answers
2k views

Truffle: Hanging on “Deploying Migrations…”

I am deploying a contract on a private testnet. I am using Parity. When I type: $ truffle migrate --network my-network-name I get a popup in the Parity interface for a password to my account. I ...
9
votes
1answer
669 views

Truffle framework with storage

How can I integrate truffle with swarm or ipfs for permanent document storage? Are there any libraries?
9
votes
1answer
571 views

Filtering on events of the entire blockchain not possible in testrpc via truffle

A contract I wrote has an event in its constructor. Since I want to find it back in the logs it doesn't seem possible to start listening to the latest block. Because the event is already 'fired' ...
8
votes
1answer
10k 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? ...
8
votes
2answers
7k views

How do you get the balance of an account using truffle/ether-pudding?

Is there an ether-pudding way to get the balance of a contract/account, or should I just use web3.eth.getBalance(account)?
8
votes
4answers
3k 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 { ...
8
votes
5answers
3k views

Flatten Truffle Solidity Contracts for Etherscan's `Verify Contract Code` Feature

Etherscan.io has a Verify Contract Code feature that takes the inputs Solidity Contract Code and Constructor Arguments ABI-encoded. Question: Is there a tool to flatten your solidity contracts (...
8
votes
2answers
3k views

truffle migrate Error: “Cannot find module 'truffle-expect'”

I'm following a solidity tutorial right now and I'm currently encountering an error when I run truffle migrate. Also, testrpc is running in another terminal tab, so this issue is unrelated to the ...
8
votes
1answer
3k views

Return Token Contract address on truffle deploy

I am trying to figure out how to return the address of a contract when I deploy it with truffle's deployer.deploy. So the goal is that when I deploy a contract that is a custom token, I want to ...
8
votes
1answer
2k views

How to run a multiline script in truffle console?

I'm following truffle tutorial to interact with a deployed contract and have a naive question. How do I run this block of multiline scripts in truffle(development)> without collapsing it into a ...
8
votes
3answers
861 views

trouble matching gas used in transaction with difference in account balance

I've fired up my testrpc and deployed a simple HelloWorld contract using truffle. I send a simple transaction to my contract and I log my account balance before and after the transaction. ...
8
votes
2answers
768 views

How can I debug a truffle JS unit test with vscode?

I am using visual studio code and truffle and would like to easily debug my JavaScript tests. A similar question has been asked here: how can I run a truffle test in a debugger?. This has been ...
8
votes
1answer
4k views

How to pass arbitrary bytes to a function (2016)

I'm trying to implement a contract which will store bytes blob, a dynamic bytes array. For example I have following struct: Sign { address signer; bytes16 signType; bytes sign; } plus ...
8
votes
1answer
724 views

Migrating solidity program testrpc+truffle - Error: Invalid JSON RPC response: “” at Object.InvalidResponse

I am trying to make a truffle application. truffle compile : working fine making a 'build' folder with .json files in it. truffle migrate : Gives the following error I am running testrpc in ...
8
votes
1answer
596 views

What is the most correct way to test modifiers?

As per the title, which testing method is most correct for modifiers? Something like testing via inheritance and creating a function specifically designed to test modifiers or testing via a framework ...
8
votes
1answer
1k views

sendTransaction results in double send with arbitrary library call

I have a situation I have isolated that seems very bizarre to me and I cannot figure out. I am running truffle v1.0.2 (not latest) and testrpc v2.0.5. When I send ETH from an account to a contract ...
7
votes
5answers
8k 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 ...
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 ...
7
votes
3answers
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 ...
7
votes
4answers
3k views

Truffle Box at URL https://github.com/truffle-box/bare-box.git doesn't exist

I'm trying to initialize a directory with truffle init, but I'm getting the following error: Error: Truffle Box at URL https://github.com/truffle-box/bare-box.git doesn't exist. If you believe this ...
7
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 ...
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... ... ...
7
votes
1answer
3k 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
7
votes
1answer
2k views

How to use the testrpc `evm_increaseTime` parameter from truffle console? [duplicate]

I am creating smart contracts with truffle and testrpc. When writing unit tests I wish to change the block time to simulate different times that smart contracts may be called. How does one set ...
7
votes
1answer
8k views

Truffle gas price and gas limit on demand instead of using fixed amount

I use truffle. When I deploy contracts, sometimes I encounter gas related errors. I always set fixed value of gas price in truffle.js. I want to change it. I think we can use web3.eth.estimateGas and ...
7
votes
3answers
8k views

What is the correct way to access public variable from contract in Truffle: then or standard callback?

There are some similar posts to this but none seem to be able to solve my problem. I have a contract deployed with Truffle running with testrpc. I want to access the value of a public uint variable ...
7
votes
2answers
3k views

Ethers in testrpc

I am new to Ethereum. I have some questions concerning the use of ethers(in stead of MetaCoins) with truffle and testrpc. 1. By default, do the accounts of testrpc contain the currency in ethers? If ...
7
votes
1answer
1k 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....
7
votes
1answer
1k views

Start up ganache-cli ethereum client in travis CI for testing

I'm trying to write a .travis.yml file to test my ethereum contract. In order to test it, I need to start up an instance of the ganache-cli ethereum client by calling ganache-cli -p 7545 and then ...
7
votes
5answers
2k views

Truffle console doesn't work :Unexpected error: Cannot provision contracts while instantiating the console

when I run truffle compile, truffle migrate successfully and then truffle console gives me the following error. strong text **Enexpected error: Cannot provision contracts while instantiating the ...
7
votes
5answers
3k views

Not enough funds for a transaction example in testrpc

I try to test one of my first Smart Contract in Solidity, a simple sub currency example, as you can see below : pragma solidity ^0.4.0; contract Coin { address public owner; mapping (address =&...
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 = ...
7
votes
3answers
2k views

Compile error with trivial assertion in Truffle test

Before I did anything serious I just wanted to check the toolchain is working. I wrote a test like this: pragma solidity ^0.4.2; import "truffle/Assert.sol"; import "truffle/DeployedAddresses.sol"; ...
7
votes
1answer
2k views

Truffle : Call that returns contract is returning tx

Using Truffle v3.2.1 and solidity 0.4.4 I have an issue with a Factory contract (that create some kind of contract), to simplify my factory contract look like this : contract HelloFactory { uint ...
7
votes
4answers
920 views

Truffle: Migrate to ropsten - fails silently

When I run the following command I receive no output whatsoever: truffle migrate --network ropsten This is just after creating a new project using truffle init and creating a single contract. When ...
7
votes
5answers
3k views

Change truffle develop port

When I run truffle develop it starts a testnet listening at localhost:9545. Is there a way to change the port this testnet is running on? EDIT: I'm not looking for a way to configure which network ...
7
votes
2answers
1k views

Which one is suitable frameworks for Dapp development(Truffle, Embark, Dapple)? [duplicate]

Right now we have major Dapp development frameworks. Truffle Framework Embark Dapple What are the pros and cons of each one. On what basis this could be chosen. And what each frameworks needs to ...
7
votes
1answer
519 views

Truffle unbox drizzle not working properly

truffle version = 4.1.4 truffle unbox drizzle truffle compile truffle migrate npm run build npm run start this gets me this error: Truffle Drizzle-box fails with TypeError: (0 , _drizzle....
7
votes
2answers
2k views

Conversion of address to string in Solidity

The Solution given in Convert address to string did not help. Motive: To convert an address to string type so that I can use it as a parameter to a function for which string type is necessary. Code ...
7
votes
1answer
697 views

Problem with start() in web3-provider-engine

While trying to connect to a provider(infura) I get the above error below is the full stack trace: bundle.js:54318 Uncaught TypeError: this.provider.sendAsync is not a function at Web3Subprovider....
6
votes
2answers
7k views

Using Ganache with an existing MetaMask account

I am attempting the Truffle "Ethereum pet-shop tutorial": http://truffleframework.com/tutorials/pet-shop I am in the stage where I am attempting to implement the smart contract on the local Ganache ...
6
votes
1answer
5k views

Truffle and Node JS

The dApp I'm building requires a traditonal backend and as a result I need to use Node.js and MongoDB alongside Truffle. Does anybody know how to set Node to work with Truffle? Thanks!
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....
6
votes
3answers
3k views

Return value of low-level calls not used

I'm attempting to use the function send() in Solidity I've got this error when i try to compile my contract with truffle : Warning: Return value of low-level calls not used. any idea about it? ...
6
votes
1answer
3k views

How does Truffle work without a web3 provider?

I have a question about the init project with Truffle. I can't understand how - in app.js - they use the deployed contract without a web3 provider, like this: var provider = new Web3.providers....