Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
2
votes
2answers
484 views

Cannot read property 'getBlock' of undefined

I'm having an issue with running truffle test on a Javascript test. I get the error TypeError: Cannot read property 'getBlock' of undefined. I am trying to get the time of the latest block by using a ...
0
votes
1answer
17 views

TypeError: Cannot read property 'nodes' of undefined

I'm new to ethereum, and I'm trying to test the depositToken function of etherdelta on linux, which version is 0.4.9, and the token I use is vixcore which version is 0.4.24, and I got this error when ...
0
votes
1answer
50 views

Failed to install Truffle on MacOS Mojave

I am currently really struggling in getting Truffle up and running. I am running MacOS Mojave and have Node (v.10.16.0) and NPM (6.9.0) and have tried npm install -g truffle and have gotten: ...
4
votes
1answer
368 views

How long does it take to “save artifacts” to Ropsten?

Migrating contracts with Truffle I get stuck at Saving artifacts... Sometimes for 10 minutes or more. I also get: Error: Transaction 0x123...123 wasn't processed in 240 seconds! Is it normal that ...
0
votes
1answer
19 views

Cannot Find Module Error for Truffle-contract

Error:- Uncaught Error: Cannot find module './truffle-contract.min.js' at c (web3.min.js:1) at c (web3.min.js:1) at index.html:27 <!DOCTYPE html> <html lang="en"> <head&...
1
vote
2answers
2k views

Out of gas when executing contract via web3 js

I am having a trouble invoking contract via web 3 js in browser. I am using truffle develop and have migrated and run tests successfully. I am also getting the info when I console.log the contract....
0
votes
3answers
185 views

Truffle compile command stuck at “Compiling your contracts…”

I developed a dapp using my PC (OS: Pop_OS!) and it was running fine. Then I had to format PC and installed new OS (Ubuntu 18.04 LTS), due to some issues in compatibility and performance.After that, I ...
1
vote
2answers
38 views

Ganache GUI installation error

node version v12.8.0,npm version 6.10.2 I followed the below steps to install the ganache GUI but I got the error $mkdir ~/ganache $git clone https://github.com/trufflesuite/ganache.git $npm install ...
1
vote
1answer
955 views

rinkeby balance says 0 after syncing even though transaction shows ether was sent

I'm using truffle to deploy a contract on the rinkeby testnet Here is transaction info saying that my address received ether however as shown below, the balance still shows as 0. truffle(rinkeby)...
1
vote
1answer
942 views

truffle migrate hanging on Deploying Migrations

I am deploying a contract on Ropsten Network,These are my settings 2_deploy_contracts.js var SafeMath = artifacts.require("./SafeMath.sol"); var TahaCoin = artifacts.require("./TahaCoin.sol"); var ...
4
votes
1answer
305 views

How do I get configuration variables (such as gasPrice) in a truffle test?

I learned from this answer that truffle configures gasPrice in truffle.js, defaulting to 100000000000. I'd like to use gasPrice in a test, without hardcoding the raw number. Is there any way to ...
1
vote
1answer
539 views

call function from truffle console (newbie)

This should be fairly simple, but I'm still trying to wrap my mind around a lot of things. What is the easiest way of testing by hand the function addEntity? What command do I type into the truffle ...
0
votes
1answer
134 views

Truffle tries deploy from unknown account

I am trying to deploy a contract to Ropsten using Infura with the config file truffle.js below. The deploy fails because the account listed in the error message has insufficient funds – however I do ...
0
votes
1answer
35 views

Simple Truffle tests timeout “before all” hook: prepare suite

I'm trying to write my first tests for truffle, but I run in a timeout each time I want to execute the tests. Error: Timeout of 120000ms exceeded. For async tests and hooks, ensure "done()" is ...
0
votes
2answers
22 views

Truffle error missmatch artifact

