Questions tagged [truffle]

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

Filter by
Sorted by
Tagged with
0
votes
0answers
100 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
402 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
652 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
208 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
23 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
1answer
79 views

Error using web3.js from OpenZeppelin

Please, i need help. I am using truffle to test a smart contract. I run "truffle develop", then "migrate". The contract has been stored in the network. Then I run the command "test". An error occurred:...
0
votes
2answers
248 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
80 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
124 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
61 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
261 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
129 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
426 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
128 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
1answer
98 views

Why does triggering a send on a contract method work, while call doesn't?

I'm still somewhat new to web development and solidity, so do correct any of my misunderstandings. I've been working with web3 on the front end, but now I'm trying to set up a server side web3 ...
0
votes
0answers
55 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
144 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
350 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
130 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
433 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
66 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
232 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
39 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
31 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
83 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
38 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
603 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
101 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
290 views

Error when testing smart contract - use truffle and solidity

I'm executing a example in this link. https://truffleframework.com/tutorials/pet-shop While testing testing with file "TestAdoption.sol", I have encountered the error "Source truffle / Assert.sol not ...
0
votes
0answers
33 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
326 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
242 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
100 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
135 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
138 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
228 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
212 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
298 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
104 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
65 views

Solidity Test - which are the variables and keywords over here

Can anyone help me in understanding what is happening over here? I understand that the contract name is TestAdoption, but after that - what is the first word "Adoption"? The second word "adoption". I ...
0
votes
1answer
233 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
324 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
391 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
43 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
143 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
147 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
590 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
47 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
133 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
221 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 ...