Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
1
vote
2answers
207 views

Deployed Contract Instance Isn't Detected in Testrpc via MetaMask

When MetaMask tries to access my local testrpc, I'm getting the following error in the browser: contract.js:424 Uncaught (in promise) Error: UnitManager has not been deployed to detected network (...
6
votes
1answer
6k views

truffle migrate: How to deploy a contract whose constructor takes a parameter

I'm using Truffle Version 4 to develop a simple smart contract and am stuck on something I think reflects a very basic misunderstanding that I just can't get my head around. Here's my simple contract,...
0
votes
1answer
949 views

Why does a test that passes in Truffle fail when run against testrpc

Using Truffle and testing against both Truffle's own blockchain and against testrpc yields different results. I am trying to test that my deployed contract is setting its owner correctly (owner being ...
9
votes
3answers
6k views

truffle migrate fails with: Error encountered, bailing. Network state unknown

Could someone point out what is happening with truffle. "truffle compile" works fine. Please find the below truffle migrate reset output Ubuntu#truffle version Truffle v3.1.2 Ubuntu#truffle migrate ...
4
votes
0answers
550 views

How can I retrieve transaction hashes using web3 batch requests?

When I send a transaction using Truffle's contract wrappers - or using plain web3 sendTransaction() - I get a tx hash back that I can use to confirm the tx has completed. While using batch requests (...
3
votes
1answer
670 views

Having to set reset flag with truffle migrate

I am having a weird issue where my migrations are not being deployed when I run truffle migrate --network development. But when I run truffle migrate --network development --reset, the contracts are ...
0
votes
1answer
2k views

Truffle Console not working, opens truffle.js instead. [duplicate]

Am currently trying to learn Dapps, and trying to initiate Truffle. But, when I use the command "truffle console" in the Git CMD window, rather than opening the console, it opens up the 'truffle.js' ...
1
vote
0answers
129 views

Transaction consumes more gas using MetaMask's injected web3

I have a simple contract: pragma solidity ^0.4.4; contract Counter { uint public count; function Counter() { count = 0; } function inc() { count++; } } And some javascript that ...
2
votes
0answers
331 views

Using Truffle with Ethercamp Ethereum Studio

I'm trying to use the Truffle development environment inside of EtherCamp Ethereum Studio. My main reference is this issue in the Truffle issue tracker. It suggests using eth-lightwallet and hooked-...
6
votes
3answers
4k views

Truffle solidity tests: out of gas & exceeds block gas limit

I am trying to run some basic test w/ my contract, written with Truffle's Solidity tests (tests written in Solidity). When runninng truffle test, I get Error: VM Exception while processing ...
1
vote
2answers
2k views

Truffle build isn't working

I installed truffle via this command: sudo npm install -g truffle Then I installed testrpc via this command sudo npm install -g ethereumjs-testrpc Then I started testrpc via this command ...
1
vote
1answer
388 views

Invalid Address Error when interacting with a smart contract & Why it works with metacoin

I solved the error accroding to Invalid Address solution PriceContract.web3.eth.defaultAccount=PriceContract.web3.eth.coinbase The contract I run was a very simple set-get variable which I adapted ...
1
vote
1answer
543 views

Correct syntax for contract.method.send() function?

I have a problem understanding the web3 documentation at the readthedocs especially here: https://web3js.readthedocs.io/en/1.0/web3-eth-contract.html#id12 myContract.methods.myMethod([param1[, param2[...
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 ...
0
votes
1answer
438 views

Where truffle save the compiled contract

I'm trying to find where truffle store the compiled code. I'd like to take this bytecode and to deploy it manually with MyEtherWallet
2
votes
1answer
272 views

truffle migrate restarts from first migration after restarting testrpc

I’m trying to create sort of private chain on testrpc so i use testrpc -u 0 -d --db /path/to/db to start testrpc each time. The thing is that if I restart testrpc (kill it and start it again) truffle ...
2
votes
3answers
5k views

How to set default address in truffle?

