Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
9
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
9
votes
2answers
3k 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+...
9
votes
1answer
2k 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 ...
9
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 ...
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
5answers
1k 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
3answers
8k 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
2answers
923 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 ...
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
3k 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
708 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
594 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
5answers
10k 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 ...
8
votes
6answers
4k 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
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
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
3answers
2k views

How to use bignumbers in truffle tests?

I am testing a smartcontract with Truffle V5. All works well if I do not use all decimals. If I set 18 decimals all explodes. The test code is this (from truffle docs): const MetaCoin = artifacts....
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
902 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
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 = ...
8
votes
1answer
5k 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
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 ...
8
votes
1answer
736 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
634 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 ...
8
votes
0answers
463 views

Running a geth light client, how do I resolve the error: “No trusted canonical hash trie”?

I've been running a geth light client to deploy smart contracts through Truffle Migrations to mainnet. I'm getting: "Error: No trusted canonical hash trie". Any help in what this entails and how to ...
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
4k 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
1answer
6k 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,...
7
votes
3answers
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 ...
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
7k views

The reason for “Could not find artifacts for” in truffle?

Any ideas about the reason for the following error from truffle? The contract is from the solidity docs. Truffle.js - //var Set = artifacts.require("./Set"); var Consumer = artifacts.require("./...
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
4answers
5k 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, ...
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
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
9k 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
9k 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
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
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

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
2answers
181 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 ...
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
3answers
540 views

difference between “deploy” and “new”?

So I'm using truffle and I notice that I seem to be able to deploy a contract's bytecode by calling deployer.deploy(MyContract); But I've also seen people run: myContract = await MyContract.new();...
7
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 ...
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
1k 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 ...

1
2
3 4 5
44