Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
0
votes
1answer
68 views

Truffle beta Contract.at is supposed to be a promise

I'm trying to test a contract with Truffle beta (because of the new web3 1.0.0 support). When i try to create the contract object by using Contract = artifacts.require("Contract"); contract = ...
0
votes
1answer
239 views

Vyper: Truffle test read mapping value inside struct

I have the following struct inside my vyper file: races: public({ start: timestamp, end: timestamp, racersBetHash: bytes32[address], racersBetAmount: wei_value[address] }[int128]) Then I ...
0
votes
1answer
223 views

JS Testing and Web3 referencing contract at deployed address

I have a Contract Factory and a sub contract, and now i want to test the newly created sub contract. This one should be pretty simple, I hope. it("test CoinNewCoin - Test Created Coin ", function (){...
0
votes
2answers
875 views

Deploying on Rinkeby with Truffle using infura

If I want to use HDWalletProvider to deploy my contract on a specific address, what should I do? rinkeby: { provider: () => { return new HDWalletProvider("Mnemnoic", "https://ropsten.infura....
0
votes
1answer
48 views

Why is gasestimate coming as “infinite” when I'm trying to return a dynamic array in solidity?

I understand, that as the list grows it is going to cost infinite gas. I'm making a temp array in memory of size of our dynamic array at present size and then returning that array. But does that make ...
0
votes
0answers
171 views

Unable to run test cases truffle

I am using truffle tests for my smart contract.I guess there is no problem with contracts because I can compile and deploy them in Remix. I can also run truffle migrate --reset successfully, and it ...
0
votes
1answer
641 views

Truffle Exec Gets Stuck [closed]

I want to exec a script in the truffle console. script const artifacts = require('./build/contracts/Message.json') const contract = require('truffle-contract') const Message = contract(artifacts); ...
0
votes
2answers
918 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
270 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
3answers
326 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
159 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
170 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
559 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
186 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
556 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
187 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
69 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
253 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
645 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
142 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
488 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
96 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
419 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
65 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
637 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
3answers
153 views

Error in the truffle init command, quorum

i'm trying to truffle a project but each time it shows me this message, whereas, i'm sure i installed the truffle successfully. vagrant@ubuntu-xenial:~/quorum-examples$ cd project vagrant@ubuntu-...
0
votes
1answer
573 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
47 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
484 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
272 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
107 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
156 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
153 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
268 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
252 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
372 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
131 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
367 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
427 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
478 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
52 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
180 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
164 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
685 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 ...