What does this means?network/artifact mismatch Contract has not been deployed to detected network but when i write truffle network i can see mine.
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 ...
2
votes
1answer
268 views

How can I use solc solidity compiler on truffle webpack?

When I try to import solc, it raises an error which says: ERROR in ./~/require-from-string/index.js Module not found: Error: Can't resolve 'module' in 'C:\users\bisrat\Desktop\webpacksample\...
5
votes
2answers
2k views

Accessing struct fields in Web3 returned by a promise in Truffle

I'm using web3js (via Truffle) to make a call to a contract, to access a struct in a mapping. mapping (bytes32 => entry) public entries; struct entry { Mode status; Deed deed; uint ...
1
vote
1answer
10 views

ganache test returns characters instead of numbers

mapping(uint256 => uint256) public amount; function saveAmount(uint256 _id, uint256 _amount) public { amount[_id] = _amount; } I have a function that saves amount in mapping. When I test ...
0
votes
1answer
402 views

Running A Smart Contract With Two Nodes on Truffle

We have installed truffle to two nodes and we initialize our private blockchain with: $geth --datadir node init genesis.json Then we run geth on both nodes with: $geth --datadir node --nodiscover -...
0
votes
1answer
26 views

Issue with Serverless deploy of smart contract-Dependency mismatch -Package.json,Package-lock.json error

I'm trying to deploy my smart contract serverless(AWS lambda) and I'm using Truffle framework. The code is getting deployed in an earlier system(earlier it was deployed here). Now I have updated the ...
0
votes
0answers
10 views

Use web3 0.2.x within Truffle V5

It's a pain to have to refactor tests written for TruffleV4 in web3 0.2.x to web3 1.0.x. Is there any way to avoid this situation by using web3 0.2.x instead within Truffle V5?
0
votes
1answer
2k views

invalid address error on running code - solidity

Here is my code : var Web3 = require('web3'); var fs = require("fs"); var Artifactor = require("truffle-artifactor"); var provider = new Web3.providers.HttpProvider("http://localhost:8545"); var ...
0
votes
1answer
20 views

Can't log struct member in truffle test

Contract : mapping (bytes32 => MyStruct) public myMapping; struct MyStruct { uint256 myMember; uint256 someOtherMember; } Test (Truffle) This works: let ...
1
vote
1answer
33 views

truffle migrate --network kovan issue

When I run truffle migrate --network kovan in the terminal the contract deployment doesn't run. Just: Compiling your contracts...==================== >Eveything is up to date, there is nothing to ...
1
vote
2answers
38 views

Understanding ganache timestamps

Sometimes, when I use the ganache specific evm_increaseTime method and advance to the next block, the next timestamp is NOT: current timestamp + advanced time But instead: current timestamp + ...
1
vote
2answers
170 views

Truffle test, how to get address(0)?

This is going to be short question and may be silly, but I'm literally stuck with a problem, where I need to pass address(0) to function in Truffle Test in JS and don't really know how to do it. In ...
0
votes
1answer
37 views

Is it necessary to fetch the history from toBlock to fromBlock by giving the non zero block number?

I have one event inside my solidity smart contract and in web application I am fetching the values using "contractInstance.Transferred({}, {fromBlock: 0, toBlock: 'latest'}).get". When I changes the ...
1
vote
3answers
77 views

A single exception in Truffle test causes every other test cases to fail

I'm making test script for my contract and it looks likes contract('...', async () => { let token = null; before('deploy', async () => { token = await MyContract.new(...); })...
0
votes
1answer
15 views

Can i use a the msg.sender which is a address to call a function of the contract?

I am trying to mint a ERC721 token using openzeppilin/contracts. It was working correctly, but later had to change the design. So now i am forced to use the msg.sender who is the minter to call the ...
1
vote
2answers
20 views

How do I specify the network ID in the config file when migrating/testing contracts on my local ganache?

