Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
4
votes
2answers
2k views

How much does it cost to upload a smart contract?

I'm using a local Ethereum testnet and it seems to me that the price of uploading a smart contract is a bit too high. This is the code for the smart contract: contract Transfer { address owner; ...
4
votes
1answer
5k views

Web3 - Uncaught TypeError: contract.abi.filter is not a function

I have compiled and deployed a simple Hello World contract using truffle: pragma solidity ^0.4.4; contract Greeter { function Greeter() { } function sayHello() returns(string) { ...
4
votes
2answers
463 views

How to connect two truffle instances?

How can we connect two truffle applications with each other? E.g., if we have two metacoin applications, how can these two communicate with each other?
4
votes
1answer
65 views

couldnt understand implementaion of UpgradeabilityProxyFactory

I want to use UpgradeabilityProxy provided by zeppelin, they have one method createProxyAndCall which they say initialize the new implementation with data parameter we provided which looks like: * ...
4
votes
2answers
576 views

Mock Smart Contract For Unit Testing

I'm new to Ethereum and solidity, I'm developing a simple decentralized application using Truffle where I have an abstract contract Storage and another contract Reader which uses storage. contract ...
4
votes
3answers
835 views

Truffle migration contract not found - but it's there!

I have a feeling this is going to be a forehead-slapper, but here goes... I'm attempting to run Truffle's "Pet Shop" demo app on AWS. The truffle compile command ran fine, with a few non-fatal ...
4
votes
4answers
472 views

Truffle Drizzle-box fails with TypeError: (0 , _drizzle.generateContractsInitialState) is not a function

Right after unboxing Drizzle-box I'm getting a TypeError: (0 , _drizzle.generateContractsInitialState) is not a function. Ganache is running on localhost:8545, contracts are deployed, Metamask ...
4
votes
1answer
523 views

Should I use new() or deployed() in Truffle unit tests?

What's the difference in using new() or deployed() when creating a contract instance to use in Truffle unit tests? Should I use // VERSION A it("should work", async () => { let instance = await ...
4
votes
1answer
878 views

How do I compile a Solidity contract with an import to standalone byte code?

I am trying to compile the MetaCoin contract (part of the Truffle Init Webpack). I need to get the byte code as hex numbers so that I can use it with Nethereum. The MetaCoin contains an import to ...
4
votes
1answer
4k views

Expected identifier, got 'LParen'

I try using IterableMapping by this example. I have error when I compiling contract by truffle: Expected identifier, got 'LParen' This is my code: pragma solidity ^0.4.15; import "./itMapsLib....
4
votes
2answers
411 views

Truffle tests not resetting account states

I've written some truffle tests that interact with the account balances. Example: A contract transfers X amount of ether from account A to account B. Surprisingly the state of the accounts (...
4
votes
1answer
645 views

Is the address used to deploy contracts in JS tests in truffle always accounts[0]

I've noticed that the deploying address in my truffle .js tests is equal to the address at accounts[0]. Since it's important to me to test the ownership of a contract, I'd like to know if it's ...
4
votes
1answer
5k views

Account is locked, after running Truffle migrate command [duplicate]

I am new to this technology and I am trying to Deploy the contract to Ropsten test network. I have my geth running in one terminal. In my truffle console I have an account with some ether. I unlock it,...
4
votes
1answer
205 views

solidity-coverage adds extra events which make unit-test fail

It seems that when using the latest solidity-coverage (0.5.11), truffle (5.0.0-next.25) ganache-cli (6.2.4-beta.1) and solc (0.5.0) additional events / logs are emitted during tests which make the ...
4
votes
2answers
4k views

How to send ether to a contract in truffle test?

For some reason I cant figure out how to send ether to a contract when testing in truffle. This is my attempt: await myContract.send(10, {from: accounts[0]}); the error message is: Error: VM ...
4
votes
1answer
330 views

Can I truffle migrate with geth --light?

I get invalid address when I try to, I suspect --light doesn't enable deploys -- is that so?
4
votes
1answer
361 views

Truffle Migrations contract constructor argument

I'm reading the Truffle Migrations contract and looking at the code for upgrade(): function upgrade(address new_address) public restricted { Migrations upgraded = Migrations(new_address); // * ...
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 ...
4
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: ...
4
votes
4answers
3k views

Truffle for Windows: I can't make it work

I've installed Truffle v3.2.1 for Windows. If I try to run: truffle console Could not find suitable configuration file. If I run: truffle create:contract MyContract I get nothing but command ...
4
votes
1answer
3k views

truffle console - return (array of addresses) issue

This problem happens only when I place contracts A and contract B in seperate file. When placed in same file, I get the array elements perfectly Please find the contract below. I was able to ...
4
votes
3answers
1k views

Deploying contracts on geth returns Error: connect ECONNREFUSED 127.0.0.1:8545

I'm using truffle (which uses pudding) to deploy contracts to my testrpc. No I'm running a geth instance locally with: geth --mine -rpccorsdomain "*" --ipcapi "admin,eth,miner" --rpcapi "eth,...
4
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 ...
4
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 ...
4
votes
1answer
903 views

truffle migrate specific file

Is it possible to truffle migrate only one specific file? I found this on the internet: https://github.com/trufflesuite/truffle-migrate/issues/23 but truffle migrate -from 2 starts to migrate from ...
4
votes
1answer
1k views

Return a mapping in Truffle test

How would you guys call a mapping from a test and get the values? This is the mapping that I have on my contract: mapping(address => uint[29]) balanceOf; It´s a mapping to an array of integers ...
4
votes
2answers
646 views

Deploy Contract (compiled by Truffle) without using Truffle

A contract SimpleStorage.sol has been compiled by Truffle using truffle compile. Its artifact is found at build/contracts/SimpleStorage.json. However, this contract should only be deployed to the ...
4
votes
1answer
697 views

Error: invalid address during truffle migration process in Rinkeby network

I can't deploy my contract to Rinkeby network through truffle migrate --reset --network rinkeby. My truffle.js file looks like this: { networks: { rinkeby: { { ...
4
votes
1answer
1k views

truffle migrate fails with Network state unknown, Error: account is locked

I'm trying to run the truffle demo on the ethereum testnet but truffle migrate fails with "Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: account is ...
4
votes
1answer
4k views

Get block address through web3.eth.getBlock(1)

I'm getting a list of the last few blocks like described here. Now I can't seem to get the address of each block or the associated contract, through web3.eth.getBlock. A lot gets returned, but no ...
4
votes
2answers
1k views

truffle deploy to geth failing, generating “receipt not found” repeatedly from geth

I've just installed truffle on an ubuntu virtualbox, and it is failing to deploy to a geth dev setup. Geth gives me a never-ending receipt not found for transaction ...
4
votes
2answers
39 views

How to test a function call that should fail?

Im using Truffle to test my smart contracts written in Solidity and I would like to mark test as passed if function call/execution fails. Example: await instance.cancelOrder({from: accounts[1]}); ...
4
votes
2answers
855 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('...
4
votes
1answer
768 views

Contract deployed successfully to Ganache via Truffle, fails to deploy on live network

I basically followed this Zeppelin crowdsale tutorial, just changed the names of the contracts. I was able to successfully deploy on a local Ganache, but then when trying to deploy to the live ...
4
votes
1answer
2k views

How to set truffle-hdwallet-provider as the Web3 currentProvider inside a web page

https://github.com/trufflesuite/truffle-hdwallet-provider/blob/master/README.md provides sample usage for the deployment configuration inside tuffle.js. I need a sample that update the Web3 ...
4
votes
1answer
555 views

Using truffle migrate with Ledger Nano S

I am using truffle to develop new contracts and I have successfully deployed contracts to the Rinkeby Testnet directly with truffle. However, this process, like the one using the MainNet, requires ...
4
votes
2answers
604 views

Failing Transaction within Truffle Testing

How does one test a transaction that is supposed to fail when testing with truffle? For example, say I was testing an ERC token, in which accounts[0] had a balance of 20. Within a test, I call ERC....
4
votes
3answers
2k views

How can I setup Angular with Truffle?

I've been looking for a way to hook up Angular with Truffle for a demo dApp I'm thinking of building but I'm unsure as to how to setup the development environment that would allow me to work with both ...
4
votes
1answer
2k views

Error: VM Exception while executing transaction: out of gas

I'm new to smart contracts, so please be gentle ;) I'm having trouble deploying a contract to testrpc using truffle. $ truffle deploy Error deploying LFC: Error: VM Exception while ...
4
votes
1answer
164 views

Is there a way to test an onlyOwner function from a Truffle/Solidity unit test?

I have a contract with a function marked as onlyOwner (from OpenZeppelin, so only the address that deployed the contract can call it). pragma solidity ^0.4.17; import "./Ownable.sol"; contract ...
4
votes
2answers
2k 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 ...
4
votes
1answer
609 views

Solidity, Ethereum ICO, Truffle and my head exploding

I am trying to somehow end up with a solidity code (for an Ethereum token and a Crowdsale contract), that I can paste in the source code bar in Ethereum Wallet and deploy the Token and the Crowdsale ...
4
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?
4
votes
1answer
2k views

truffle always says “.my_function is not a function” [duplicate]

I'm trying to do my first basic smart contract, following this popular HelloWorld tutorial. However whenever I get to the part where I run a function in the truffle console, it is always telling me "....
4
votes
1answer
580 views

Truffle: How to detect test environment while running smart contract test cases?

I'm trying to run some test cases in Travis CI using truffle but I want some of them not to run if the test environment(localhost:8545) is running via "testrpc" because some of my test cases only ...
4
votes
1answer
503 views

Watching events defined in libraries

Is it possible to watch for event triggers when the actual event and trigger is defined in a library? I get no console output with the following code library ObjectHistoryLib { event ...
4
votes
1answer
972 views

Truffle Dapp Deployed Contract Access

Which function we need to use in truffle for the communication of second Dapp to the contract deployed on blockchain by first Dapp, because contract deployed by truffle is not accessible by geth node. ...
4
votes
1answer
525 views

How do you provide a GasPrice and GasLimit to overcome the “low tx nonce or out of funds” log message

I am getting the following logged by my private chain geth node when running a test in truffle: removed tx ( TX(ff8ec4f713e64fb25df07d153607e29629c9276b57e0b7e331f17b5a3c31fdd1) Contract: ...
4
votes
0answers
44 views

What's the point of Truffle Migrations?

I've been reading a few articles and StackExchange posts (e.g. What are truffle migrations?) about Truffle Migrations, but I still don't get it: why do we need them? It seems they do only one thing (...
4
votes
1answer
95 views

How to raise version of oraclize-api installed via Truffle

I'm using local instance of Oraclize API, to make truffle compile work. I've installed it by truffle install oraclize-api but for now, I'm getting following error if (oraclize_randomDS_args[...