Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [truffle]

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

1
vote
1answer
32 views

Can I avoid manually changing code from solidity 0.4.17 to 0.5?

I'm totally newbie in blockchain programming and I have a situation: I have to continue the project written on truffle framework with solidity version 0.4.17, the problem is that I couldn't manage to ...
1
vote
1answer
16 views

onERC721Recieved implementation

As per the ERC721 requirements, I have to implement onERC721Recieved. This is how I did it: function onERC721Received( address _operator, address _from, uint256 _tokenId, ...
0
votes
0answers
23 views

Uncaught (in promise) TypeError: rentalInstance.carsCount is not a function

I am beginner in writing Dapp. I am writing with truffle and solidity. Rental.sol pragma solidity ^0.5.0; contract Rental { // address[16] public rentals; // address public owner; ...
0
votes
0answers
12 views

Can I avoid metamask popups with calls to a server-side js script in order to pay for transactions?

I have a dapp that allows a user to input some info via the GUI, and this info is stored to the blockchain(testnet for now) when the user presses a button. This naturally incurs a cost, which causes ...
0
votes
1answer
51 views

ReferenceError: address is not defined

Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 ReferenceError: address is not defined. const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); // ...
0
votes
1answer
109 views

TypeError: Data location must be “memory” for parameter in function, but none was given

Contract fail to compile in IDE Remix.due to the following error: TypeError: Data location must be "storage" or "memory" for parameter in function, but none was given. version:0.5.6+commit....
0
votes
1answer
20 views

truffle test get different results between ganache-cli and local geth

When I run truffle test on ganache-cli, it will pass the test but when I run the same truffle test commnad on local geth node, it will fail with error saying invalid address at the method which takes ...
0
votes
1answer
65 views

Metamask not connecting to localhost “7545”

After following the pet shop tutorial i cant connect my localhost to the metamask wallet i'm still get 0eth in my wallet whereas it should be 99eth after connecting. The metamask is not showing it as ...
0
votes
1answer
19 views

Is there a good erc20 source using web3js?

I'm looking for some source codes using web3js for interaction with erc20 tokens and contracts. Does anyone know good source codes using web3js? Thanks in advance!
3
votes
2answers
83 views

Truffle Test Issue With `address payable` and Compiler Version

I am trying to run truffle test on an old contract which was written using pragma solidity 0.4.24;. While I am able to deploy the contracts using truffle migrate, I get the following error when ...
0
votes
1answer
15 views

Cannot retrieve data from smartcontract during tests

I am writing truffle tests for my smart contract solidity version 0.4.24. The tests are emitting events to write data to memory through smart contract. But I am unable to retrieve data from functions. ...
1
vote
1answer
33 views

Smart contract now vs javascript now

I have a trouble with comparing timestamp parameter(in test) and now in smart contract. Here is my smart contract: function create(uint created_at) public { require(now > created_at, "The ...
2
votes
2answers
65 views

Cannot able to call the contract inside the truffle console

I am new to the truffle framework. I have initialised my contract Dapp with the constructor function as given below pragma solidity ^0.5.0; contract Dapp { uint public totalSupply; ...
0
votes
1answer
62 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

Solidity Contract Deployment fails - but account has plenty of ETH

I was just trying to deploy a new contract on the Ethereum MAIN-Net (not Ropsten, Rinkeby or the other test-nets) - and I’m getting this strange error: Message: sender doesn't have enough funds to ...
0
votes
0answers
37 views

Issue calling one contract from another using Quorum

I'm using truffle and running locally with 4 quorum nodes, trying to call another contract's function, but keep getting 0 in return instead of the expected value the I get once calling the contract ...
-2
votes
1answer
20 views

I had error when I ran truffle test call which I had followed the documentation of official truffle petshop documentation [closed]

chittiError: CompileError: Error parsing /Users/rahul/pet-shop-tutorial/test/TestAdoption.sol: ParsedContract.sol:10:1: ParserError: Expected pragma, import directive or contract/interface/library ...
1
vote
1answer
191 views

UnhandledPromiseRejectionWarning: Error: Subscriptions are not supported with the CustomProvider [duplicate]

Trying to deploy the newly created contract into rinkeby test network but got struck with the below error. Please check the code, error message and package.json details below. const HDWalletProvider =...
0
votes
2answers
40 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
3answers
90 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 ...
0
votes
1answer
118 views

Invalid implicit conversion from address to address payable requested

first of all really nice to find this forum, I'm starting coding Solidity. Here the problem I get compiling a template of crowdsale smart contract ExampleTokenCrowdsale.sol, from this tutorial. The ...
0
votes
0answers
8 views

Metamask browser apps reusing Truffle tests?

After reading the documentation about metamask (https://github.com/trufflesuite/trufflesuite.com/blob/master/src/docs/truffle/getting-started/truffle-with-metamask.md) is not clear to me whether it's ...
1
vote
2answers
44 views

Trying to test the contracts fully

truffle(develop)> version Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 const ApprovalContracts = artifacts.require('../../contracts/ApprovalContracts.sol'); contract ('...
0
votes
1answer
20 views

Truffle Test async problem [closed]

When I "truffle test" and the below runs, I get 1,3 as the output. How do I make everything happen in order, I want to force it to wait until dai is defined. const DAI = artifacts.require("DSToken"); ...
1
vote
2answers
64 views

Why Truffle over Remix Ide

Can anyone please let me know why I should work in truffle framework to test the contracts when I have access to Remix Ide.
0
votes
0answers
21 views

ERC721 Transfer Event issue

Looking at the open-zeppelin ERC721 Contract's code, I see that the very last thing that its mint function is doing is call emit on the contract's pre-defined Transfer event. My question is: how do ...
0
votes
1answer
26 views

how to parse values returned by one contract into another?

I've two contracts deployed one is UserRegistration and another is Exam I've getUser(uint id) method to fetch data of particular user using users mapping, function getUser(uint _id) public constant ...
0
votes
0answers
22 views

Web3 & Solidity - Automatically read ABI and Create Contract

Is there a way to automatically create a new Solidity Contract - from within a web3 JS file using the .json file created in a project's build folder after each compile? I have already figured out how ...
0
votes
1answer
36 views

Solidity Contract Needs Another Contract's Address

Is there a way for a Solidity contract to programmatically find out another solidity Contract's address? Right now I'm letting Contract A know about Contract B by hard-coding the address of B into ...
1
vote
1answer
40 views

“ app.candidates is not a function” getting these error while caling the function through truffle console with "app.candidate'

pragma solidity ^0.5.0; contract Election { //Model a Candidate struct Candidate { uint id; string name; uint voteCount; } //Store Candidate //Fetch ...
0
votes
1answer
32 views

receiver.payable

Truffle v5.0.5 (core: 5.0.5) Solidity v0.5.0 (solc-js) Node v10.15.1 pragma solidity v0.5.0; contract ApprovalContracts { address public sender; address public receiver; address public ...
0
votes
2answers
52 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 ...
0
votes
0answers
36 views

How to use multiple app.js in truffle project?

I'm new to blockchain and currently developing small application for educational purpose using solidity. I am using truffle framework and stuck at a point. currently there is only one app.js file in ...
0
votes
1answer
26 views

Truffle - how to share variables and functions between test files? [closed]

I have files in Test directory, each one performs different test but all of them contain at least exactly the same functions "register" and "vote", also few arrays like votings = [], groups = [] and ...
0
votes
1answer
143 views

Truffle console error “Error: Returned error: VM Exception while processing transaction: revert”

I compiled and migrated my solidity codes of erc20 token to development networks on truffle, and use it on truffle console. truffle(development)> let instance = await XToken.deployed() truffle(...
0
votes
0answers
33 views

HTTP query create request error for oraclize

I have tried to deploy a sample contract having oraclizer query using truffle+ethereum bridge+solidity. First ethereum bridge made up and got OAR address which is used in sample contract in ...
0
votes
2answers
55 views

Solidity & truffle: get elements from strings array

i'm glad to follow this forum, it is very helpful. I'm using truffle to develop contracts and i just found that dynamic arrays are not yet suported, for that reason i was using string arrays with a ...
0
votes
2answers
31 views

truffle pet shop example question(address convert) [duplicate]

I have some question about truffle pet shop example ,here is the original link pet shop, when I work this command:truffle test , and I have some compile problem. here is original code: I have some ...
0
votes
1answer
17 views

Import dependencies which rely on additional dependencies

I'm using truffle to create a contract that extends another contract in a GitHub repository e.g. contract Consumer is Chainlinked { } My first problem is that I an unable to import directly from a ...
0
votes
2answers
270 views

Truffle compile and migrate not working

I have a geth node running on my laptop. This is the command I used to start geth. geth --port 4321 --networkid 1234 --datadir=./dataDir --rpc --rpcport 8543 --rpcaddr 127.0.0.1 --rpcapi "eth,net,...
0
votes
1answer
27 views

Event suddenly disapears when i call another function in my contract

So i am doing a factory for an ERC20 token contract, here is my factory code: pragma solidity >= 0.4.0 < 0.6.0; import "./ERC20.sol"; import "./ERC20Interface.sol"; contract Factory { ...
0
votes
0answers
14 views

web3 is not getting detected while migration in truffle [duplicate]

I am trying to deploy the contract in ropsten. In that process I use web3 for a conversion. Due to this the migration fails as mentioned below. Please assist me in resolving this. I have also tried ...
0
votes
0answers
104 views

Truffle: Error: Could not find a compiler version matching 0.5.0

I wonder why I get the error when I have v0.5.0 everywhere and do the following: In my Action.sol: pragma solidity ^0.5.0; In Migrations.sol: pragma solidity >=0.5.0 <0.6.0; When running truffle ...
0
votes
0answers
12 views

Is it possible to write to a file from a truffle console?

I am running some tests on my smart contracts and I need to gather a bunch of data to process in a spreadsheet. Is it possible to write to a file from the console?
1
vote
1answer
47 views

how to test overloaded function in truffle?

I recently upgraded truffle to the newest version. Now it does not automatically detect overloaded functions anymore. Before, I could just do the following: await contract.function({ from: accounts[...
0
votes
1answer
27 views

Making assertions (assert.equal) on two return values in Truffle

Appreciate any help I can get. I am trying to make an assertion on returned values from a smart contract, and I cannot figure out how to get it to work for a Truffle test. I cannot show all my code in ...
2
votes
0answers
36 views

Why truffle deploy fail with address value=0 after I upgrade to version 5.0.5?

I have a truffle 2_deploy_contracts.js something like this : const sample = artifacts.require('./Sample.sol'); module.exports = function(deployer) { deployer .then(()=>deployer.deploy(...
2
votes
1answer
31 views

Truffle .call() returns values with array index instead of keys

I am currently writing tests for solidity contract using truffle. When I invoke a function from the contract with .call(), the object that is being returned to me has the values included twice, once ...
1
vote
0answers
27 views

Truffle test {from} option is ignored

To test my contracts i need to use multiple accounts. I hoped that changing value of from option will help me with this. But it is ignored and msg.sender is always accounts[0] (my deployer) Truffle ...
2
votes
1answer
72 views

How to debug transaction from truffle test on development network

I am trying to debug a failing solidity function, which I am calling from the JS test files with truffle. When I run my test, I am successfully able to get a transaction id. However, my solidity ...