Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
4
votes
1answer
269 views

Truffle hangs forever with parity with PoA

I'm trying to create a private chain using parity (PoA) and truffle but when I do truffle migrate it hangs forever with the following output: > [ > { > "jsonrpc": "2.0", &...
0
votes
1answer
300 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
534 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
1answer
25 views

BigNumber string error when passed as uint256

I get the following error when passing (new BigNumber('2')).exponentiatedBy(100) big number value as uint256 Error: invalid BigNumber string value (arg="value", value="1....
0
votes
0answers
50 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
635 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....
1
vote
1answer
59 views

Issue with Ganche and Truffle with Metamask. Can't load token balance

I'm testing to create a token in Truffle; it compiles fine, but it won't load the balance of the token in to Metamask. I've set the connection correct: it does load the ETH balances of the Ganache ...
0
votes
2answers
257 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
428 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
17 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
22 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
660 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
530 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
26 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
61 views

Using two solc versions within the same truffle project

I am creating an app that has various imports that require two different versions of solidity. AragonOS(0.4.x) and openzeppelin(0.5.x) Of course, there are breaking changes in 0.5.x so my question is ...
0
votes
1answer
33 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
385 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 ...
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 ...
0
votes
0answers
18 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
34 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, ...
7
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
64 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
330 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 ...
2
votes
1answer
39 views

How to trace the line where a tx failed in truffle tests?

I know about 0x's sol-compiler and sol-trace. I used them before and they do exactly what I'm looking for, but these modules bring significant overhead when used with truffle. Check out this file to ...
0
votes
1answer
345 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
470 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
19 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 ...
0
votes
1answer
83 views

Error when testing the contract

ApprovalContract.sol pragma solidity ^0.5.1; contract ApprovalContract{ address public sender; address payable public reciever; address public constant approver=...
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 ...
0
votes
2answers
30 views

truffle migrate fails silently

I'm trying to deploy a truffle project to testnet. When I run truffle migrate --reset --network rinkeby --verbose-rpc, this is output: You can improve web3's peformance when running Node.js versions ...
0
votes
2answers
326 views

how to debugg truffle tests with built in debugger

So I'd like to use the commandline debugger in truffle. To test I simply run truffle test I have an empty truffle.js file. I can get my transaction ID in the javascript tests. When I run: ...
4
votes
1answer
32 views

couldnt understand implementaion of UpgradeabilityProxyFactory

I want to use UpgradeabilityProxy provided by zeppelin, they have one method createProxyAndCall which they say initialize the new implementation with data parameter we provided which looks like: * ...
0
votes
2answers
41 views

I can't migrate the contract using truffle init

I am working to build a Dapp using Ganache, Web3, and Truffle frameworks. I am unable to compile the contracts using truffle compile. I am facing an error. I want to explain you in detail what I did. ...
0
votes
2answers
52 views

Where web3.eth.accounts.create() creates new account?

I am using ganache which creates an ethereum blockchain with 10 accounts. The blockchain created by ganache is linked with truffle's pet-shop box using web3. I want to add a new account in that ...
2
votes
1answer
3k views

Send ether from web3 to fallback payable contract function

I'm trying to send some Ether to the payable function of my contract and I'm unable to find/understand a resource to do so. Here's my attempt below: Web3 App file (simplified, without initialisation ...
2
votes
1answer
307 views

Error: VM Exception while processing transaction: invalid opcode at transfer function

I try test function transfer in my contract. I following by tutorial. Full project locate on my git. It is my test.js code: var SPT = artifacts.require("StepanToken2"); contract("Testing ERC20 ...
0
votes
1answer
124 views

html:82 Uncaught ReferenceError: App is not defined at HTMLButtonElement.onclick (html:82)

It's showing me uncaught reference error in my index.html file <div id="candidate-box"></div> <button class="btn btn-primary" onclick="App.vote()">Vote</button> ...
0
votes
1answer
41 views

Truffle: 'func.call()' retrieves the return-value of a non-constant function

I've just learned that one can easily obtain the return-value of a non-constant function, by using myContract.func.call() (instead of myContract.func(), which retrieves a response object). Up until ...
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 ...
0
votes
0answers
48 views

Error: Truffle is currently using solc 0.5.8,

i run migrate in the terminalbut it shows Error: Truffle is currently using solc 0.5.8, but one or more of your contracts specify "pragma solidity ^0.4.27". Please update your truffle config or ...
0
votes
1answer
1k views

Truffle Error : VM Exception while processing transaction: revert

I am trying to call following function of smart contract from App.js: function addCandidate(bytes32 _name, bytes32 _party) public{ //require(msg.sender == votingAdmin); //if(msg.sender != ...
1
vote
1answer
59 views

Truffle config not matching web3 infos

At truffle.js I set the account to the third ganache's account Then I run truffle console and coinbase was set to the first account and defaultAccount to undefined. Not only that, I've tried to ...
3
votes
1answer
469 views

Deploying on contract on main net - Error: insufficient funds for gas * price + value

Running geth v 1.7.3 truffle 4.0.5 truffle-config.js module.exports = { networks: { development: { host: "localhost", port: 8545, network_id: "*" // Match any network id ...
0
votes
1answer
26 views

I am getting the following wrror while i tried to do node <file name> and also truffle test <file name>

Error: Cannot find module 'web3' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Module....
0
votes
1answer
55 views

Deploy smart contract on Ropsten with Truffle without truffle-hdwallet-provider

Here is my truffle-config.js networks: { ropsten: { network_id: 3, host: '127.0.0.1', port: 8545, gas: 4000000, from: "address_in_metamask" }, I ran a geth node using the command: geth --...
0
votes
1answer
421 views

truffle migrate cause “Error: insufficient funds for gas * price + value truffle migrate”

When I run "truffle migrate" to deploy contract to geth, I got this error: "Error: insufficient funds for gas * price + value truffle migrate". this is the genesis block of my private chain: { "...