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

Slither not working with Truffle imports

Currently I have a project that needs slither run against it so I pulled down the docker image for slither as specified in the docs here https://hub.docker.com/r/trailofbits/slither/, then I shared ...
1
vote
0answers
21 views

Replacing pending deploy tx with truffle

I deployed my contract with default params using truffle migrate --network mainnet --reset the gas was too low and got my tx pending for more than 20 hours already. I wanted to replace the tx with new ...
0
votes
0answers
678 views

Metamask RPC error -32603… {“error”:“revert”,“program_counter”:6758,“return”:“0x”}

I have a dApp that leverages ERC721 contract which allows users to upload images onto IPFS and transfer them to each other. User A can upload images fine and transfer them fine to User B. Once ...
0
votes
1answer
121 views

Problem while compiling a solidity contract with truffle

Each time that I compile a contract with truffle I get this error: (cmd) # Compiling your contracts... > Compiling .\contracts\HW.sol Error executing vyper: 'vyper' is not recognized as an internal ...
0
votes
1answer
35 views

How I can do steps in the truffle test?

I'm testing AMM, so I have steps like add liquidity, try to swap remove liquidity etc I can just add it in one it block like this answer suggests contract('amm', (accounts) => { it ("...
0
votes
1answer
14 views

Accessing to a contract's public array from javascript

Look at this basic Solidity contract: // SPDX-License-Identifier: MIT pragma solidity 0.6.11; contract MyContract { string[] public tmp; ... function read_tmp() public view returns(string[]...
0
votes
0answers
51 views

AttributeError: type object 'Transaction' has no attribute 'exclude'

When I execute a python script to deploy smart contracts, it throws the following exceptions: Traceback (most recent call last): File "contrCompDeploy.py", line 7, in <module> ...
0
votes
0answers
42 views

Truffle “test” is passing only 1 it(“”) test instead of showing “all 3 tests passed”

MyToken.sol //// SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract MyToken is ERC20 { constructor(uint256 ...
0
votes
1answer
42 views

Truffle test deploys everytime a new contract with .deployed()

I want to test some contracts^^ And now Im wondering because like I understand .deployed() should take the contracts from the migration in truffle and dont deploy new ones? My test.js: const one = ...
0
votes
1answer
76 views

Error in converting ERC20 tokens with decimals to full coins without rounding errors?

How to convert token to full token without having any rounding errors. web3.utils.toBN(6221221111111110001).div(10**18).toFixed() TypeError: num.isZero is not a function at BN.divmod (...
0
votes
0answers
49 views

“before each” hook error while run truffle test command

I ran truffle test command on my project for testing but I got an error like this: "before each" hook for "1- should be return true Pauser Role for account[0]" why I'm getting ...
2
votes
2answers
37 views

Importing openzeppelin-test-helpers

Somethings I need BN library for correct balanceOf assertion with 1e18 decimals, somettimes expectRevert. I see the different projects use it differently: const { constants, time, ether, expectRevert }...
3
votes
2answers
331 views

Ganache-cli Fork unlocked account to make transactions

I'm trying to use ganache-cli on a fork of the Main Network. I use the following command to start ganache. ganache-cli --fork https://mainnet.infura.io/v3/MY_API_KEY -- unlock ...
0
votes
1answer
15 views

I am not able to assign value to a string storage and retrieve the set value

below is the test.sol file pragma solidity ^0.5.0; contract test { string initialstring = "Hello World!"; function getstring() public view returns(string memory){ ...
0
votes
1answer
31 views

Factory Pattern Migration With Truffle

have a standard factory pattern for my contract and I am trying to get it up and running using Truffle Migrations. In my factory truffle migration script I have await deployer.deploy(ContractFactory); ...
0
votes
1answer
66 views

Generate private keys from seed phrase [duplicate]

I am working with @truffle/hdwallet-provider library. This library works with a mnemonic. Is is basically a seedphrase. Is there a way to work with this library outside truffle ? (I mean in a ...
0
votes
1answer
56 views

How to get the current selected account in Metamask?

How to get the current selected account in Metamask? I've seen things like this as the answer to this.. const accounts = await web3.eth.getAccounts(); const account = accounts[0]; But doesn't this ...
6
votes
1answer
5k views

Setup Ganache with Metamask. What and where is a Chain ID?

I am following these instructions. The problem is that the above instructions don't mention Chain ID and it appears Chain ID is required to even make it work. Thus, I'm stuck. What is the Chain ID? ...
1
vote
1answer
26 views

truffle - should I remember the results of previous calls?

I wrote a smart contract. now, I am writing tests in truffle . the code is gonna look like this. contract('contract', accounts => { it("test1", () => { }) it("test2", ...
0
votes
0answers
21 views

New to blockchain development

hope everyone's doing ok. So I am really interested in blockchain development. My programming experience so far has been C++ and a little bit of Python. I know the basics of Javascript as well. So I ...
0
votes
0answers
13 views

truffle deployer - addess is still there without deploy

First Question: // Stage deploying A before B deployer.deploy(A); deployer.deploy(B); This is found on the truffle website. It says stage deploying A before B. So this must mean that deploying B ...
0
votes
0answers
26 views

TypeError: Library functions must be implemented if declared for solc compiler version ^0.6.0 library implementation

Suppose I have the following code: // SPDX-License-Identifier: MIT pragma solidity >=0.4.21 <0.7.0; library SomeLib { function add(uint256 a, uint256 b) public returns(uint256); } contract ...
0
votes
0answers
13 views

what does link mean in truffle?

I saw the following : what does `deploy.link` exactly do in `truffle` I have safe.sol library safe { function safeMultiply(uint256 a, uint256 b) internal pure returns (uint256) { if (a ...
0
votes
1answer
31 views

truffle - should I create migrations files by myself?

I am using truffle. I run truffle compile and I get json files in build/contracts directory. Now, truffle says I should run truffle migrate , but in the migrations folder, I only got ...
0
votes
0answers
17 views

deployment failed

Error: * Deployment Failed * "ERC20TransferLiquidityLock" is an abstract contract or an interface and cannot be deployed. Import abstractions into the '.sol' file that uses them instead of ...
0
votes
1answer
114 views

Solidity Multiple Contracts and Inheritance issue

My smart-contract has gotten bigger than the 24K size allowed by Ethereum, so I had to break it up into smaller contracts. I then had to facilitate all sorts of inheritance and importing between these ...
0
votes
1answer
43 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
32 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
3answers
20 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
87 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
271 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
24 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 ...
5
votes
4answers
2k 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
48 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
127 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
31 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
130 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
41 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
329 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 ...
1
vote
1answer
54 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
198 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?
1
vote
1answer
35 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/...
2
votes
1answer
86 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
26 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
138 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
78 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
20 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
83 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
2answers
202 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
24 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 ...

1 2 3
4
5
49