Stack Exchange Network

Stack Exchange network consists of 174 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.

0
votes
0answers
7 views

Solidity/Truffle - Suddenly getting TypeError on Migration file

Suddenly getting an error when doing a truffle compile --reset - even though I didn't make any code changes on my Migrations.sol file. TypeError: Name has to refer to a struct, enum or contract. ...
0
votes
0answers
23 views

Transferring ether balance from contract balance to winner,not working

here is my Solidity snippet: function deliverPrizes(address payable winner) public onlyOwner{ winner.transfer(address(this).balance); } This is what I wrote on truffle console: dCoders....
0
votes
1answer
16 views

How does truffle get the address of the contract only by it's name?

When executing the command truffle(develop)> let instance = await MetaCoin.deployed() How does truffle get the address of the contract that is deployed ?
0
votes
2answers
20 views

access mapping inside mapping of struct in Solidity ^0.5.0

I have a contract which looks like this: contract a { struct Str { uint256 totalTokens; mapping(address => uint256) playerTokens; } mapping(uint256 => Str) public ...
0
votes
1answer
25 views

How to change the account that is interacting with the deployed smart contract on Ganache? [duplicate]

When I enter truffle console and start interacting with the deployed contract truffle uses the first address, how to change the address for testing ? user@user:~/workspace/smart-contract$ truffle ...
0
votes
1answer
30 views

Upgrading to solidity version 0.5.0 getting deployment failed error with same smartcontract perfectly deployed on 0.4.24

The same smart contract is running smoothly in solidity version 0.4.24 but now when I update the solidity version and solving a lot of bugs inside my smart contract I intended to deploy that in ...
0
votes
0answers
15 views

Truffle-contract cannot find module 'debug'

I'm trying to connect my smart contracts to a frontend app using web3 and the truffle-contract node package. In my client-side javascript file, I am requiring the package as follows: import contract ...
1
vote
2answers
27 views

How truffle selects the address with which it deploys a smart contract with and where does it gets it's private keys?

I am reading truffle tutorials for deployment smart contract to gauche, I've never deployed any smart contract to real network. Now when migrate (deploy) a smart contract I get these info: ...
0
votes
1answer
16 views

Unable to use call.value to send the ether to another contract

Block Builder! I create a bank and client contracts, in order to reproduce DAO attack event. The client can deposit, but can not withdraw. I enclose the repo from Github here: https://github.com/...
2
votes
1answer
11 views

How to add Truffle signing keys to MacOS keychain

Debated what Stack Exchange to go to for this, but I thought I'd start here since it's related to setting up a local Ethereum dev environment. I downloaded and have been using the Ganache command-line ...
1
vote
1answer
19 views

Truffle - a proper way to execute a chunk of code

Let's say I have a complex operation to execute, for example deploying 6 contracts and calling functions to each one, passing addreses to few of them and executing some extra more functions. I can, of ...
1
vote
1answer
11 views

Show truffle migration history

What is the best way to show truffles migration history or at least the last successful step. Something similar what I see when I do truffle migrate: Running migration: 1_initial_migration.js ...
1
vote
1answer
16 views

Truffle - call migration file multiple times

I would like to execute migration file "6_deploy_and_register_group.js" every time when I need to create a new group. Is this a proper way to use migrations? If yes, how can I make it working? ...
0
votes
0answers
21 views

Member “transfer” not found or not visible after argument-dependent [duplicate]

I am writing ERC721 contract with truffle. I have recently upgrade solc to 0.5.0 due to openzepplin compiler version. Read about the changes to the 0.5.0 version unfortunately I am unable to resolve ...
0
votes
1answer
21 views

find the bytecode of a contract during compilation

Is there a solution to recover the complete bytecode (init + runtime) of a contract imported in solidity. For example "bytes code = getBytecode (Escrow.sol)" and this would be replaced by bytecode ...
1
vote
1answer
42 views

Member “transfer” not found, solidity 0.5 [duplicate]

Get the following error message, which I suspect has something to do with the solidity version 0.5, that I'm using? Error message $ truffle test Using network 'development'. /contracts/...
0
votes
2answers
50 views

web3.utils.fromWei(web3.eth.getBalance(web3.eth.coinbase), 'ether').toNumber() gives error

web3.utils.fromWei(web3.eth.getBalance(web3.eth.coinbase), 'ether').toNumber() gives this error: > /usr/local/lib/node_modules/truffle/build/cli.bundled.js:369506 > throw new Error('...
-1
votes
0answers
19 views

I want to accept ether when user register

pragma solidity ^0.4.19; contract User { mapping(address => uint) private addressToIndex; mapping(bytes16 => uint) private usernameToIndex; mapping (address => uint) Balance; ...
1
vote
1answer
40 views

Can't connect to local blockchain

Using Truffle, I'm trying to implement my first smart contract by running the MetaCoin webpack. After running Truffle Develop, I can see my list of accounts: Truffle Develop started at http://127.0....
1
vote
1answer
20 views

Scope in events in web3 1.0 [closed]

Inside the callback of an event, how do I get the scope outside the function? Specifically, in the following scenario, I want the web3 object: (using truffle-contracts and web3 1.0 here) ... const ...
0
votes
1answer
25 views

Error: Please pass numbers as strings or BigNumber objects to avoid precision errors

let result = await instance.joinQuiz({ from: accounts[1], value: web3.utils.toWei(10, "wei") });
1
vote
1answer
22 views

ParserError: Expected identifier but got 'payable'

function getWinners() public onlyOwner { require (now > endQuiztime, 'Quiz did not end '); require (isReveal, "You didnt reveal Questions"); // calculate winner for each ques based on ...
1
vote
1answer
25 views

truffle - deploy two contracts and use them in test [duplicate]

How can I pass 2 groups to test? Migrations: var Group = artifacts.require('./Group'); module.exports = async function(deployer, network, accounts) { await deployer.deploy(Group, "test 1"); ...
2
votes
1answer
29 views

abstract contract getting deployed instead of the main contract on truffle migrate

I'm building a project which consists of two .sol files -> A.sol and B.sol. Now, A.sol contains an abstract contract definition of B, among other things, like this: Contract B { function fnB() ...
2
votes
1answer
34 views

Can't access test network's accounts

So I've updated my framework and with it the web3,js lib. When I run the console and attempt to get an account from my test network by web3.eth.accounts, it won't display a list of the accounts like ...
1
vote
1answer
13 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"....
0
votes
0answers
27 views

FATAL ERROR: Rebalance Allocation failed - process out of memory

So while running truffle compile for my contracts on AWS Ubuntu server I got the following error: <--- Last few GCs ---> [17055:0x3985730] 11958 ms: Scavenge 511.7 (553.4) -> 506.9 (553.4) ...
1
vote
2answers
245 views

Unable to run truffle compile

I want to run truffle compile on my AWS Ubuntu 18.4 server. I'm able to compile the same contracts on my local with no compilation errors but when I tried to run truffle compile on AWS ubuntu server ...
0
votes
2answers
27 views

Get creator from contract address

How can I get the creator's address of a contract? I'm using truffle, so usually I do let instance = await VM.instance() and then get the contract's address via instance.address Then, how can I ...
0
votes
0answers
20 views

Build failed SyntaxError: Unexpected token: name (length)

I setup truffle unbox react-auth and add few libraries as shown in my package.json below. I have no problem running npm run start but failed to compile npm run build with the following error: ...
0
votes
2answers
37 views

truffle migration fails, but initial migration was mined

I am trying to deploy this contract on a private permissioned Quorum network. The migration fails on the 1_initial_migration process. If I try to repeat the process with: sudo truffle migrate --...
0
votes
1answer
92 views

ı got 'TypeError: Data location must be “storage” or “memory” for parameter in function, but none was given.'

I am trying to do truffle migrate but i got this error $ truffle migrate Compiling .\contracts\Election.sol... Compiling .\contracts\Migrations.sol... Compilation warnings encountered: /C/Users/...
0
votes
1answer
67 views

truffle version installation issue

I am running into permission issues when I try to install truffle avi@avi-Inspiron-3542:~$ sudo npm install -g truffle /usr/bin/truffle -> /usr/lib/node_modules/truffle/build/cli.bundled.js ...
0
votes
1answer
20 views

How to test contract interaction with mainnet contract via Truffle

I'm writing a contract via Truffle and my understanding is that running truffle test will run my tests in a clean-room environment. E.g. a fresh deployment blockchain run on my local machine How can ...
0
votes
0answers
32 views

How to `truffle migrate` to private permissioned network?

I am running a private permissioned network and would like to use Truffle v5.0.1 for deployment. I use it according to the documentation: Compile my project with truffle compile so that the ./build ...
0
votes
0answers
30 views

Invalid opcode on estimateGas 'code': -32000

this is my contract : pragma solidity >=0.4.21 <0.6.0; contract CloudProject { uint public nbCandidates = 0; uint public nbBureau = 0; uint public nPartiPouvoir = 0; ...
0
votes
1answer
27 views

Truffle migrate no error but does not create build directory

I'm trying to develop a simple dapp using ReactJS.I used Charterhouse/truffle-create-react-app box suggested by truffle website. The problem is truffle compile and truffle migrate do not seem to work. ...
1
vote
0answers
23 views

Transaction submitted through Infura, but not from local node

So, I have a Rinkeby fast sync on my server. When I try to interact with my contract and transfer something, geth says "Submitted transaction", but then I can't find it using its hash on etherscan. ...
0
votes
0answers
18 views

Uncaught ReferenceError: TruffleContract is not defined (Truffle Pet Shop)

I'm writing my own application that follows a similar form to the Truffle Pet Shop. I have the following code in my app.js: initContracts: function(){ $.getJSON('Greeter.json', function(data) { ...
2
votes
1answer
53 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 ...
0
votes
1answer
28 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....
0
votes
1answer
20 views

Unable to transfer from a contract to another contract

I was trying to learn how smart contract interaction by implementing a bank contract and a client contract. The end user create a Client contract. Then, he use the Client contract to deposit or ...
-1
votes
1answer
25 views

Problem with the compilation in the truffle framework

I made a smart contract in Remix-Solidity IDE, when I compiled it I had no errors and I was able to remove the contract but when I tried to use the truffle for my Dapp and compiled it it showed me ...
2
votes
1answer
40 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 ...
0
votes
1answer
17 views

Migrates contract with specific account without hard-code address using truffle and Genache

Block Builders! I am trying to migrate my two smart contracts using truffle and Genache. I would like to specify the deploying accounts existing locally. However, when I try to migrate the contracts I ...
0
votes
1answer
23 views

Unable to test the value from contract using truffle test

block builders! I have trouble testing the return value from my contract, because the return uint value is always a "transaction" object (I actually don't really know what that mean) Here is the ...
1
vote
0answers
36 views

How to use the latest version of Truffle Contract in a web page?

I'm trying to use version 4.0.0 of truffle-contract in a browser app, so no NodeJS, no require or anything. So I followed the instructions in the doc, downloaded truffle-contract in non-minified ...
-2
votes
1answer
30 views

ParserError compiling Smart Contract, what's wrong?

I'm getting this error when trying to compile a contract using cmd on windows: Error parsing C:/Users/alexa/Desktop/contracts/contracts/ApprovalContract.sol: ParsedContract.sol:6:37: ParserError: ...
1
vote
1answer
179 views

TypeError: Data location must be “memory” for return parameter public view returns (address[16]){

I know that is question has been answered in one form. However, I could not find an answer for my specific case. Here is my code: pragma solidity ^0.5.0; contract Adoption { address[16] adopters; ...
0
votes
1answer
24 views

Access modifiers for properties of a struct

I am relatively new to Solidity. I am following a tutorial and came up with the following contract: contract Election { struct Candidate { uint id; string name; uint voteCount; } ...