Questions tagged [truffle]

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

1
vote
1answer
716 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 ...
7
votes
2answers
12k views

How do Enums work?

I am just starting out with Solidity and JavaScript and am trying to understand Enums. I have a simple contract pragma solidity ^0.4.4; contract SimpleEnum { enum SomeData {Channel} SomeData ...
0
votes
0answers
26 views

Geth - blockchain remains on genesis block, miner node doesn't mine

When attempting setup a local private PoW blockchain, an issue is arising where instead of mining new blocks, Geth instead hangs on the first attempt to 'commit new mining work'. Between the two geth ...
1
vote
1answer
465 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); } ...
1
vote
0answers
121 views

Using web3py with truffle framework

Can we use web3.py with Truffle framework ? If yes, please share such integration examples
1
vote
1answer
20 views

Notation in npm solidity-coverage tests

I had been using the npm package solidity-coverage and while reading the coverage reports I came up with this E symbol. I am not sure what it means and there is no explanation in the documentation as ...
0
votes
1answer
327 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/...
4
votes
0answers
610 views

Truffle migrate Error Invalid number of arguments to Solidity function

Truffle 4.0.1 I've got a contract declared "is Pausable" (OpenZeppelin framework) and I want to pause it as part of the deployment logic. I'm getting an error, however, when invoking pause() Error: ...
19
votes
3answers
3k views

how to catch “revert” error in truffle test javascript?

