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
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 ...
0
votes
1answer
387 views

Testing contract interactions with Truffle

I have 2 contracts, User and Registry, interacting and I want to test their interactions with Truffle. Currently my test(s) for User are contract('User', function(accounts) { // many tests here ...
9
votes
5answers
809 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 ...
8
votes
2answers
725 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 ...
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
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
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 ...
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 ...
7
votes
4answers
875 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 ...
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 ...
6
votes
4answers
2k views

How to use Truffle with Solidity 0.4

I just tried to set up a truffle project and tried to compile a contract I have already written. When I do so I get the following error message: /usr/lib/node_modules/truffle/node_modules/solidity-...
6
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 ...
6
votes
1answer
3k views

How to set a sender address when deploying a contract with Truffle?

I don't seem to find the answer to what looks like a really basic question. How does one specify a sender address when deploying a new contract using Truffle ? My contract is owned. So most of my ...
5
votes
2answers
3k views

Constructor initializing another contract

I have a contract which is creating an instance of another contract. I am confused about deploying the contracts in Truffle. Does the constructor get initialized when deployed?
5
votes
1answer
1k views

function.call() behaves differently to function() in truffle test

I'm using Truffle 4.0.1 and Node 9.2.1 In my solidity smart contract I have a function function finalize() public onlyOwner { require(!isFinalized); finalization(); // does some stuff ...
5
votes
2answers
5k views

passing String object with “0x..” value as bytes32 to a solidity function

I'm having trouble to pass bytes32 to a solidity function from javascript. It's converting to an incorrect bytes32 in solidity. The javascript is a test, running with truffle v3.3.1 on testRPC v3.0.5....
5
votes
1answer
432 views

Best practice for sharing truffle build files between developers

I am working on a few projects using truffle, as you know truffle compiles and migrates contracts to various ethereum networks e.g. MyContract.sol produces MyContract.json which contains a reference ...
5
votes
2answers
3k views

Deploying contracts in Ropsten with Truffle

I have another n00b question... sorry about that :( I'm trying to deploy a smart contract to Ropsten. I have synched the Ropsten network with geth --testnet --fast --rpc --rpcapi eth,net,web3,...
4
votes
1answer
270 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", &...
4
votes
1answer
940 views

Sign data with private key inside a truffle test file

I've got a contract method that checks the signer of a message using the solidity ecrecover function. In my truffle test file I now want to check if this is done correctly. Therefore I need to sign a ...
4
votes
1answer
2k views

Manually set web3 version in truffle?

The version of web3 in Truffle v4.0.5 is v0.20.3. Is it possible to manually upgrade the web3 version? Similar to this question about web3 in geth. (It's hardcoded.) Somewhat relevant to this issue.
4
votes
1answer
522 views

How do you provide a GasPrice and GasLimit to overcome the “low tx nonce or out of funds” log message

I am getting the following logged by my private chain geth node when running a test in truffle: removed tx ( TX(ff8ec4f713e64fb25df07d153607e29629c9276b57e0b7e331f17b5a3c31fdd1) Contract: ...
4
votes
1answer
344 views

Truffle Migrations contract constructor argument

I'm reading the Truffle Migrations contract and looking at the code for upgrade(): function upgrade(address new_address) public restricted { Migrations upgraded = Migrations(new_address); // * ...
4
votes
1answer
3k views

Deploying abstract contracts and interfaces

I am trying to create a basic inheritance hierarchy with abstract/virtual formalisms. Consider the following two contracts: Abstract Contract (IUser.sol): contract IUser { function addUser (...
3
votes
1answer
2k views

Truffle error: Cannot read property 'call' of undefined [duplicate]

I am trying to run the following contract in truffle, which is pretty much the same HelloWorld but I kept the name MetaCoin from the truffle example. I have read this, this, and this posts related to ...
3
votes
1answer
276 views

Truffle Dapp Communication

In truffle, a dapp is deployed using the port of running geth node (in testnet). Then how will another machine node will communicate to that dapp because it is impossible to run a node on same port ...
3
votes
2answers
1k views

Truffle on Windows 10: how to unlock an account for migration to a private network

I try to migrate a smart contract to a private network via truffle on Windows 10. I specify a certain account in truffle.js and so far I get the following error: Error encountered, bailing. Network ...
3
votes
1answer
319 views

Can I truffle migrate with geth --light?

I get invalid address when I try to, I suspect --light doesn't enable deploys -- is that so?
3
votes
0answers
301 views

Upgrading the truffle Migrations contract

In the standard truffle migrations contract the purpose of the upgrade function is upgrade the Migrations contract itself by copying the last_completed_migration of the old Migrations contract to the ...
3
votes
1answer
1k views

Transaction gas cost in truffle test case

Below is from a truffle test cases in javascript, where I was trying to add the gas cost to an account balance to confirm the sum of transaction, where the sum should be equal to the previous balance. ...
3
votes
1answer
205 views

truffle-hdWallet-provider not return correact address when using private key

I want to access MyEtherWallet account address from truffle-hdwallet-provider. This is the code. ``` var HDWalletProvider = require("truffle-hdwallet-provider"); var privateKey = process.env.KEY; ...
3
votes
1answer
2k views

Truffle Smart Contract Testing does not reset state

I have the following javascript test for a simple ERC 20 token. Which on the call return token.balanceOf.call(accounts[2]); will fetch some old data and fail from a previous test transaction writting ...
2
votes
2answers
654 views

Truffle - How to get event?

I can't figure out how can I get event. I was trying with "contract.NewVoting().watch{}" but it says that watch is not a function. I found out that watch has been removed and there is EventEmitter ...
2
votes
1answer
557 views

Solidity Truffle React TestRPC: Invalid address error while creating transactions through React app

I am writing a simple contract which is basically a registry. I am using testRPC for my ethereum testing. Following is my contract on Truffle: notary.sol pragma solidity ^0.4.11; contract notary { ...
2
votes
3answers
1k views

Truffle post-deployment actions

I have 2 contracts that deployed with truffle. Now I extended it and my contracts require some bootstrap actions like "set some address" or "set in contract1 address of contract2". I will not change ...
2
votes
1answer
68 views

Oraclize a restfullAPI using a specific number represented by the variable z

Hello I made a restfull API on my own (python file jsonify + localtunnel) on a localhost using a specific number (in this case 141) represented by the variable z. This variable should go into DevCoin ...
2
votes
2answers
1k views

smart contract address checksum

I am going through ethereum blockchain demo's and currently trying to call other contract deployed already on a local ethereum rpc in memory blockchain. Using truffle and ethereum rpc i am testing ...
2
votes
1answer
111 views

VM Exception while processing transaction: revert message

When a solidity smart contract reverts with a message due to a failure on a require statement, the browser calling the smart contract returns "Error: VM Exception while processing transaction: revert"....
1
vote
2answers
277 views

How to host a blockchain application?

I have started working in blockchain for the last few weeks. I have created a private blockchain in my system using geth and added peers by using admin.addPeer() command. I have also created an ...
1
vote
1answer
2k views

how to parse the value returned by truffle ?

I need the value of string. Also, what is the significance of s , e , c . truffle(development)> x.then(function(result) { console.log(result[4]);});}}); undefined truffle(...
1
vote
1answer
345 views

Can't run truffle migrate if ganache-cli launched with --db option

If I run ganache-cli without options or any options except --db, and then run truffle migrate it will successfully migrate my contracts. BUT If I run ganache-cli --db ./ganachedata, and then run ...
0
votes
2answers
151 views

Intracting with dapp using frontend truffle petbox

App = { web3Provider: null, contracts: {}, account: '0x0', init: function() { // Load pets. return App.initWeb3(); }, initWeb3: function() { if (typeof web3 !== 'undefined') {...
0
votes
1answer
189 views

Not able to see my token on metamask

This is my complete contract code : https://gist.github.com/cmaliwal/31a80d36b8d873a3dca37b2b18188164 When I deployed my contract on ropsten test network using remix and metamask contract deployed ...
8
votes
1answer
4k 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
3answers
857 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. ...
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"; ...
6
votes
3answers
1k views

testrpc, contract creating contract not mined?

I'm trying to develop a contract that creates a contract (factory/worker, faucet pattern). Think my issue may be with the tools I'm using: testrpc (local blockchain) Remix Browser Solidity (connected ...
5
votes
1answer
378 views

Truffle error “Don't set config.from directly”

I have parity running on my mac and I can start it with parity --rpcaddr 0.0.0.0 --rpcport 8547 --port 30305 --rpccorsdomain '*' --rpcapi "eth,net,web3" Once It's all sync'd up I then make a new ...
5
votes
2answers
250 views

Sending ethers with mocha.js and truffle might result in larger sums than intended

Good day, I have a contract General and a library GenLib. library GenLib{ event MoneyIn (address _from, uint256 _amount); function moneyIn() { MoneyIn(msg.sender, msg.value); <- ...
4
votes
2answers
1k views

truffle deploy to geth failing, generating “receipt not found” repeatedly from geth

I've just installed truffle on an ubuntu virtualbox, and it is failing to deploy to a geth dev setup. Geth gives me a never-ending receipt not found for transaction ...