So my issue is when I run the compile and then migrate commands everything goes smooth, then I try to test by running the truffle test command and it gives me an error saying 'Error: The network id ...
8
votes
1answer
523 views

Configure Truffle Compiler: Default Import Folder

I want to use an external library. I guess it is good to load the library in production from a CDN because this requires less space and should be faster. import "github.com/Arachnid/solidity-...
0
votes
2answers
74 views

Solidity: uint parameter not being set properly

Testing my contract locally with truffle. I have a function with the signature: function purchase(address buyer, address seller, bytes16 bookId, uint tokens) public onlyOwner returns(bool success) ...
8
votes
1answer
563 views

Filtering on events of the entire blockchain not possible in testrpc via truffle

A contract I wrote has an event in its constructor. Since I want to find it back in the logs it doesn't seem possible to start listening to the latest block. Because the event is already 'fired' ...
6
votes
1answer
684 views

Problem with start() in web3-provider-engine

While trying to connect to a provider(infura) I get the above error below is the full stack trace: bundle.js:54318 Uncaught TypeError: this.provider.sendAsync is not a function at Web3Subprovider....
0
votes
2answers
92 views

After compiling contract, there is no build directory inside project directory?

After writing 'truffle compile' in terminal , it just give the message i.e. compiling your contracts...and exit, no build directory is formed in Project directory. What is the issue?
0
votes
1answer
36 views

Problem watching events without invoke functions in the Smart Contract

I have an event which is sent each time when a contract is deployed. It is launched in the constructor. I have a Dapp where I want to watch this event to send a tx each time that a smart contract is ...
0
votes
2answers
19 views

Error: HelloWorld has not been deployed to detected network (network/artifact mismatch)

I'm following the steps in this link to create a truffle project. I'm using ganache-cli as the ethereum client. rajkumar@rajkumar: Ethereum$ mkdir helloworld rajkumar@rajkumar: Ethereum$ cd ...
0
votes
1answer
294 views

Truffle test: error when passing more than one file as input

I have several test files, which I can successfully execute via truffle test (having started a ganache-cli process). For example: ganache-cli truffle test test/test1.js truffle test test/test2.js ...
2
votes
3answers
525 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 ...
6
votes
4answers
3k views

Truffle Box at URL https://github.com/truffle-box/bare-box.git doesn't exist

I'm trying to initialize a directory with truffle init, but I'm getting the following error: Error: Truffle Box at URL https://github.com/truffle-box/bare-box.git doesn't exist. If you believe this ...
1
vote
0answers
17 views

What is the easiest way to write truffle tests in typescript?

I read about Typechain, but the configuration is rather verbose and generally feels like a very custom solution: Everytime you change contracts you need to run yarn generate.
0
votes
2answers
634 views

Error: VM Exception while processing transaction: revert: When trying to migrate a truffles initialised contract?

I'm trying to migrate/deploy a multi-signature contract through truffles, I am receiving "Error: VM Exception while processing transaction: revert" when the contract starts to migrate/deploy. ...
0
votes
1answer
31 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 ...
7
votes
2answers
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 ...
1
vote
0answers
30 views

can not migrate contract to geth private chain

with ganache, no problem with migration. Then with geth, I just cannot make it work. I made sure that the coinbase has enough ether, and it is mining, the account is unlocked genesis { "config"...
0
votes
1answer
18 views

Zepellin Crowsale buyTokens error

I'm trying to use the buyTokens function of the Zepellin Crowsale interface, but this gives me an error, without any log to be able to debug contract TokenA is MintableToken, PausableToken, ...
1
vote
1answer
689 views

Why do I get VM Exception while processing transaction: revert?

I'm trying to call a function from a contract I've created on ganache-cli through a javascript on a website. Here's the code of the java script: web3.eth.defaultAccount=web3.eth.accounts[0]; var poe ...
14
votes
3answers
3k views

How to check events in Truffle Tests?

What's the best way to check that events were fired in a Truffle test?