How can I catch "revert" error in truffle test written in javascript? Error: VM Exception while processing transaction: revert Here is part of test contract, function doRevert() public { ...
6
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 ...
1
vote
1answer
21 views

During gas-free transaction get an error “No relay responded! 4 attempted, 4 pinged”

I did all modification related to this instruction https://github.com/tabookey/tabookey-gasless However, when I'm trying to write some tests it fails and provides me the following error Error:...
0
votes
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 ...
0
votes
0answers
100 views

unable to deploy contract on rinkeby network

I am trying to deploy my contract to rinkeby test network but unable to do so here is my contract code. pragma solidity ^0.4.17; contract Inbox { string public message; function Inbox(string ...
1
vote
1answer
21 views

How to pass account address to truffle deployer?

How do I pass my account address to the contract constructor while deploying with truffle migration? I want to pass address into MyAdress like below. deployer.deploy(MyContract, MyAddress) My ...
0
votes
2answers
73 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
2answers
393 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: ...
0
votes
1answer
27 views

I keep getting the error: “Uncaught (in promise) Error: Invalid number of arguments to Solidity function”

I have tested it in remix and the function does work, I also removed inputs just for testing purposes but it seems that it doesn't work anyway. Here is the function: struct Message{ string ...
0
votes
0answers
41 views

How to call A child Contract function in web3js?

Hey I am new at blockchain development and I need to make contract name organization that create sessions contracts. I had already implemented the solidity code but I have a problem in front-end ...
1
vote
1answer
92 views

My Solidity files are not compiling and I am getting constant error

I'm new to blockchain and I'm following a tutorial. However, I'm getting problem compiling my first contract on Truffle. Here's my code : pragma solidity ^ 0.5.2; contract ApprovalContract { ...
6
votes
1answer
516 views

How to sequence steps in a truffle test?

I'm trying to test contract which rely on a particular state of other deployed contract. For example let say i have a contract wanting to test the "transfer" function of an ERC20 contract. I should ...
2
votes
1answer
305 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
0answers
33 views

How do I set constant state variables in source code before migrating to a test network?

Is there a way to change the value of address literals in solidity source code before migrating to a local test chain using Truffle? Currently, if a contract A needs to know the address of another ...
1
vote
1answer
287 views

Truffle “TypeError: Cannot read property 'legacyAST' of undefined”

I had just finished editing what seems like the last of my error in my contracts because truffle will get to the last contract I have to compile, hangs for a second and the does this: Compiling ./...
2
votes
2answers
508 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
15 views

Supporting multiple HDwallets with truffle/drizzle

I have a dapp using truffle/ drizzle that implements regular user auth format (Login, id, tokn, etc). If I wanted to support each user having access to their own hd wallet, how would I do that with ...
0
votes
1answer
81 views

Dapp on Ganache and Truffle but… what about Remix?

My dapp runs well with Ganache and Truffle but how to deploy with Remix and connect the contract to web GUI without abi? I mean, i created a Dapp that runs really good on Ganache and i run the web ...
2
votes
1answer
16 views

Truffle: provide a different config file name via the CLI?

I've read through the Truffle docs on configuration, but I haven't found the option of providing a different file name other than truffle-config.js or truffle.js. In my case, I need multiple files ...
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 != ...
2
votes
1answer
20 views

Truffle: how to override compiler settings via the CLI?

This is a highly specific bottleneck encountered when using Truffle. In my normal truffle-config.js file, I have the optimizer enabled. I run a CI pipeline which has a coverage job. I use 0x/sol-...
0
votes
2answers
316 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: ...
1
vote
1answer
45 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 ...
0
votes
2answers
235 views

Retrieve specific account in truffle 5 console

I am following a truffle tutorial where the individual users web3.eth.accounts to retrieve all the accounts from Ganash. However that seemed depreciated and to duplicate his results I used web3.eth....
1
vote
1answer
814 views

Can't connect to local rinkeby node from web3.js

I'm developing a Dapp using truffle and I need to connect to a contract that I uploaded on rinkeby using truffle migrate --network rinkeby. Problem is that I'm unable to connect to the rinkeby network ...
0
votes
0answers
33 views

why .call() in Truffle did not return results as expected?

I'm deploying a contract to my private chain and try to call the contract's function. After I got in the geth console and finished deploy contract, I called the function but it doesn't work ...
0
votes
1answer
497 views

Deploy to mainnet with Truffle + Infura: nonce too low [duplicate]

I'm trying to deploy a very simply ERC20 token contract using Truffle and Infura and getting this: Running migration: 1_initial_migration.js Deploying Migrations... ... ...
6
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
1answer
28 views

tokenInstance.balanceOf is not a function [duplicate]

It happen when use truffle test, and here my DappTokenSale file: var DappToken = artifacts.require('./DappToken.sol'); var DappTokenSale = artifacts.require('./DappTokenSale.sol'); contract('...
3
votes
1answer
461 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
32 views

ReferenceError: admin is not defined

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; ...
1
vote
0answers
184 views

Error: Returned values aren't valid, did it run Out of Gas?

I got this problem when follow the instruction, here my two contract: 1) token sale contract: pragma solidity ^0.5.0; import "./DappToken.sol"; contract DappTokenSale { address payable admin;...
0
votes
1answer
388 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: { "...
0
votes
2answers
51 views

(Truffle) how to call finalize() function after finishing crowdsale

I would like to call token.transferOwnership(msg.sender) after finishing timed crowdsale. So, I inherited FinalizableCrowdsale contract, then override finalization() function to call transferOwnership ...
0
votes
1answer
36 views

Operator == not compatible with type unit256 and address // TypeError: Invalid type for argument in function call

I got 2 problem when i follow instruction. Here my contract file: pragma solidity ^0.5.0; import "./DappToken.sol"; contract DappTokenSale { address admin; DappToken public tokenContract; ...
1
vote
1answer
33 views

Struct member access in web3 requires additional dummy field

If a struct contains a single field, then that field is inaccessible from web3. In the below example, field uint b must also be present in order to access field uint c from web3. Of course, it's not ...
0
votes
1answer
859 views

Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: VM Exception while processing transaction: revert

Googled around and nothing could solve this error. truffle migrate --network development Using network 'development'. Running migration: 2_deploy_contracts.js 1520374082 1522102082 1000 '...
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 ...
7
votes
4answers
776 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 ...
2
votes
1answer
471 views

Truffle Bytecode Different from Etherscan Bytecode

I am having difficulty verifying my contract code on Etherscan using the code generated by Truffle. Using Etherscan VerifyContract V1: https://rinkeby.etherscan.io/verifyContract Truffle produced ...
0
votes
1answer
532 views

How to deploy a contract to parity using truffle?

I get this when trying to deploy to parity - Writing artifacts to ./build/contracts Invalid JSON RPC response: "Provided Host header is not whitelisted.\n" I am new to using truffle with ...