Questions tagged [truffle]

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

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

TypeError: tokenInstance.balanceOf is not a function

It happen when use truffle test, here my contract file: pragma solidity ^0.5.0; import "./DappToken.sol"; contract DappTokenSale { address payable admin; DappToken public tokenContract; ...
0 votes
1 answer
385 views

Do I need to front the cost of gas to sell a collection of NFTs

Forgive me if this has been asked before, if it has please provide any resources so I can learn more! I'm having trouble wrapping my head around the development process of creating an NFT.Say I want ...
5 votes
1 answer
691 views

Truffle test fails to call the base function, wants the override

I have an extended ERC20 contract with ERC827 functions, which are overrides of ERC20 with an extra callback parameter. I have these two pairs of base/override functions: Base: function ...
2 votes
1 answer
452 views

Dapp using react-native and truffle

I have a blockchain dapp which is working fine in web browser. Wallet : Metamask OS : Ubuntu 20 Node : 10.19.0 Npm : 6.14.4 But, I would like to run the dapp in mobile view using truffle ...
0 votes
1 answer
644 views

Could not find artifacts for " + import_path + " from any sources

I'm working through a Solidity course on Udemy. I'm trying to run migrate on truffle. Here's my code: MyToken.sol // contracts/GLDToken.sol // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; ...
0 votes
0 answers
10 views

One of two contracts not migrating to truffle ganache

I was trying truffle in vscode and using a sample program HelloBlockchain that comes with it. I created a new test.sol file , created its migration and script files similar to the ones HelloBlockchain ...
1 vote
1 answer
2k views

Truffle migrate got stuck

Issue I ran the official example code: truffle migrate,and stuck there for a long long time: truffle migrate Running migration: 1_initial_migration.js Deploying Migrations... Steps to Reproduce I ...
3 votes
1 answer
1k views

Passing one contract instance as an argument to the constructor of another contract

I need to use the functions of the ERC20 contract in another contract. The ERC20 contract is from the openZeppelin contract library. I found the following code on a website: import "../../...
2 votes
1 answer
592 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 ...
1 vote
1 answer
572 views

Solidity test fails when testing onlyOwner functions

I have a contract where some functions can be called only by the owner of the contract and I want to test it with a solidity test in truffle. The contract looks like this: contract owned { ...
0 votes
1 answer
1k views

How can I make sense of solidity-coverage reports

I'm trying to check the coverage of an entire ERC20 set of openzeppelin tests. I'm using openzeppelin/test-environment and solidity-coverage v0.7.4 as plugins in truffle. The tests went fine but I get ...
1 vote
1 answer
475 views

I tried to deploy a contract on Ropsten, but always get the following error

PS D:\nodejs\rff\metacoin> truffle --network ropsten migrate Using network 'ropsten'. Running migration: 1_initial_migration.js Deploying Migrations... Error encountered, bailing. Network state ...
0 votes
1 answer
916 views

Fund my Ropsten account to deploy my contract

I have a full geth node on my machine and I want to deploy my contract on Ropsten using truffle. How I can fund my coinable account with some ether to deploy my smart contract? I have tried fuusent....
0 votes
1 answer
954 views

Source "truffle/Console.sol" not found: File import callback not supported

after install truffle -g try to run console.log by import "truffle/Console.sol" from https://github.com/trufflesuite/truffle-logger-example get error on import line - not found. how can i ...
0 votes
4 answers
459 views

Error: Private key does not satisfy the curve requirements (ie. it is invalid)

I have a project working fine on truffle but when migrating to Kovan network, Getting the issue "Error: Private key does not satisfy the curve requirements (ie. it is invalid)" project is an ...
0 votes
1 answer
564 views

Cannot swap eth for exact tokens: TransferHelper: ETH_TRANSFER_FAILED

I can't swap eth for exact tokens because of the error... Error: Returned error: VM Exception while processing transaction: revert -- Reason given: TransferHelper: ETH_TRANSFER_FAILED. The code, I ...
0 votes
1 answer
709 views

Returned error: VM Exception while processing transaction: revert when i use UniswapV2router functions

I'm using my owned cloned UniswapV2 smart contracts(core+periphery) and deployed them using ganache network, so when i start testing functions, i started with createPair() function located in ...
1 vote
1 answer
343 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
7 votes
2 answers
1k views

Unit testing a Solidity Library function with a struct memory argument

I am trying to unit test a Solidity Library contract function using truffle and web3. My simplified Library contract looks like this: pragma solidity >=0.5.16; pragma experimental ABIEncoderV2; ...
0 votes
1 answer
548 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
2 answers
1k views

Using hardhat with Windows

Can anyone break down how to successfully set up a hardhat project on windows? I keep running into the HH12 error: "Error HH12: Trying to use a non-local installation of Hardhat, which is not ...
0 votes
1 answer
938 views

Truffle console showing irrelevant balance irrelevant BN{ negative: 0, words: [ 16777216, 62077800, 20718012, <1 empty item> ], length: 4, red: null }

I'm using ganache network, truffle network, web3, chai and mocha. while using truffle console in terminal it shows: truffle(develompment)> balance BN { negative: 0, words: [ 16777216, 62077800, ...
1 vote
1 answer
306 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
2 answers
1k views

Error: Cannot find module 'ethereumjs-wallet'

A truffle test needs ethereumjs-wallet const wallet = require('ethereumjs-wallet'); I tried npm install ethereumjs-wallet and even npm uninstall ethereumjs-wallet npm install --save ethereumjs-...
0 votes
1 answer
597 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
1 answer
717 views

How to deploy a truffle built Dapp

I've completed my truffle Dapp, the contracts are deployed to the Ropsten test network and my web code talks nicely to them, it works great from http://localhost:8080/ when I do an npm run dev. I now ...
8 votes
7 answers
10k views

Change truffle develop port

When I run truffle develop it starts a testnet listening at localhost:9545. Is there a way to change the port this testnet is running on? EDIT: I'm not looking for a way to configure which network ...
2 votes
3 answers
749 views

Windows Ganache GUI not taking updates from Truffle running on WSL2

I have added truffle workspace to Ganache as usual. But now when I do a simple truffle develop followed by migrate inside the truffle shell, Ganache picks up that the contracts are deployed, but it ...
1 vote
1 answer
2k 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
2 answers
404 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
0 answers
19 views

Truffle ganache debug not working

I have installed truffle and ganache and the @ganache/console.log library. Furthermore, I have the following contract from an online course which serves as an example to demostrate the debug mode of ...
0 votes
1 answer
695 views

Truffle Migrate Error: Could not find built Migrations contract: Unexpected token in JSON at position 0

Running truffle migrate with valid contract code started causing this error for me: Writing artifacts to ./build/contracts Using network 'development'. Error: Could not find built Migrations ...
0 votes
2 answers
397 views

How to use cacheSend of drizzle library when the method needs two parameters

Should it be like the example below(2,2 as two different parametres) Ex: const stackId = drizzle.contracts.SimpleStorage.methods.set.cacheSend(2,2, {from: '0x3f...'})
1 vote
1 answer
742 views

Uncaught ReferenceError: global is not defined using Truffle's MetaCoin tutorial (truffle develop)

I'm using truffle develop to interact with the MetaCoin tutorial contract. I've done this before months ago on an older version of truffle and this worked fine. But now, I'm getting the same error ...
0 votes
1 answer
840 views

Error linking solidity smart contract with React frontend

I'm trying to link my smart contract to a boilerplate react frontend as follows: import React, { useState, useEffect } from "react"; import MyContract from "./contracts/MyContract.json&...
0 votes
2 answers
556 views

How to detect what instruction caused "truffle test" to result in "invalid opcode" error?

I wrote a test for my contract and it returns invalid opcode as a result. Full output: 1) Contract: FPCoin1 One can purchase tokens for ether: Error: VM Exception while processing transaction: ...
0 votes
1 answer
1k 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
1 answer
437 views

Error: Returned error: sender doesn't have enough funds to send tx. The upfront cost is: xxxxxxxxx and the sender's account only has: xxxxxxxxxxx

I'm trying to run a huge test suite(around 50 test cases) using Truffle and after around 18-20 test cases pass I'm getting this error for the remaining test cases. The tests seem to be running fine ...
0 votes
1 answer
445 views

Truffle Test Console Logging

I'm having some trouble with Truffle logging configuration. During tests, each submitted transaction and its hash is logged on the console and this one becomes full of useless messages that disturb ...
1 vote
1 answer
6k views

gyp ERR! stack Error: `C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin\MSBuild.exe` failed with exit code: 1

I used the command truffle unbox react to build a dapp. It is just the initial step of my dapp development. However, it sucks. It continually pops up gyp ERR! build error gyp ERR! stack Error: `C:\...
1 vote
1 answer
1k views

How to get the returned value of a smart contract function when it called by using cacheSend() in drizzle

I just tried to build a simple DApp using truffle, react and drizzle. My question is how to get the returned value of a smart contract function when it called by using cacheSend() in drizzle? As ...
0 votes
1 answer
439 views

ERC721 is being minted to null address

Here is the contract code to mint ERC721 tokens: contract NFT is ERC721URIStorage, Ownable { mapping(uint256 => address) private _owners; mapping(address => uint256) private _balances; ...
0 votes
2 answers
854 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
1 answer
609 views

How do I dynamically set in my Web3.js file the deployed smart contract's ABI & address?

I'm using Truffle, Solidity, Web3.js, and Ganache. Whenever I deploy a smart contract, I have to copy and paste the new ABI & address of the contract. How can I dynamically change the value so ...
0 votes
1 answer
441 views

TypeError: Cannot read property 'nodes' of undefined

I'm new to ethereum, and I'm trying to test the depositToken function of etherdelta on linux, which version is 0.4.9, and the token I use is vixcore which version is 0.4.24, and I got this error when ...
2 votes
3 answers
1k views

What is the Chain ID for Metamask associated with truffle develop?

I was following a tutorial but found out that it is outdated. Inputting 'truffle develop' in bash states that it started on "http://127.0.0.1:9545/." However, when I try to connect Truffle ...
0 votes
3 answers
757 views

Can't compile Truffle project that imports a .sol with different pragma version

I have a contract pragma solidity 0.6.12 version that imports several 0.6.12 version contracts and one pragma solidity 0.8.0. My truffle-config: compilers: { solc: { version: "^0.6.12 &...
0 votes
2 answers
2k views

Metamask TestRPC shows 0 Ether while connecting to Ganache- CLI

I've gone through various Q/A(s) of the problem of ganache-cli and metamask not linking but after trying all the solutions, still doesn't work for me. As soon as I type ganache-cli in windows cmd ...
0 votes
2 answers
2k 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 ../...
0 votes
1 answer
616 views

Truffle config gas price confusion

I'm doing a dry run of a mainnet to get the total gas cost/ Replacing 'Migrations' > Total cost: 0.000343902 ETH Replacing 'EthText' > Total cost: 0.001205478 ETH Summary =====...

1
2 3 4 5
59