Questions tagged [truffle]

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

0
votes
1answer
138 views

Drizzle component returns BigNumber

I am using the following Drizzle (Truffle) component to call a function from a smart contract: <ContractData contract="Market" method="priceOf" methodArgs={this.props.id}/> The result is a ...
1
vote
1answer
45 views

openzeppelin,VM Exception while processing transaction: revert

using openzeppelin-solidity to create crowdsale. Then I use this statement to Buy Token: MyCrowdsaleInstance.sendTransaction({ from: purchaser[1], value: web3.utils.toWei("0.5", "ether"), ...
0
votes
1answer
204 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
2answers
220 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 => { ...
1
vote
1answer
162 views

How do I deploy a contract via a contract factory in truffle?

The code below does not set the simpleStorage instance's value to 55, but identical code works when the contract is not generated via a factory
0
votes
0answers
18 views

What is best way of setting and getting string=>uint pairs in Solidity?

I am developing a game smart contract and it has 20 numerical settings. like time, fee, difficulty etc I want to access these values using identifier throughout contract get all these values from ...
1
vote
1answer
34 views

Invalid number of parameters for “ ”. Got 0 expected 2!

I have the function below which doesn't take any arguments when i call it from truffle console i get the below error, any idea on how i can fix this: uint ownerCounter = 0; function ...
0
votes
1answer
12 views

truffle won't run tests while initializing a global contract instance

I am testing my smart contract in truffle. I need to declare some global variables hence I did so outside 'it'. I also tried declaring a global contract instance that I can use in all test cases. ...
1
vote
1answer
11 views

truffle pet shop example - metamask connects but adopt button not working

I am having some trouble with getting the adopt button to work in the truffle pet shop tutorial: https://truffleframework.com/tutorials/pet-shop I have worked through the truffle petshop example ...
0
votes
0answers
29 views

Unknown network “ganache”. See your Truffle configuration file for available networks

I am working windows 10 and have both truffle.js & truffle-config.js I am using command truffle migrate --reset --networks rinkeby Error produced: Unknown network "ganache". See ...
0
votes
0answers
21 views

How to use the address.transfer(amount)?

Using this smart contract, I want to transfer from one account to another. Here is my simple smart contract : pragma solidity ^0.5.0; contract Subtract { address payable public minter; uint ...
0
votes
1answer
162 views

Why does the transaction stay in queue from more than 240 second

I am running quorum nodes via the Quorum-maker script, and when trying to call functions from my already deployed smart contract, I get this error : Transaction ...
0
votes
1answer
195 views

How to chain functions in truffle framework?

I am wondering how to chain functions in truffle testing framework to avoid writing the same code twice. To give an example, I am experimenting with the old version of King of the Ether Throne ...
0
votes
1answer
224 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
1answer
185 views

which wallet is usable with ganache test-rpc?

I tried metamask, but unable to send ether between accounts because metamask is trying to estimate gas and gets stuck :( myetherwallet doesn't save my seed so I need to enter it all the time
12
votes
4answers
7k views

“SyntaxError: Unexpected token import” on truffle test

I get an "SyntaxError: Unexpected token import" error when I do 'truffle test'. I am trying to import a function declared in another file into the java-script test file. I have been searching about ...
0
votes
1answer
156 views

Program for interacting with deployed contracts via a GUI?

So I've deployed a contract to Rinkbey using truffle, and now I'd like to play with it. I'd like something that builds a GUI for me from the ABI like EthFiddle does. I just want something that lists ...
0
votes
0answers
12 views

Testing a Smart Contract on two different devices at the same time

So the goal is to have two computers each owning one account or just different addresses on MetaMask for example and connecting them to the same Smart Contract that is deployed on Rinkeby. Now how ...
0
votes
0answers
12 views

Execute `transferFrom` after executing `approve` on erc20

I can not withdraw from adress specified by approve. truffle(development)> erc20.approve("0x9e26730bf972d6ae8840b8f6003a61f57e25ff92", 1).then(b=>res=b) { tx: '...
1
vote
0answers
23 views

How to obtain the msg.sender in truffle console?

Here is my code snippet to return the msg.sender: function showSender() public view returns (address) { return (msg.sender); } But when I try to call this function using this: Coin....
0
votes
1answer
246 views

Deploying new contract inside truffle test case

I was trying to transact between two contracts inside my truffle test case. But not been able to do it. The second contract instance comes back undefined always. As per the truffle documentation, ...
0
votes
0answers
37 views

Hoiw to convert string to address with web3

I am getting address value with html input as string value how do we convert the string to address for parsing with truffle-contract. Here's the method I am using: registerAirline : async() => {...
0
votes
1answer
29 views

Calling Smart Contract function returns tx object instead of expected return value in Truffle test

I have started writing a smart contract for a gift registry. When I write tests using the Truffle Framework I get unexpected return values. For example, when calling the offerGift function from ...
0
votes
2answers
387 views

Running solidity-coverage with truffle gives error: can not find 'coverageEnv/migrations'

Running solidity-coverage gives the following error: $npm run coverage ... Writing artifacts to ./build/contracts Launched testrpc on port 8555 Running: node --max-old-space-size=4096 ../...
1
vote
1answer
21 views

How does a Truffle migration know the address of a contract before it is created?

How does the truffle migration of this contract know what the address is of the registry contract, in the constructor: https://github.com/marbleprotocol/humanity/blob/master/contracts/Humanity.sol ...
0
votes
1answer
69 views

How do I overcome the problem of gas limit?

Here is my genesis.json file { "config": { "chainId": 1994, "homesteadBlock": 0, "eip155Block": 0, "eip158Block": 0, "byzantiumBlock": 0 }, "...
1
vote
1answer
48 views

truffle unbox react - front end is unable to read / set state of the contract

I am experiencing problems with the Truffle React boilerplate code that the front end is unable to read / set state of the contract. Here are the details: I unboxed the React boilerplate using ...
0
votes
1answer
35 views

How I can generate a file.sol from ABI?

I have created an smart contract but the code in the sol file have disappeared. But the jeson file still remains. Can I generate my smartcontract again from ABI ?
1
vote
1answer
22 views

Getting the transaction hash on function call

I am new to Solidity, Web3, and Ethereum. I am trying to build a web application through which users can upload a file to IPFS, then store the IPFS hash in the blockchain. I am using the React truffle ...
0
votes
1answer
219 views

Truffle “Replacing” durring migration

what does "Replacing" mean in migration? a simple test contract C.sol: pragma solidity ^0.4.17; contract C{ uint public ConstructorUint; function C(uint SetConstructorUint)public{ ...
0
votes
1answer
26 views

How we can integrate truffle with Jenkins?

is it possible to add truffle on Jenkins pipeline?
0
votes
1answer
33 views

Quorum 7nodes example unable to finish simplestorage migration using privateFor

I'm following this example: truffle quorum example I created a cluster using docker-compose and all the nodes are up and running but when I run the truffle migrate command the migration doesn't end ...
2
votes
1answer
186 views

How do I get access to uPort from a mobile Browser

I've developed a simple DApp that uses uPort and it works fine on Desktop - where I can login through uPort with the QR Code. On a mobile browser (Anrdoid Chrome) I'm auto directed to uPort where it ...
1
vote
1answer
199 views

Exceeds block gas limit error to call view functions

With solidity view function, you can specific the amount of gas to use. My understand is since it is not a state changing transaction, all the gas cost is not charged for, and the client should be ...
2
votes
1answer
262 views

Pending transactions are not mined

Preconditions I'm running a private network with Geth, having custom smart contracts deployed by Truffle and a simple frontend which using Metamask as a provider to connect the network. Versions ...
0
votes
3answers
38 views

Solidity Compatibility Configuration

I am a cyber security analyst who is new to ethereum and working on a project to study crypto security. It's a series of 22 vulnerable smart contracts that you're supposed to exploit. For anyone who ...
1
vote
1answer
194 views

No output when writing data to IPFS and storing its hash through Solidity

So I am using truffle. Following from Creating a form in IPFS for users to enter data [check the code in answer], doing some changes: Contract name - IpfsContract.sol test.js uses the following JSON ...
0
votes
1answer
24 views

Why Could not find artifacts for contract from any sources

I am using windows 10 with truffle and ganache-cli. I have 2 contracts file to be deployed contain interfaces of other contracts defined within the contract: Contracts: ERC721Mintable.sol Ownable ...
0
votes
0answers
56 views

Web3 Cannot read property 'apply' of undefined

I'm new to dapp and trying to follow iwaldman to build an ipfs-image-dapp. Here is the repo: https://github.com/iwaldman/ipfs-image-dapp. But running yarn start gives the error Cannot read property '...
0
votes
1answer
21 views

truffle testing enum

I am trying to test an enum value from a test. This is simplified version of the contract: pragma solidity >=0.5.0 <0.7.0; contract Foo { enum State { StateA, StateB } State ...
0
votes
1answer
259 views

Can I find constructor arguments from truffle artifact?

I'm in the process of verifying my contract on Etherscan. Etherscan asks for ABI-encoded constructor arguments during the verification process, though I was a bit silly and don't quite know what they ...
1
vote
1answer
196 views

Truffle test case to unit test withdrawal pattern

How can I test the withdraw() function in a truffle javascript test case for the below contract? The problem is, If I use the msg.sender from the same contract, the before and after balance will be ...
1
vote
1answer
2k views

How to get contract instance address for Web3 1.0 contract API?

With truffle-contract, all you needed to do to get the contract instance was something like this: const getContract = require('truffle-contract') const contractJSON = require('./MyContract.json') ...
0
votes
2answers
534 views

How to access Truffle deployed contracts with app's javascript code?

I have some smart contracts deployed with Truffle on the local Ganache network, but I don't know how to access it with the app's javascript in order to make function calls to the contract. How would I ...
0
votes
2answers
34 views

find the bytecode of a contract during compilation

Is there a solution to recover the complete bytecode (init + runtime) of a contract imported in solidity. For example "bytes code = getBytecode (Escrow.sol)" and this would be replaced by bytecode ...
0
votes
1answer
252 views

Comparing msg.value using javascript test always fails

So I have this solidity function: function claimGoodTest(uint256 typeId) public payable { if (msg.value < 4000) revert(); } I test it with the following: var result = await contract....
0
votes
1answer
187 views

How can I use truffle to deploy my contract to a local testnet (not testrpc)?

I followed the steps in the following link to create a local Ethereum testnet, but now I want to deploy a contract to "MyTestNetNode": https://medium.com/@WWWillems/how-to-set-up-a-private-ethereum-...
1
vote
2answers
989 views

Identifier not found or Not Unique testing contract truffle

Created a simple HelloEthereum.sol contract: pragma solidity ^0.4.17; contract HelloEth { string message; function HelloEth() public{ message = "Hello Ethereum!"; } ...
3
votes
1answer
51 views

Ganache + Truffle: how to deploy a contract without considering the gas

I am working with Ganache and Truffle. I am trying to deploy kind of a huge smart contract, but most of the functions in this smart contract are pre-prod functions, so I do not really worry about real-...
0
votes
1answer
177 views

Loading truffle library in remix browser IDE

Besides writing smart contracts in the browser, I would also like to write my test in this IDE. Any suggestions how to load the truffle files in http://remix.ethereum.org? I appreciate your help!