Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
5
votes
1answer
4k views

Error calling a function from another contract: Member “*” not found or not visible after argument-dependent lookup in type

I'm having trouble compiling a contract that calls a function of an imported contract. SilverCoin.sol: pragma solidity ^0.4.11; contract SilverCoin { function abc() constant returns (uint) { ...
5
votes
2answers
1k views

what is the role of Migrations.sol contract in truffle project?

I have started working with truffle since 4 months and I don't give importance to Migrations.sol, I thought it's just a "get started" contract. But when I removed it caused a problem. can anyone ...
5
votes
2answers
2k views

How to get the transaction cost in a Truffle unit test?

How can I get the actual gas consumed by a sendTransaction inside a truffle test? In the following test, buyer sends an amount of 50 ETH to a contract: const EmptyContract = artifacts.require("...
5
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.
5
votes
2answers
4k 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,...
5
votes
1answer
2k views

Get transaction id after contract function call

I'm using truffle. How can I get transaction id before it is mined? For example: contract.purchase(price).then(function(tx) { console.log("Success"); }).catch(function(e){ console.log(e); }...
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
3answers
1k views

Does deploying a contract mean it will overwrite the last instance?

I must have missed something about deploying contracts, but to be sure: I'm using Truffle, Does deploying a contract mean it will overwrite the last instance? Since I see that it gets a new address ...
5
votes
4answers
1k views

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider

I am trying to Deploy a beginners contract onto the rinkeby test network through Infura node. It is throwing the following error. (node:35183) UnhandledPromiseRejectionWarning: Unhandled promise ...
5
votes
1answer
6k views

Is it possible to send ether from contract address to my account address using the CloseChannel() function and what will be the Truffle command?

pragma solidity ^0.4.0; contract exchange { mapping (address => uint256) public balances; event PaymentDone(string s); function Channel( uint value) payable { balances[msg....
5
votes
3answers
4k views

Truffle deployer.deploy() not working

I'm having problems deploying the contract via Trufflem, using Parity as my client, on the Kovan network. The contract is a slight variation of this one. When I ran $ truffle migrate using the ...
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 ...
5
votes
2answers
561 views

What Continuous Integration services support running Truffle Solidity tests?

What are the best practices for running a CI server that runs Truffle Solidity tests?
5
votes
2answers
1k 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 ...
5
votes
4answers
844 views

I can't verify my contract on the Rinkeby etherscan site

I'm getting the following error when verifying on the RINKEBY etherscan site: Error! Unable to verify source code Exception #1 Occured: ERROR|The Contract solidity compilation has exceeded the ...
5
votes
3answers
1k views

Truffle v5 runs out of gas but Truffle v4 deploys the contract

Truffle v4 used to deploy the contract successfully, but Truffle v5 truffle migrate command fails. My process to deploy: 1) delete buidl/ folder 2) truffle compile 3) truffle migrate Truffle v5 ...
5
votes
1answer
1k views

Web3.js or Web3.py ? What is the more mature API to interact with Ethereum?

I'm started a new Dapp project, and I trying to find the best way for a quick prototype (back and front end dev). I most familiar with Python, so I search every element than I can to build a Dapp in ...
5
votes
1answer
2k views

“this._eth.sendTransaction is not a function” when executing method in Web3

I'm using react-web3 (which basically gives me a web3 object back) and I'm trying to make my contract work. This is the code I'm using: const web3 = window.web3; const contract = new web3.eth....
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
3answers
2k views

accessing truffle contract abstractions from external JS script

When writing tests in truffle (v3.2.1) I can forget about things like a contract's ABI and address and just use ContractName.deployed() to interact with a contract on my testrpc chain. How can I mimic ...
5
votes
2answers
545 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 ...
5
votes
1answer
576 views

Having issues using the Drizzle library in React

Using Ubuntu 16.04 Greetings, all I was following the tutorial for getting Drizzle up and running located here. I advanced to this step when I attempted to run the app using the "npm start" command ...
5
votes
1answer
2k views

You must deploy and link the following libraries before you can deploy a new version of Contract

I made my custom library and try to using on my own project. Below is the 2_deploy_contracts.js module.exports = async(deployer, netowrk) => { await deployer.deploy(OptionStorage, ownerAddress); ...
5
votes
3answers
1k views

How to properly catch events using MochaJs

Good day, I'm using mochajs to test my Solidity code using truffle and testrpc. In my contract I got the following event and function: contract store{ event MoneyIn (address _from, uint256 ...
5
votes
1answer
456 views

Oraclize + Testrpc + Truffle. Results aren't updating in contract

In my contract I am just doing a basic query to WolframAlpha function testOracle(){ oraclize_query("WolframAlpha", "random number between 0 and 100");} I also have the __callback function: ...
5
votes
1answer
1k views

Truffle does not add “networks” to build/contracts/contract.json after migration

Problem Truffle does not add "networks" to build/contracts/contract.json files after migration. Versions running Truffle v4.0.1 (core: 4.0.1) Solidity v0.4.18 (solc-js) EthereumJS TestRPC v6.0.3 (...
5
votes
2answers
1k views

How to import a smart contract on github in a truffle contract?

I am using a smart contract that imports and uses the Oraclize contract at https://github.com/oraclize/ethereum-api/blob/master/oraclizeAPI_0.4.sol, if in the remix editor this can be done as follows: ...
5
votes
2answers
1k views

how to check if an event was added to the log in a contract constructor

when executing a transaction in truffle tests, the return value is the transaction receipt and one can check for the presence of a particular event in the logs. this is not possible when the ...
5
votes
2answers
4k views

How would you integrate Ethereum smart contracts into an existing node/react project?

I have an existing node/graphql/mongodb/react/redux project that is in beta and I would like to integrate Ethereum smart contracts to be able to save transaction information into the block chain. Is ...
5
votes
1answer
1k views

Accessing testrpc addresses from solidity tests

I'm consulting truffle's docs on how to test contracts directly in solidity. http://truffleframework.com/docs/getting_started/solidity-tests I'd like to figure out a way to refer to existing testrpc ...
5
votes
3answers
5k views

Build an application with Truffle + React + Redux

I'm looking for some examples about how to build a Dapp with Truffle + React + Redux. I'm able to only find this old tutorial https://www.youtube.com/watch?v=GPP6uAq15d8. Does anyone have some other ...
5
votes
3answers
2k views

Truffle does nothing and shows no output when running tests

I am switching machines and ran into a weird issue with truffle. Truffle is set up properly on my old machine. I can compile and run tests without any issues. To my knowledge, I set up everything ...
5
votes
1answer
2k views

The send transactions “from” field must be defined!

I am trying to call a function of a contract that has been deployed to Ganache. I am trying to call a function that makes payouts to a few addresses and can be called by owner only. When I am calling ...
5
votes
1answer
622 views

Contract factory function running out of gas during Truffle test

Using openzeppelin library and truffle I am trying to make a Contract Factory that creates ERC20 tokens. I prefer to test it with Truffle using solidity and not javascript. Here is the code from the ...
5
votes
4answers
1k views

How to change settings for truffle develop?

I'm trying to change the settings for my truffle develop node, but the values in truffle.js don't seem to work. Here's what I have there: networks: { development: { host: "127.0.0.10", ...
5
votes
1answer
2k views

How to access test accounts created by TestRPC from a Solidity test with Truffle?

With Javascript tests, it is possible to access the accounts which TestRPC creates using: contract('MetaCoin', function(accounts) { // tests here can access accounts[n] to get the public keys } ...
5
votes
2answers
2k views

Truffle test with async/await

Has anyone got Truffle tests to work with async/await? My sample code for testing require('babel-polyfill'); var ERCToken = artifacts.require("./ERCToken.sol"); var Proxy = artifacts.require("./...
5
votes
2answers
271 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); <- ...
5
votes
2answers
1k views

Truffle Migrations | Same contract deployed multiple times

I'm using truffle migrations a lot, and I would like to deploy a contract twice during my migrations. Is it possible? Nowadays, I'm using migrations like const MyContract = artifacts.require('...
5
votes
2answers
3k views

What is use of HDWalletProvider in Truffle config?

The sample code here for deploying to Ropsten used HDWalletProvider and a mnemonic in the config, but I am not sure I understand its purpose. Is this just telling it the account that will become the ...
5
votes
2answers
2k views

Unit tests written in Solidity, how to change msg.sender address, msg.value,

I would like to know if it's possible to change the address of the message sender of contract's function call when writing unit tests in solidity. It really should be, I was trying to find out how but ...
5
votes
1answer
2k views

Truffle console.log is not working

I've installed Truffle by npm, and running testrpc, but console.log is not working in Truffle console. A simple console.log('test'); do nothing. Any idea?
5
votes
1answer
2k views

Contract migration error: The contract code couldn't be stored, please check your gas amount

I am trying to deploy my simple ERC20 token with locally installed Truffle, but received this error: truffle migrate --reset Using network 'development'. Running migration: 1_initial_migration.js ...
5
votes
1answer
2k views

Getting new BigNumber() not a number: [object, object] error

I am getting a BigNumber() error from the standard token function balanceOf(). The function returns uint256, but it seems like it's returning an array of objects. Here is my javascript testing in ...
5
votes
1answer
2k views

Watching Solidity event gives error: TypeError: watch is not a function

I am trying to watch a Solidity event in my React app, but I keep getting the following exception error thrown: TypeError: MyEvent.watch is not a function I am sure the event is present in ...
5
votes
1answer
407 views

Using truffle migrations for seeding lots of data inside a smart contract?

I have been developing a smart contract (ERC-721 compliant) which needs to be populated with lots of various pieces of data. Approximately 300 ERC721 tokens need to be minted inside the contract at ...
5
votes
1answer
526 views

Printing uint256 value to console while debugging with Truffle

I am trying to figure out how to print values to the console while doing truffle debug <txhash>. So far I have tried using an event called "TestValue", but I am not seeing the output in the ...
5
votes
2answers
1k views

Why are my contracts showing as not deployed in Truffle?

I'm trying to use Truffle to test some contracts by following their docs. As specified, I have installed truffle, testrpc, created the migration contract and worked fine. Ran truffle compile $ ...
5
votes
1answer
376 views

Getter function on solidity

what mistake did I make? pragma solidity ^0.4.0; contract Getter_check { uint public data = 50; function f() constant returns (uint r) { r = data; } } pragma solidity ^0.4.0; ...
5
votes
1answer
2k views

How to deploy truffle contracts to Rinkebey?

What are the parameters that I have to specify to be able to deploy solidity contracts using Truffle in the config file? I am using Metamask to store test ether and have a unique mnemonic to define ...

1 2 3
4
5
44