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
22 views

problem with the truffle develop command

I am trying to use the "truffle develop" command but it does not work. I get this error message below. It seems to say there is a problem in the truffle-config file but there is no error. Do ...
0
votes
1answer
26 views

JS Testing: A contract calling a function in another contract which creates a contract

I want to test three contracts in total: Main.sol, Factory.sol, PCE.sol Here's the flow I want: accounts[0] calls factoryStart in Main.sol Main.sol should call a function in Factory.sol, passing the ...
0
votes
2answers
13 views

How to get token address inside a crowdsale contract, if you create separate migration files?

To expand on the question, I have created an erc20 token contract, & a crowdsale contract. For each file, I intend to create separate migration files. How can i get the token address for reference ...
0
votes
1answer
20 views

TypeError: value.forEach is not a function when calling a function

I am using Truffle to deploy a contract on Ganache and retrieve the contract in an express app. While I can get the contract instance and it can console.log a list of function object, the function ...
0
votes
0answers
25 views

My smart contract works properly on Ganache network but not on Ropsten [closed]

I have a smart contract that is fully tested on ganache network through truffle. The contract implements a trade system where there are two main functions namely invest() and withdraw(). When I test ...
0
votes
0answers
23 views

Timeout while attempting to connect and deploy in the Ropsten network

I am trying to deploy the contract in Ropsten network. It fails with the timeout error The same is deployed in Ganache without any issues. Please advice truffle-config.js require('dotenv').config(); ...
0
votes
0answers
12 views

amount of gas used in receive and fallback functions in truffle tests

I have a contract that is written in solidity ^0.6.4 and has a simple implementation of reverting funds when someone directly transfers some eth or calls an unhandled function. Now it appears to be ...
3
votes
4answers
156 views

The endpoint returned a different chain ID: 0x539 (Ganache)

I am trying to connect Metamask to ganache by creating a custom RPC with the following details: New RPC URL: HTTP://127.0.0.1:7545 Chain Id: 5777 But I keep getting the error message The endpoint ...
0
votes
1answer
15 views

Pass mapping as constructor parameter

I'd like to save the contract addresses from DAI and UNI into a mapping when calling the smart contract constructor depending on the network. Below is a minimalistic example that works fine: contract ...
0
votes
1answer
12 views

Truffle test: getting Transaction Object instead of uint result

