Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
1
vote
0answers
33 views

Help hacking this contract

This is a very simple contract that I can't hack and I'm stuck, I need some help to get the concepts right. pragma solidity ^0.4.10; contract SimpleToken { mapping(address => uint) public ...
1
vote
2answers
37 views

What are contract Variables and how are they different from normal varables declaration

pragma solidity ^0.4.2; import DappToken; contract DappTokenSale { address admin; DappToken public tokenContract; function DappTokeSale(DappToken _tokenContract) public { ...
0
votes
0answers
11 views

sender account not recognized error when using “WrestlingInstance.registerAsAnOpponent({from: account1}) ”

I'm following the ethereum walkthrough at: https://hackernoon.com/ethereum-development-walkthrough-part-2-truffle-ganache-geth-and-mist-8d6320e12269 I got stuck at account0 = web3.eth.accounts[0]. ...
0
votes
1answer
241 views

Error: The contract code couldn't be stored, please check your gas amount during deploy

I know this issue was discussed before several times, but I cant get the solution to my problem. I'm trying to deploy a contract with Truffle on Ganache. During the deployment in 2_deploy_contracts....
0
votes
0answers
29 views

send().catch() doesn't give me the error message anymore

I'm using Truffle/Drizzle/MetaMask and calling methods with send() and using .then() and .catch() and I rely on getting the error message send to .catch() e.g. contract.methods['hello'](arg).send({ ...
0
votes
2answers
599 views

Deploying on Rinkeby with Truffle using infura

If I want to use HDWalletProvider to deploy my contract on a specific address, what should I do? rinkeby: { provider: () => { return new HDWalletProvider("Mnemnoic", "https://ropsten.infura....
2
votes
1answer
165 views

call graphs for solidity smart contracts

Do we have some open source tools where we can get call graphs for solidity smart contracts execution ? For ex: Suppose Function A in contract C calls some other function B so the graph should contain ...
0
votes
1answer
242 views

How to deploy smart contract to main ethereum network

I am tring to deploy our ERC20 token in main net it gives an error Error: exceeds block gas limit. First I download or sync whole blockchain using geth command ( geth --syncmode "fast" --rpc --rpcapi ...
1
vote
2answers
691 views

Truffle migrate no error but does not create build directory

I'm trying to develop a simple dapp using ReactJS.I used Charterhouse/truffle-create-react-app box suggested by truffle website. The problem is truffle compile and truffle migrate do not seem to work. ...
1
vote
1answer
153 views

Link library inside contract creation

I have a contract like this pragma solidity ^0.4.24; import './MyLibrary.sol'; contract A { // Do Stuff } And I have a factory contract instanciating A contracts pragma solidity ^0.4.24; ...
4
votes
2answers
910 views

Truffle does nothing and shows no output when running tests

I am switching machines and ran into a weird issue with truffle. Truffle is set up properly on my old machine. I can compile and run tests without any issues. To my knowledge, I set up everything ...
1
vote
4answers
51 views

Issue deploying this contract

This is a contract im trying to deploy and i think its an abstract contract as most of the functions dont seem to be implemented... anyway the issue im facing is that truffle is telling me i cant ...
0
votes
1answer
153 views

MetaMask - RPC Error: Internal JSON-RPC error

I am getting this error when i trying to use metamask on my local for a simple transaction from one account(say A) to another (say B). code: -32603 data: {originalError: {…}} message: "Internal ...
1
vote
2answers
966 views

unable to uninstall truffle

I am unable to uninstall truffle using this command npm uninstall -g truffle Current ver is 4.1.5 , I want to uninstall and reinstall v4.1.4 as code seems to be breaking while compiling and v4.1.4 ...
0
votes
1answer
415 views

Accessing Web3 in trufflebox's react-auth-box

Hi I am using trufflebox boilerplate react-auth-box. Created a new component called Foo where I am trying to access the web3 object that has been mapped from Store to this.props. However the console....
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 ...
0
votes
2answers
398 views

How to detect what instruction caused “truffle test” to result in “invalid opcode” error?

I wrote a test for my contract and it returns invalid opcode as a result. Full output: 1) Contract: FPCoin1 One can purchase tokens for ether: Error: VM Exception while processing transaction: ...
4
votes
1answer
325 views

Truffle test fails to call the base function, wants the override

I have an extended ERC20 contract with ERC827 functions, which are overrides of ERC20 with an extra callback parameter. I have these two pairs of base/override functions: Base: function ...
0
votes
0answers
21 views

Contract deployed successfully on localhost and mainnet, but gives error on rinkeby and ropsten

I tried to deploy a contract to rinkeby then on ropsten, but getting an error: Network ropsten-fork Minting initial supply of 5000000000 ... Error: Error: Error: invalid address (arg="_to", coderType=...
1
vote
2answers
279 views

Transaction exited with an error (status 0) after consuming all gas

I developed some smart contracts to be deployed to a private PoA (Proof of Authority) blockchain. I spun up a private blockchain via truffle develop and got the following receipt: Compiling your ...
2
votes
2answers
885 views

Truffle cannot find Ethereum client when running tests

By default this is the content of the file truffle.js: module.exports = { // See <http://truffleframework.com/docs/advanced/configuration> // to customize your Truffle configuration! }; ...
0
votes
1answer
33 views

Truffle Exec Return Events

I have set up a JavaScript file that takes in my contract and executes the various functions and then returns the correct events. The file runs through 'truffle exec'. I am using the following line ...
1
vote
1answer
589 views

Invalid number of arguments error for getter function with no passed arguments

I am receiving this error when trying to call the getUsers getter function from the contract below: Invalid number of arguments to Solidity function. Running on Truffle in develop mode. mapping (...
1
vote
1answer
49 views

Could not find __Truffle__NotFound.sol from any sources

This is the file I'm trying to compile. I've been using truffle for a few years and I remember that we used to be able to compile files with different names than the contracts inside. I'm using ...
0
votes
1answer
309 views

Passing command-line arguments to 'truffle test'

I have a JS script which I pass to truffle test from command line: truffle test my_script.js I would like this script to take an input argument (retrieved via process.argv[2]). Does `truffle ...
2
votes
3answers
544 views

writing tests in solidity for functions returning multiple values

I have a function that returns multiple values function getInfo(string id) returns(string x,string y){ bytes32 _id= strToBytes(id); return (infostruct[_id].x,infostruct[_id].y) ; } Now i want ...
0
votes
0answers
56 views

Unhandled Rejection (TypeError): Election.methods.addCandidate is not a function

//solidity code function addCandidate(string memory _name) public { candidatesCount++; candidates[candidatesCount] = Candidate(candidatesCount, _name, 0); } //App....
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 { ...
0
votes
2answers
651 views

How to test contract with multiple accounts / addresses in truffle?

I want to test my truffle contract with multiple msg.sender addresses. Like "the first user sell token, the second user buys this token". For one address I simply write something like contract.buy....
0
votes
2answers
299 views

Default getter and setter for mapping in solidity

In my smart contract I've public mapping as mapping (uint=>User) public users where User is a Struct, so is there any way to get the values of this mapping using default getter. For Example : If ...
12
votes
4answers
2k views

What is the real price of deploying a contract on the Mainnet?

I'm trying to deploy a contract on the mainnet, but I've been getting some issues deploying with Truffle. ➜ ballot git:(master) ✗ truffle migrate --network mainnet --dry-run Using network 'mainnet' (...
0
votes
1answer
433 views

Truffle compiling error

I having the error below when I tried compile the contract. Should I downgrade the truffle version? If yes, which version because I couldn't find the appropriate version for sol 0.4.18. Thanks ...
0
votes
1answer
24 views

truffle won't run tests while initializing a global contract instance

I am testing my smart contract in truffle. I need to declare some global variables hence I did so outside 'it'. I also tried declaring a global contract instance that I can use in all test cases. ...
0
votes
0answers
34 views

gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1

I used the command truffle unbox react to build a dapp. It is just the initial step of my dapp development. However, it sucks. It continually pops up gyp ERR! build error gyp ERR! stack Error: `C:\...
0
votes
1answer
662 views

Out of gas on truffle test

I am following the tutorial on http://truffleframework.com/tutorials/pet-shop I am using Ganache for testing, where i am also deploying the tutorial contract. 1) TestAdoption "before all" hook: ...
1
vote
1answer
542 views

Problem with truffle console : Cannot read property 'call' of undefined

I have a problem when executing the code HelloWorld.deployed().balance.call().then(console.log) This error introduced: Cannot read property 'call' of undefined This problem is similar to this ...
0
votes
0answers
27 views

not able to assign address to a public property using web3

while everything is working fine when working on remix ide but on truffle its not updaing value of a property (player2) i am also returning that address value and its returning as it should be. but ...
0
votes
1answer
36 views

truffle deploy --network ropsten issues

I am having an issue deploying to ropsten. I am receiving an insufficient funds error but I believe my address to have ether on ropsten. This command: truffle migrations --network ropsten Also ...
0
votes
1answer
390 views

Empty/null address handling in truffle pet shop tutorial

I am trying out the Truffle Pet Shop tutorial and it seems to be working all well except for a small issue. My solidity function getAdopters() returns an address[16] function getAdopters() public ...
0
votes
0answers
19 views

Error based on inheritance and dependency between contracts (Using EternalStorage contract)

I have been using EternalStorage contract with my contracts for the storage purpose. Now the structure is some like this: Eternal Storage <- Contract (A) <- Contract (B) <- Contract (C) Now ...
0
votes
1answer
40 views

web3 - web3.utils.toHex zeros length

I'm trying to send 12 integer as bytes to a contract function. If I use web3.utils.toHex(12) the variable will become 0xc The problem is that when contract function parses bytes, it reads uint256, ...
8
votes
3answers
6k views

Difference between Ganache and Truffle

What is the difference between this two? I understand that Ganache is like a fake blockchain, but Truffle has that too ? What are the limitations of each and under which circumstance we use either ...
0
votes
1answer
65 views

I have written a javascript code for compiling the solidity code but it's showing error

I was trying to compile my contract using solc compiler but it returning me some errors. I will place my solidity code along with the error that I am getting here. Please help me out to sort this ...
0
votes
1answer
331 views

Truffle testrpc - public variable getter method error

I'm running into a weird issue where I couldn't retrieve the value of a public variable in truffle console. It's a public variable used as a counter to track the number of records added. I spent ...
0
votes
1answer
353 views

Error: Invalid address

I keep encountering an error saying invalid address. Why is this? const Web3 = require('web3'); const contract = require('truffle-contract'); const MyContract = require('../build/contracts/...
1
vote
1answer
472 views

Latest Zeppelin SampleCrowdsale.sol token moved outside of contract?

Really new to Solidity, but I was following this guide: https://blog.zeppelin.solutions/how-to-create-token-and-initial-coin-offering-contracts-using-truffle-openzeppelin-1b7a5dae99b6 Only, I used ...
3
votes
2answers
1k views

Invalid address error

I keep getting Error: Invalid address when trying to run the application. My current setup of web3 using infura node is if (typeof web3 !== 'undefined') { web3 = new Web3(web3.currentProvider); } ...
0
votes
2answers
29 views

Truffle migration script does not make transaction

Please look at my simple example below. Is migration script 3 being executed, such that it sets the value on the blockchain -- I think not, because there is no speak about a txHash or cost... How to ...
1
vote
1answer
1k views

Javascript web3 calls Solidity contract function with extra parameter?

In the http://truffleframework.com/tutorials/pet-shop example, there is the following contract, and the function adopt(uint petId) has only one parameter. contract Adoption { address[16] public ...
1
vote
2answers
35 views

Contract.deployed() does not work as expected

I use Truffle to test a contract. When i use Contract.deployed() and i fetch address, for example : In a first test, the contract's address is 0x07D899846146b3503dE9D9Dc36B94C2e428eA434 In a second ...