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
0answers
32 views

Solidity Compiler won't upgrade

I updated to the latest version of Truffle using: npm uninstall -g truffle followed by: npm install -g truffle I verified this succeeded by doing: truffle --version and got this: You can ...
2
votes
0answers
44 views

Error when I try to deploy with infura

Running migration: 1_initial_migration.js Deploying Migrations... ... 0x0ed88dd40f380a805ed0ba1b5b0a9d8178321ab6da9e5c0cb247f5700337b173 Migrations: 0xcfc4ba0488f20c7a2bb24e735f43e240bf249bc8 Saving ...
0
votes
0answers
14 views

How do I solve this error involving web3 and webpack in my truflle-react box based project?

The project is a truffle-react trufflebox, a bounties creating and solving application. It uses Truffle v5.0.1. This is the home page. Below is the page that displays when you click on the 'Become a ...
0
votes
0answers
47 views

How to call contract method from specific address and private key without Metamask check

Good morning, I need to known how call contract method in javascript from specific address(and relative private key) without the check of Metamask. I explain better. This is an example of js code, ...
1
vote
0answers
19 views

web3: getPastEvents works in Truffle on instance, not in web3 script on page

I am looking to collect the previously logged events of a certain type using getPastEvents. It does not seem to work in my web3 script on my site but it does work in truffle console on a deployed ...
0
votes
1answer
23 views

Calling Protected Function From Another Contract

I am trying to call a function in another contract, that is protected with an openzepellin Role library. I am calling availableFunction on the javascript side, which in turn calls protectedFunction. ...
1
vote
0answers
49 views

Error deploying smart contract with web3.js and Truffle HD wallet provider

My web3 version is 1.0.0-beta.41, node version is 10.15.1 solc compiler is 0.4.25 compile.js is successfully compiled with interface and bytecode exports. My deploy.js file const HDWalletProvider ...
0
votes
1answer
18 views

How to deploy a dapp which uses multiple blockchain

I am a newbie and started learning dapp on ethereum. Up till now, I wrote smart contracts; created frontend with html, css and js; deployed smart dapp on either private network(geth, ganache) or ...
1
vote
1answer
162 views

DOMException: Failed to execute 'postMessage' on 'Window' error when using Metamask and truffle Ganache

I faced Uncaught (in promise) DOMException error like below when I was developing Nuxt web app with Metamask(chrome) and truffle Ganache. Uncaught (in promise) DOMException: Failed to execute '...
1
vote
1answer
55 views

Metamask transaction confirmed but “Internal JSON RPC error”

I am using getWeb3() to instantiate a contract and make calls with, the transaction says that is confirmed but when I open up developer tools there is the following error MetaMask - RPC Error: ...
1
vote
2answers
56 views

TypeError: Name has to refer to a struct, enum or contract when compiling a contract

I'm getting a weird error while compiling a contract in Solidity, I think it's because I'm using Solidity v0.5.0 and it was written with a previous version. Here's the code: pragma solidity ^0.4.2; ...
0
votes
1answer
46 views

Truffle test scripts - Help Please [duplicate]

I want to know if my syntax is correct not how to catch a revert. the task is: Call bid method from accounts[1] of Auction.sol using auctionInstance and pass itemId=0, count=6 as arguments it("...
0
votes
1answer
14 views

Javascript Read Message Value Received

In my smart contract, I have a function that sends ether to the caller using the msg.sender.send() function. I need to check that the value being returned by the function is correct (i.e. the amount ...
2
votes
1answer
17 views

Contract Not Deploying In Truffle Tests

I am trying to do a simple test on Truffle, but it seems that the deployed() promise is never being executed. var MyContract = artifacts.require('MyContract') contract('MyContract', function(...
5
votes
2answers
38 views

Is it safe to commit truffle build files to Github (open source)?

Regarding the json build files that Truffle produces based off of my smart contract, is it safe for this information to be treated as public? I just want to be sure it doesn't contain any sensitive ...
0
votes
1answer
13 views

How can I interact with my deployed contract?

What is the simplest way of interacting with a Deployed contract, considering that I am the owner of the contract (Token Contract). I use Truffle/Solidity0.5.0/Open-Zeppelin/node10.15.0 nothing ...
2
votes
2answers
143 views

Undefined results for “web3.eth.accounts” in truffle console

truffle(development)> web3.eth.accounts[0] gives output as "undefined" truffle(development)> web3.eth.accounts instead of showing all accounts details gives the below output Accounts { ...
2
votes
2answers
45 views

Truffle - test only function?

I have a large amount of contracts which I'm testing after applying changes. I'd like to add solidity functions which will be compiled only for testing, but not on mainnet nor ropsten. Is this even ...
0
votes
1answer
28 views

Circular reference error in factory contract pattern

I've used the factory model before, but I've never encountered a circular reference error, and I'm having trouble seeing how this could be a circular reference when I'm creating a brand new ...
0
votes
1answer
36 views

How to access in JavaScript multiple return values returned from a solidity function

My contract function returns two values. How to access the multiple return values in JavaScript from a mocha testcase? contract X { function a() pure public returns(uint,uint) { uint p=10; ...
2
votes
0answers
27 views

Tracking Non-Deployer Transaction Gas Use In Truffle Migrate

In Truffle, gas used by a Migration in deployer.deploy() is tracked by a Reporter using events emitted by the Migration. If I have code of the form: deployer.deploy(MyContract) .then(instance =>...
1
vote
2answers
27 views

How to make truffle test work with ethers.js [duplicate]

I prefer the ethers.js library to web3. Is there a way to configure truffle test to use ethers.js instead of web3? Thanks!
0
votes
3answers
115 views

How to upgrade solidity compiler solc to version 0.5.x?

I am using solidity 0.4.24. The latest version has been updated. How to upgrade my solidity version? Is there any commands for it?
0
votes
1answer
24 views

ERC20 Contract - OpenZeppelin - total confusion

Trying to launch a simple ERC20 Token. I'm finding OpenZeppelin's extensive library - where every Contract seems to import about 4 other Contracts - to be both wonderfully well organized - but also ...
1
vote
1answer
38 views

UnimplementedFeatureError: Encoding type “struct BiddingContract.Bidder memory” not yet implemented

The code is broken with the new upgrade v0.5, using Truffle v5.0.1 (core: 5.0.1) struct Bidder { address bidders_address; uint productId; uint bidValue; } struct Product { uint ...
0
votes
1answer
41 views

Truffle and Ganache - do I need to set the same gas-price and gas-limit in both of them?

Or can I set different values? If I can set different values, then how will they be used in the system (i.e., what gas-price and gas-limit will apply in every transaction that I execute)? Here is my ...
2
votes
1answer
54 views

What is the behavior of solc with optimizer disabled?

When enabling the optimizer the documentation of solc tells you that you can choose between optimizing the gas cost at deployment or the gas cost at execution by setting the runs parameter. But what ...
0
votes
0answers
10 views

Research Papers related to Mythril, Truffle and ReMix

I have found research papers related to most of the testing tools like Oyente, Gasper, MadMax, Securify and so on but I can't find research papers related to Mythril, Truffle and Remix. Are these ...
0
votes
1answer
18 views

ERC777 granularity rounding error

I'm making a token with ERC777 standard. I've got my decimals at 18, and I want whole tokens, so I set granularity to 10^18. when I try to mint 20 tokens, I get granularity error. So I made a ...
1
vote
1answer
32 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
40 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
33 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
34 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
32 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
91 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
27 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
35 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
21 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
26 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
22 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
13 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
24 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
28 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
22 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
126 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
80 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
vote
1answer
69 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
29 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
63 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
50 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 ...