I have a method in my contract like so: mapping(address => uint256) allowance; ... function setAllowance(address user, uint256 amount) external onlyOwner nonReentrant returns (uint256) { ...
0
votes
1answer
13 views

Deploying multiple contracts with different solc versions

I have a few contracts that I deploy with my 1_initial_migration.js. However some of them are of different solc version than others. Is there a way to change it programmatically before compiling and ...
0
votes
0answers
15 views

How to Load JSON Build of Solidity Contract into Javascipt

I'm thinking there's gotta be a way to load the abi (or the entire JSON build file) of a smart contract into my front-end Javascript app after compilation automatically - meaning via some kind of ...
0
votes
1answer
23 views

How to call a function in a smart contract from Truffle (or anywhere else)?

PSA: I'm new to Solidity/Truffle and I'm hoping you guys won't be too harsh on me I'm trying to figure out how call a function that only the smart contract owner can call. The reason why I want to do ...
0
votes
1answer
31 views

How to get event log Web3.py?

I am using solidity 0.7.4, web3.py 5.12.2, and python 3.7. I am working with Windows 10. My goal is to emit an event inside a solidity function, in order to retrieve the log after the function is ...
0
votes
0answers
9 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
1answer
36 views

Implementing Chainlink Data in Truffle / Hardhat

What is the easiest way to connect with Chainlink so we can test our dApp locally. Do we have to run a local Chainlink node, or is there any workaround for getting the online data?
0
votes
0answers
8 views

how to verify a contract using truffle-plugin-verify

I'm trying to verify a simple contract. The contract is already deployed on the Ropsten network. import "@openzeppelin/contracts/access/AccessControl.sol"; import "@openzeppelin/...
1
vote
1answer
25 views

Truffle Test: Simply comparing BigNumber to String works, but WHY?

Reading from this post, one should not use toNumber() when working with uint256, so when writting the below test, I was expecting it to crash, but it does not, instead it runs to success! why ? it(&...
0
votes
0answers
19 views

Not Able to create 1 ERC 20 tokens with 18 decimals of my own using code provided from open zeppelin truffle

I am trying to create my own ERC 20 token but I ran some issue with openzepelin code. Here is the code var SampleToken = artifacts.require("SampleToken"); module.exports = function(deployer)...
1
vote
1answer
26 views

Truffle ganache fork

Suppose I have access to a full archive Node and I want to fork from a specific block using Ganache. Using ganache-cli, I can specify where to fork using the --fork parameter by passing it the Node ...
0
votes
0answers
23 views

Truffle returns no code at address after contract update

etherjs (5.0) is used to deployed a smart contract Hello.sol. Here is the js code (truffle 5.1.52/ganache CLI 6.12.1): import { ContractFactory, ethers } from "ethers"; let privateKey = ...
1
vote
0answers
12 views

Deploy contracts without deploying Migrations

I would like to deploy my contracts to mainnet using truffle. I figure it's the easiest and safest way to do it since I already deploy to testnet using truffle. The problem is I don't want to deploy ...
0
votes
0answers
20 views

Slither Error: Invalid compilation: Solidity version not found ['']

I work with Truffle Fluidity to get an analysis on my contract. My contract is in contracts file that Truffle determines that. I preformed all steps that Truffle mentioned in document. I work with ...
0
votes
1answer
18 views

Truffle doesn't see the smart contract deployed on ganache

etherjs (5.0) is used to deployed a smart contract Hello.sol. Here is the js code (truffle 5.1.52/ganache CLI 6.12.1): import { ContractFactory, ethers } from "ethers"; let privateKey = ...
1
vote
1answer
12 views

truffle command line version older than it is in package.json

After installing Truffle with yarn add truffle, the following line shows up in package.json: "truffle": "^5.1.52" In the root directory of the project, the truffle version ...
0
votes
2answers
25 views

Resolve solidity compiler error

I am trying to create a smart contract and I am using ganache, visual studio code and truffle for that purpose. The versions installed in my windows system are: Truffle v5.1.49, Solidity v0.5.16 (solc-...
1
vote
1answer
12 views

What is the easiest way to interact with your contract in a development environment?

Is there some form of toolkit which generates a console similar to the one on etherscan, where you can call functions that are defined in your contracts ABI? It seems quite painful having to write the ...
0
votes
0answers
31 views

Error: Contract not deployed after cloning private geth network from one server to another

Steps to reproduce: Private geth network is running on server1. Deploy contract using truffle and make a few transactions. Stop geth n/w of server1 and copy its entire directory (accounts.txt, boot....
0
votes
0answers
23 views

uncaughtException : RangeError: Maximum call stack size exceeded

Facing an issue while working multi-http-provider. When I write var Web3 = require('web3'); require('multi-http-provider'); It throws an error uncaughtException : RangeError: Maximum call stack size ...
0
votes
0answers
15 views

Error parsing @openzeppelin/upgrades/contracts/upgradeability/ProxyFactory.sol

The @openZeppelin's ProxyFactory.sol("@openzeppelin/upgrades": "^2.8.0",/"truffle": "^5.1.51") is used in development of proxy contract: pragma solidity ^0.7.0; ...
0
votes
0answers
22 views

Solidity - Setting the length of an EnumerableSet UintSet

Is it possible to pre-set the length of the set of an EnumerableSet.UintSet type? For instance, if I declare this mapping: mapping (address => EnumerableSet.UintSet) private agentTickets; and then ...
0
votes
0answers
49 views

Using Webpack getting the error 'Uncaught Error: Module parse failed: Unexpected token (32:44)

Here is the complete error Uncaught Error: Module parse failed: Unexpected token (32:44) You may need an appropriate loader to handle this file type. | if(typeof window.web3 !== 'undefined') { | ...
0
votes
0answers
14 views

Empty Address when using Truffle Debug

I currently have a local chain with Ganache. Say I have two contracts written in Solidity: Foo_v0_0_1.sol Bar_v0_0_1.sol In the code for my smart contract Foo_v0_0_1, I have the following: import &...
0
votes
1answer
48 views

Deployed contract address in Truffle does not match Ganache

I have truffle set up with Ganache. I am running tests on my solidity contract that involve sending ether to the contract and withdrawing it from the contract. Funny thing is my tests are PASSING, but ...
0
votes
0answers
23 views

Uncaught (in promise) TypeError: Cannot read property 'deployed' of undefined

I am working on a truffle dapp project. Other than init(), initWeb3(), and initContract(), I have been doing fine interacting with my contracts in several JavaScript functions, until I created my 9th ...
0
votes
1answer
71 views

ReferenceError: cannot access 'CONTRACT' before initialization

I'm trying to test a single smart contract (PCE_Contract.sol) with (PCE_Contract_test.js) using Truffle. When I run Truffle test, console output is : ReferenceError: Cannot access 'PCE_Contract' ...
0
votes
0answers
24 views

How to work around warnings of infinite gas requirements for this function

This is the warning Gas costs: Gas requirement of function SimpleStorage.data is infinite: If the gas requirement of a function is higher than the block gas limit, it cannot be executed. Please avoid ...
1
vote
1answer
36 views

How do i test “it” methods with truffle?

I have this contract: contract('MetaCoin', (accounts) => { it('should put 10000 MetaCoin in the first account', async () => { const metaCoinInstance = await MetaCoin.deployed(); const ...
1
vote
1answer
11 views

How to change the sender of a function call?

I have this code from truffle unbox metacoin: ontract('MetaCoin', (accounts) => { it('should put 10000 MetaCoin in the first account', async () => { const metaCoinInstance = await MetaCoin....
0
votes
1answer
16 views

How to create a test contract that takes parameters?

I have a contract like so: pragma solidity ^0.5.16; pragma experimental ABIEncoderV2; Contract Ballot { constructor(string[] memory proposalNames) public { } } How do I create a test-instance ...
1
vote
1answer
27 views

Error: Could not find truffle/Assert.sol from any sources;

I started a project with truffle init, and I am trying to write a test and I have an import like so: import "truffle/Assert.sol"; I get an error: Error: Could not find truffle/Assert.sol ...
0
votes
0answers
10 views

Does the Bytecode and ABI generated for each contract also include it's imports?

If not, how does a contract such as an ERC20 get deployed if each output has its own ABI and Binary file? When compiling with truffle, and looking at A.json (where A imports B and C) it seems that it ...
0
votes
1answer
19 views

What is the proper way to check if msg.sender is the contract owner?

I'm trying to make a function that returns true if msg.sender is the owner. This is my function; function isAdmin() public view returns (bool){ require(admin == msg.sender); return true; ...
0
votes
0answers
19 views

Why does this function work in truffle tests and fail through metamask?

I have the following function and it has been working perfectly in truffle tests as I was developing the smart contracts and now that I am implementing it in the front end I have been getting a error ...
0
votes
0answers
14 views

How can I get intellisense to work when writing javascript tests in truffle?

Truffle injects a global web3 instance into your tests and also seems to set up some mocha functions in the global scope (contract, describe and it). When I open the test file for a truffle project in ...
1
vote
1answer
35 views

Error: Truffle Box at URL https://github.com/truffle-box/bare-box.git doesn't exist. Even after updating truffle

I am getting the Error: Truffle Box at URL https://github.com/truffle-box/bare-box.git doesn't exist. If you believe this is an error, please contact Truffle support. Even after updating of truffle to ...
0
votes
0answers
46 views

throw new Error(“Could not find artifacts for ” + import_path + “ from any sources”);

I’m receiving then ex error: C:\Users\xxxxx\AppData\Roaming\npm\node_modules\truffle\build\commands.bundled.js:455204 throw new Error("Could not find artifacts for " + import_path + " ...
0
votes
1answer
21 views

How to access a public function in solidity?

I have a smart contract deployed on the Testnet here - https://ropsten.etherscan.io/address/0xD99ea28F24317F28291556754edd24AA1352c26e This contract has a public function triggerAgeCount function ...
0
votes
0answers
19 views

Truffle Test Error Revert in Contract Factory

I'm trying to create a contract factory that creates "Oracles". Oracles have state variables that are initialized in the contract constructor, and I'm trying to use Truffle Test to verify ...
0
votes
1answer
19 views

Uncaught ReferenceError: TruffleContract is not defined 2

Firstly, I have viewed (Uncaught ReferenceError: TruffleContract is not defined) and am getting the same error for my smart contract: However, I received this error while having the contract script ...

1
2 3 4 5
46