I made four accounts and lost the passwords to the first three. I am trying to run truffle migrate, but I am worried that truffle is trying to use the first address that I created rather than the ...
0
votes
1answer
443 views

truffle-contract Contract.new() produce an empty contract(no state)

I am making a new copy of a already deployed contract. I am using truffle, truffle-contract to do so. From JS front end var conf = contract(MyContract) conf.setProvider(this.state.web3....
0
votes
1answer
393 views

Events are not getting recognised TypeError: Contract.events.event is not a function

I am trying to get older state of a contract. I have deployed contract using truffle. my contract is pragma solidity ^0.4.15; contract NDA { bytes32 party1name; bytes32 party2name; bytes32 ...
0
votes
1answer
48 views

How can we get the older state of a contract?

What I have I have my private ehtereum chain running on an AWS EC2 instance. I am able to deploy contracts on my private chain. I am able to call functions of smart contract. I am using truffle ...
1
vote
1answer
172 views

Syntax error on official Ethereum ERC20 Code?

I copy and pasted the code found here: https://www.ethereum.org/token into a file called TokenERC20.sol When I run truffle compile I get this error: SyntaxError: Expected "contract", "import", "...
0
votes
0answers
221 views

Why does truffle console not start?

Trying to follow the tutorial on Medium, I would like to open the truffle console (Ubuntu 16.04). I get the following output: mzh@021-voting $ truffle console Error: Invalid JSON RPC response: "" ...
6
votes
1answer
676 views

Truffle exits with “Error: The contract code couldn't be stored, please check your gas amount.” error when migrating the 1_initial_migration.js

I am trying to migrate the basic truffle example (the one created via truffle init) to rospten using Parity but I get the following error even thought the contract is correctly deployed on Rospten: ...
3
votes
1answer
5k views

How to pass argument/parameter to a payable function of a contract that has been already deployed, via web3 / javascript / truffle?

I'm wondering how to pass argument to a payable function of a contract that has already been deployed, via web3 / javascript / truffle. For instance, I see the following piece of code at: http://...
8
votes
1answer
1k views

Truffle — testing enum values

I am using truffle to develop a simple smart contract. I have the following contract: contract Puppy { enum State { good, bad } State public status; State public constant INITIAL_STATUS = ...
1
vote
0answers
136 views

Truffle: How to test for inheritance

I have a Contract B which should inherit from contract A. Using Truffle, how can I test that this is indeed the case?
1
vote
0answers
303 views

Separate contract calling mint from token contract

I have a standard ERC20 token contract with minting functions: pragma solidity ^0.4.11; import "./Stake.sol"; import "./Mint.sol"; contract Token is Stake, Mint { //omitted standard ERC20 text }...
0
votes
1answer
101 views

Where do i define the test contract params?

lets say i have this code (taken from here) // Specifically request an abstraction for MetaCoin var MetaCoin = artifacts.require("MetaCoin"); contract('MetaCoin', function(accounts) { it("should put ...
1
vote
1answer
274 views

Specify Token Price

I'm pretty much new on this. But I really want to learn. I just created a contract for mintable token on Kovan test-net. But, I'm getting confused when I try to buy the token, it's always shown x000....
2
votes
1answer
1k views

Using view modifer in solidity gives error in truffle compiler “ParserError: Expected token LBrace got 'View'”

I am running truffle test with the following simple test contract, however it seems that it doesn't understand the view modifier. Contract pragma solidity ^0.4.18; contract MetaCoin { function ...
3
votes
1answer
141 views

Client to sign transaction and deploy contracts with no chain downloaded

I'd like to deploy contracts from truffle using a localhost wallet but without syncing all the chain. I think this should be possible: a lightweight client able to connect to the network and to sign ...
0
votes
2answers
200 views

Contract Name Types in Truffle Solidity Tests

The example in the docs for truffle .sol tests has these lines: MetaCoin meta = MetaCoin(DeployedAddresses.MetaCoin()); and MetaCoin meta = new MetaCoin(); I've had a good read through the docs ...
0
votes
1answer
274 views

Web3: Perform contract function but only receive transaction hash or incorrect value

I am trying to demo a function on my own geth testnet. I deployed a sample contract I found at http://solidity.readthedocs.io/en/develop/types.html?highlight=crowdfunding. pragma solidity ^0.4.11; ...
2
votes
0answers
99 views

Standard Truffle assertions documentation

I have found Assert.sol which is the code that defines the standard Truffle assertions. Is there a document which describes the available functions? An index would be useful as a start...
1
vote
0answers
34 views

Can only deploy contracts on Parity when --geth flag is invoked [duplicate]

When I try to truffle migrate a contract on a private blockchain using Parity, I get The contract code couldn't be stored, please check your gas amount But when I do everything else the same, ...
0
votes
1answer
55 views

Dummy/test truffle contract?

I am having trouble migrating a contract using truffle. So I want to test with another contract. I know nothing about this. Can someone point me to a contract/project I can download and migrate? I'...
3
votes
1answer
2k views

Can't retrieve Event logs with MetaMask Web3

I have no problem retrieving events with this code: contract.MyEvent({}, { fromBlock: 0 }).get((err, data) => console.log(data)) But when I use the exact same code in a browser that is using ...
0
votes
1answer
53 views

Any “testing” contracts I can migrate?

I am testing a private network and I want to test using truffle to migrate/deploy some contracts. Is there a library of test contracts somewhere that I can use for this?
1
vote
1answer
782 views

How to generate new address for new contract created by constructor

I'm trying to resolve a problem and google is not useful this time. On my localhost truffle + testrpc I have a contract which returns a new instance of a new contract. import 'contracts/...
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 ...
4
votes
1answer
3k views

Deploy smart contract to mainnet with Infura and MetaMask

I am trying to deploy my smart contract to the main net using the following code: truffle.js: module.exports = { networks: { live: { provider: new HDWalletProvider("mnemonic from ...
2
votes
1answer
590 views

Truffle work over HTTPS

I installed my own ethereum node and put it behind HTTPS nginx proxy. geth attach works perfectly but truffle deploy failed with error: <html> <head><title>400 The plain HTTP ...
2
votes
1answer
2k views

Deploying to testnet using Truffle and Metamask

Is it possible to deploy a smart contract developed using truffle to testnet using just Metamask (without a local eth client instance running)? I tried importing the private key of metamask wallet to ...
0
votes
1answer
1k views

How to call a function from truffle

I'm new to ethereum. I followed a tutorial and I ended up with a contract that looks like this pragma solidity ^0.4.15; contract HelloWorld { uint public balance; function HelloWorld() { ...
0
votes
1answer
454 views

Truffle-Contract error with Metamask

It seems that on my computer/web browser Google Chrome is slow to inject meta-mask. Therefore I have to write something like this for my App to actually get the web3 instance instead of failing: ...
0
votes
2answers
609 views

Token not found on Etherscan after Deploying Crowdsale

I am deploying contract that creates a token and a crowdsale, based on code slightly modified from zeppelin-solidity. Problem: After deploying the contract to Rinkeby using Truffle and Infura, ...
4
votes
1answer
5k views

Truffle mingration: Error: authentication needed: password or unlock

I deploying contract using Truffle and got an error Error: authentication needed: password or unlock. I already checked related questons and found only ugly hacks like "unlock desired account directly ...
0
votes
1answer
307 views

Hello world not working. Function not found

I have a simple test contract that I've deployed using truffle: pragma solidity ^0.4.4; contract TestObject { uint public myValue; function TextObject() { myValue = 1000; } ...
2
votes
1answer
4k views

Truffle migrate does not run 2_deploy_contracts.js

I am having problems with truffle migrate on the default Truffle project and using Infura as the provider. Steps to reproduce problem truffle init npm install ethereumjs-wallet bip39 web3-provider-...
1
vote
2answers
3k views

truffle-contract .new() contract method

The Truffle documentation says that the new() contract method deploys a new instance to the network. I have the following code: const Web3 = require('web3'); const provider = new Web3.providers....

1
35 36
37
38 39
44