Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
0
votes
2answers
839 views

How to test contract with multiple accounts / addresses in truffle?

I want to test my truffle contract with multiple msg.sender addresses. Like "the first user sell token, the second user buys this token". For one address I simply write something like contract.buy....
0
votes
0answers
257 views

External js file not getting load in Truffle test

I'm writing up test cases for my smart contract. Here is the folder structure: - bin - build - contracts - mytestfile.sol - modules - mymodule.js - test - mytestfile.js truffle.js I want ...
0
votes
1answer
30 views

In up gradable design pattern how to set the allowed contracts or owner during deployment of smart contracts

Functional Background: Contracts for upgradable design pattern: ProofDB.sol : contract to store the data. Proof.sol : contract that contains the business logic. Registry.sol: contract that ...
0
votes
2answers
313 views

How to download or access ('web3/lib/web3/event.js');

The following test script requires('web3/lib/web3/event.js'); const SolidityEvent = require('web3/lib/web3/event.js'); function decodeLogs (logs, contract, address) { return logs.map(log => { ...
0
votes
2answers
147 views

Solidity: uint parameter not being set properly

Testing my contract locally with truffle. I have a function with the signature: function purchase(address buyer, address seller, bytes16 bookId, uint tokens) public onlyOwner returns(bool success) ...
0
votes
2answers
165 views

when to use MyContract.deployed()?

I was going through truffle-contract docs and came across this function MyContract.deployed() As mentioned in docs this function create an instance of contract abstraction(abi) representing the ...
0
votes
0answers
63 views

Truffle migrate fails with geth

When I run "truffle migrate" I wait for few seconds than the geth node fall down and I got this truffle error : "Error encountered, bailing. Network state unknown. Review successful transactions ...
0
votes
1answer
463 views

Sending string as address to smartcontract

I have trouble sending an address to a deployed contract, my function looks like this: function addNote(uint _value, address _owner) public { ... } and when I'm sending the parameters: contract....
0
votes
1answer
175 views

why i get a lot of errors when i use truffle?

Seems that i have a lot of lost dependencies for example installing sha3 errors: > node-gyp rebuild C:\Windows\system32\node_modules\sha3>if not defined npm_config_node_gyp (node " C:\Program ...
0
votes
1answer
505 views

truffle migrate cause “Error: insufficient funds for gas * price + value truffle migrate”

When I run "truffle migrate" to deploy contract to geth, I got this error: "Error: insufficient funds for gas * price + value truffle migrate". this is the genesis block of my private chain: { "...
0
votes
1answer
169 views

Basic token transfer and unit test

I am having trouble testing a very naive transfer method for my coin, based off of the ethereum.org demo coin. I've simplified it down into the essentials, yet my solidity unit test keeps failing. ...
0
votes
0answers
67 views

How to find module in truffle pack

I am trying to run a JS test script with truffles but I can not seem to find the right place to store the assertRevert file so that the module can be found by the script when I try to run the test. ...
0
votes
0answers
244 views

Cannot read property '2' of null ERROR during truffle compilation

Here is the source code. pragma solidity ^0.4.24; import"./SafeMath.sol"; contract erc20 { function totalSupply() public view returns (uint256); function balanceOf(address who) public view ...
0
votes
2answers
563 views

How to pass msg.sender and constructor params in truffle tests?

I have the following constructor: constructor(address _payee) public { payer = msg.sender; payee = _payee; } And this function in my JavaScript tests: beforeEach(async () => { ...
0
votes
1answer
141 views

Error npm installing consensys diligence takehome bignumber util

``` /sudo npm install Password: Unhandled rejection Error: Command failed: /usr/local/bin/git clone --depth=1 -q -b master https://github.com/debris/bignumber.js.git /Users/quantum/.npm/_cacache/tmp/...
0
votes
1answer
473 views

Truffle compiling error

I having the error below when I tried compile the contract. Should I downgrade the truffle version? If yes, which version because I couldn't find the appropriate version for sol 0.4.18. Thanks ...
0
votes
2answers
94 views

How to manipulate value stored in array (Solidity smart contract)?

I'm currently fighting with a seemingly very simple issue. I just try to increment the value stored in an array in a Solidity contract. uint256[] public barLengthToBarAmtForSale; I initialise the ...
0
votes
1answer
372 views

How can we assign unique hash id to the id that created inside our smart contract in ethereum?

I am using truffle, ganache and web3. I am initializing user id in smart contract while deploying the smart contract. As of now, everything is done by account[0] of Ganache. Now, I want functionality ...
0
votes
1answer
63 views

Is it necessary to fetch the history from toBlock to fromBlock by giving the non zero block number?

I have one event inside my solidity smart contract and in web application I am fetching the values using "contractInstance.Transferred({}, {fromBlock: 0, toBlock: 'latest'}).get". When I changes the ...
0
votes
0answers
34 views

Ger transaction details from the variable declared in smart contract

I have written smart contract in which I have declared one variable like uint256[] public UserIdList. And I am adding 3 userids while migrating that contract. Now, I am doing the mapping of user id ...
0
votes
0answers
87 views

Truffle error during migration

I am getting an error when I run : truffle migrate --network production Error Running migration: 1_initial_migration.js Deploying Migrations... ... ...
0
votes
0answers
41 views

Can the result of a call trigger the execution of a transaction?

Supposing I have a transaction (A) = a call (B) + other storage operations (C). Executing A, beeing a transaction, I have to pay the gasUsed by B and C. Beeing B an expensive call and since I need the ...
0
votes
1answer
634 views

Error: VM Exception while processing transaction: out of gas - Truffle

I'm facing some issue with test cases, I wrote some simple function in my smart contract as following: function Create ( bytes32 _a, address _b, string _c, address[] _d, uint256[]...
0
votes
1answer
105 views

Truffle error: Recipient address error

Whenever i run truffle migrate for any contract i get the following error: Error: Attempting to run transaction which calls a contract function, but recipient address ...
0
votes
1answer
488 views

Import error in Truffle Pet Shop tutorial

I'm executing an example in the Truffle Pet Shop tutorial. While testing with file TestAdoption.sol, I have encountered the following error: Source truffle / Assert.sol not found The source code ...
0
votes
0answers
45 views

How to .endSale from a contract?

I am writing a smart contract for a token sale. How can I endSale destroy contract and transfer remaining tokens and accumulated ethers from the sale to admin wallet ( using truffle commands)? I ...
0
votes
1answer
434 views

how to replicate bytes32 to uint256 conversion in javascript

I am attempting to replicate a bytes32 to uint256 conversion in nodejs. I would like to get the same result as this example contract pragma solidity ^0.4.23; contract TestContract { bytes32 ...
0
votes
1answer
262 views

How to deploy smart contract to main ethereum network

I am tring to deploy our ERC20 token in main net it gives an error Error: exceeds block gas limit. First I download or sync whole blockchain using geth command ( geth --syncmode "fast" --rpc --rpcapi ...
0
votes
0answers
106 views

Unable to deploy contract on Ropsten network

When I try to migrate contract to Ropsten Network (truffle migrate --network ropsten) it keeps migrating the contract on the net with id 4447 unless Ropsten is the only network configured in truffle....
0
votes
1answer
153 views

Accessing struct properties from a contract returns hexadecimal strings

I have a simple contract that has a setter and getter for a struct called Institution. I have removed most of the properties am using, to simplify the question. pragma solidity ^0.4.22; contract ...
0
votes
1answer
146 views

Truffle Test: How to send ether to a contract from a contract?

Would like to test the modifier below modifier isNotAContract(){ require (msg.sender == tx.origin, 'Contracts are not allowed to interact.'); _; } How can I invoke a function using this ...
0
votes
1answer
260 views

geth + truffle-hd-wallet accounts not listed properly

I have setup a latest single node geth for my learning. I am also using truffle-hd-wallet in my app. While in my app i do not get the correct coinbase account on using 'web3.eth.getCoinbase()'; the ...
0
votes
1answer
249 views

Solidity: VM Exception while processing transaction: invalid opcode - What happens?

If VM Exception while processing transaction: invalid opcode is thrown, does it have the same effect than revert?
0
votes
1answer
363 views

Contract not using Upgraded Proxy Contracts

There's 2 contracts A and B, A imports B, where B is a library that can be upgraded. To achieve this, I tried replacing B with a proxy contract and a delegate contract. We now have contracts Foo, ...
0
votes
1answer
128 views

Transaction reverted when testing requires/asserts in non void functions

im trying to test the requires of a Smart Contract using just solidity according to this article: http://truffleframework.com/tutorials/testing-for-throws-in-solidity-tests This is the contract, the ...
0
votes
1answer
333 views

SenTransaction can't send Ether to a contract address

I am using openzeppelin, Ganache and truffle, here's a very simple smart contract for fundraising: pragma solidity 0.4.24; import 'openzeppelin-solidity/contracts/crowdsale/Crowdsale.sol'; contract ...
0
votes
1answer
409 views

Compare byte32 Keccak256 to the same Keccak256 stored in a byte32 array

I want my function to be able to accept an array of Hashed secrets as a parameter and since solidity doesn't allow for strings, I had to use a byte32[]. The string parameter is an intake for the user'...
0
votes
0answers
461 views

Ubuntu 16.04: Truffle: command not found

I installed the truffle on my Ubuntu machine and it installed successfully but when i am trying to execute truffle commands it is saying; truffle: command not found I tried the solution mentioned in ...
0
votes
1answer
49 views

on deploy MultiSigWalletWithDailyLimit: Error VM Exception while processing transaction: revert

I'm trying out a very simple js script through truffle to create the Gnosis multisig wallet on a local testrpc net. However it always fails. JS deploy file: const MultiSigWalletWithDailyLimit = ...
0
votes
2answers
172 views

How is gas price too low corrected (truffle deploy)?

truffle.js module.exports = { networks: { development: { host: "127.0.0.1", port: 8540, network_id: "*", gas: 4600000, gasPrice: 4000000 // Match any network id } ...
0
votes
1answer
162 views

How to solve eth_getFilterChanges looping when deploying with truffle (parity)?

I am using truffle migrate and I get some kind of loop which just endlessly prints out eth_getFilterChanges. How can this be solved? I have used this truffle.js module.exports = { networks: { ...
0
votes
1answer
666 views

How to deploy a contract to parity using truffle?

I get this when trying to deploy to parity - Writing artifacts to ./build/contracts Invalid JSON RPC response: "Provided Host header is not whitelisted.\n" I am new to using truffle with ...
0
votes
1answer
50 views

Gas amount to store a contract?

i'm trying to run truffle migrate and it gives me always this error. Error: The contract code couldn't be stored, please check your gas amount. MBP-de-Alicia-2:smartContracts alicialombarte$ truffle ...
0
votes
1answer
143 views

I am getting error while i deploy my smart contract to ropsten test network(The same project successfully deploy on rinkeby test network) [duplicate]

This is the Project I am getting error while i deploy my smart contract to ropsten test network(The same project successfully deploy on rinkeby test network) it is the error ~/Voting-Application/...
0
votes
1answer
340 views

ERC20 TestToken code returns 0 for allowance after approval [duplicate]

I have the following code in my testtoken.js and am wondering why the assertion fails with "AssertionError: allowance wasn't set to 30: expected '0' to equal 30". it("Approve an allowance of 30 ...
0
votes
0answers
77 views

Why account balance can decrease when gasPrice is 0 and msg.value is 0?

It also spends pretty large amount, which doesn't seem to be related to gasUsed Contract: pragma solidity ^0.4.24; contract Test { bool i; function hello() public { i = true; } }...
0
votes
0answers
62 views

Truffle contract compilation from STDIN or something like this

My contracts have some methods that used only for testing i.e. exposes some internal contract data and I do not want to deploy it to live network. for now Solidity does not supports C-style ...
0
votes
0answers
114 views

not able to fetch bool value from contract using truffe

Index.html: <input id="txtUser" type="text" placeholder="Enter user name" /> <button id="btnAuthenticate" onclick="App.Authenticate()">Authenticate</button> contract: function ...
0
votes
1answer
2k views

Truffle Error : VM Exception while processing transaction: revert

I am trying to call following function of smart contract from App.js: function addCandidate(bytes32 _name, bytes32 _party) public{ //require(msg.sender == votingAdmin); //if(msg.sender != ...
0
votes
2answers
693 views

Error: VM Exception while processing transaction: revert: When trying to migrate a truffles initialised contract?

I'm trying to migrate/deploy a multi-signature contract through truffles, I am receiving "Error: VM Exception while processing transaction: revert" when the contract starts to migrate/deploy. ...