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
279 views

truffle deploy: Network state unknown when geth is synced

eth.syncing false eth.blockNumber 5199029 truffle deploy --network=live Running migration: 1_initial_migration.js Deploying Migrations... ... undefined Error encountered, bailing. Network state ...
1
vote
3answers
380 views

Choosing between Javascript and Solidity for testing smart contracts

Truffle offers two ways to test smart contracts: either using test files written as Solidity contracts, or Javascript/Mocha. https://truffleframework.com/docs/truffle/testing/writing-tests-in-...
1
vote
2answers
1k views

How does Truffle know the address of contracts published via truffle migrate?

In Truffle's documentation, it says DeployedAddresses.sol is how Truffle identifies and stores the addresses of contracts published to the blockchain via truffle migrate. How does this file work, and ...
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 ...
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
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 ...
3
votes
1answer
790 views

Inheritance of constructor [duplicate]

Why does warning appear with inheritance of constructor? contract MyToken is ERC721Token{ function MyToken(string _name, string _symbol) ERC721Token(_name, _symbol) public { } The content of the ...
2
votes
0answers
108 views

Minimal contract testing setup using truffle

This question is a follow up onto this one. I have tried following the suggestion in the answer of adding a done() method that fires when an error occurs (an exception is raised) but it doesn't when I ...
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
1answer
1k views

Truffle contract deployment either exceeds block gas limit or out of gas

I've been having the same issue when I was trying to deploy a contract using truffle develop console. The contract is not extremely big but does initiate two other contracts when called a certain ...
1
vote
4answers
1k views

Error: exceeds block gas limit

geth comand geth --rpc --rpcapi db,eth,net,web3,personal Truffle.js module.exports = { networks: { development: { host: "localhost", port: 8545, network_id: "*" // Match any network id }, live: { ...
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 =&...
1
vote
2answers
848 views

How to call my contract's function using sendRawTransaction?

I am trying to call my contract's method using sendRawTransaction. I have a function in my contract updateReading(address consumerAddress, uint32 consumerMeterId, uint64 ...
1
vote
4answers
1k views

Module not found: Can't resolve './contracts/SimpleStorage.json'

I am new to solidity, truffle and i tried react-box from Truffle and i get the following error. I am using Macos. Here is the basic steps npm install -g truffle truffle develop compile ...
0
votes
1answer
98 views

TypeError: tokenInstance.balanceOf is not a function

It happen when use truffle test, here my contract file: pragma solidity ^0.5.0; import "./DappToken.sol"; contract DappTokenSale { address payable admin; DappToken public tokenContract; ...
0
votes
2answers
110 views

Can I automate the truffle (smart contracts) test scripts?

As we all aware about smart contract testing using truffle framework. Currently, we are writing the test scripts either in solidity or in java-script manually. Is there any way so that I can auto ...
0
votes
1answer
621 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 ...
19
votes
6answers
10k views

truffle has not been deployed to detected network

Is it possible to referer to a contract that has been deployed with Contract.new() with Contract.deployed() ? When referencing .deployed() in my test it throws : has not been deployed to detected ...
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 ?:...
26
votes
10answers
10k views

How can you handle an expected throw in a contract test using truffle and ethereum-testRPC?

Is it possible to write a test using truffle that attempts to confirm that a throw occurs in a contract? For example, if I had a contract with function... contract TestContract { function testThrow(...
21
votes
6answers
13k views

Truffle deployment on test network says: Error: exceeds block gas limit

I'm trying to deploy a sample contract (following this guide) but I'm receiving an error of not enough gas. I changed the numbers a little but could not fix it. I saw this question in stack exchange ...
21
votes
5answers
6k views

Truffle configuration file name - is it 'truffle.js' or 'truffle-config.js'?

Truffle configuration file is mentioned in several places on the web (GitHub, truffle package on npm, solidity-coverage package on npm, etc.). Some refer to it as 'truffle.js, others refer to it as ...
11
votes
3answers
2k views

How to set the timeout for truffle test's before block?

I'm running my tests on a private chain and some of them times out: 1) "before all" hook: Error: Timeout of 2000ms exceeded. For async tests and hooks, ensure "done()" is called; if returning ...
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 ...
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
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
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 ...
5
votes
1answer
367 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
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
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
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("...
4
votes
1answer
479 views

Should I use new() or deployed() in Truffle unit tests?

What's the difference in using new() or deployed() when creating a contract instance to use in Truffle unit tests? Should I use // VERSION A it("should work", async () => { let instance = await ...
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 ...
2
votes
1answer
842 views

Questions about interacting with contracts using truffle

I have a simple Escrow contract that I've deployed using testrpc. I'm not sure how to interact with the methods once I've created an initialized a new one. Here's the contract: pragma solidity ^0.4....
19
votes
1answer
4k views

What is truffle?

What is the truffle framework? Who can use it, who should use it? And what are the benefits?
17
votes
4answers
10k views

'Error: base fee exceeds gas limit' When creating new contract instance (Using Truffle, Web3Js and testrpc)

I have the following code in app.js file of my truffle project. import { default as Web3} from 'web3'; import { default as contract } from 'truffle-contract' import conferrence_artifacts from '../../...
11
votes
5answers
904 views

what is a standard .gitignore for truffle?

I'm using the latest Truffle. Very nice, after having to roll my own dev environment in early 2016! But there is no obvious documentation as to what parts of the project need to be checked into Github....
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
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 ...
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
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 =&...
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
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: ...
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 ...
4
votes
4answers
460 views

Truffle Drizzle-box fails with TypeError: (0 , _drizzle.generateContractsInitialState) is not a function

Right after unboxing Drizzle-box I'm getting a TypeError: (0 , _drizzle.generateContractsInitialState) is not a function. Ganache is running on localhost:8545, contracts are deployed, Metamask ...
4
votes
1answer
557 views

Truffle: How to detect test environment while running smart contract test cases?

I'm trying to run some test cases in Travis CI using truffle but I want some of them not to run if the test environment(localhost:8545) is running via "testrpc" because some of my test cases only ...
4
votes
2answers
4k views

How to send ether to a contract in truffle test?

For some reason I cant figure out how to send ether to a contract when testing in truffle. This is my attempt: await myContract.send(10, {from: accounts[0]}); the error message is: Error: VM ...
3
votes
1answer
5k views

Account is locked, after running Truffle migrate command [duplicate]

I am new to this technology and I am trying to Deploy the contract to Ropsten test network. I have my geth running in one terminal. In my truffle console I have an account with some ether. I unlock it,...
3
votes
1answer
4k views

Web3 - Uncaught TypeError: contract.abi.filter is not a function

I have compiled and deployed a simple Hello World contract using truffle: pragma solidity ^0.4.4; contract Greeter { function Greeter() { } function sayHello() returns(string) { ...
1
vote
1answer
1k views

Contracts will not compile using truffle with the “emit” keyword included in front of events [duplicate]

I notice there has been changes made to solidity and that the word emit is now to be used in front of event triggers (to distinguish from functions being called). However when I include these in ...