Questions tagged [truffle]

Development environment, testing framework and asset pipeline for Ethereum

Truffle is a development environment, testing framework and asset pipeline for Ethereum, aiming to make life as an Ethereum developer easier. With Truffle, you get:

  • Built-in smart contract compilation, linking, deployment and binary management.
  • Automated contract testing with Mocha and Chai.
  • Configurable build pipeline with support for custom build processes.
  • Scriptable deployment & migrations framework.
  • Network management for deploying to many public & private networks.
  • Interactive console for direct contract communication.
  • Instant rebuilding of assets during development.
  • External script runner that executes scripts within a Truffle environment.

Github Repository

Official Website

1088 questions
2
votes
1 answer

Truffle failing to install on a Mac M1

I am trying to install Truffle on my mac M1. I started by following the instructions on the truffle web site in the Pet Shop tutorial I got node installed node successfully, but then I get this error... sudo npm install -g truffle ... npm ERR!…
Simon
  • 78,655
  • 25
  • 88
  • 118
2
votes
1 answer

Truffle installation error: "install latest visual studio version"

enter image description hereI've installed latest version of visual studio with desktop development c++ workload but still they are asking for it when i try to install truffle. I entered command :npm install -g truffle and lot of messages appear…
2
votes
2 answers

Tried npm install -g truffle but getting this gyp error

I tried npm node-gyp -g but it didn't help. I am trying to install truffle in my mac. I am using mac os Catalina, node version 16.13.1, and npm version 8.1.2 npm ERR! code 1 npm ERR! path…
2
votes
2 answers

Truffle '"Migrations" -- cb is not a function'

I wrote a simple smart contract in Solidity 0.6.6 that I'm trying to deploy to the BSC Testnet. This is what I have in my truffle-config.js file (privateKeys is an array with a single entry of ['0x + privatekey']: networks: { bscTestnet: { …
edoyle23
  • 21
  • 2
2
votes
0 answers

Module not found: Error: Can't resolve 'os' in './node_modules/xhr2-cookies/dist' while using react

I was working on a truffle project with react in the front-end. As I was importing web3 to my App.js, this happens, ERROR in ./node_modules/xhr2-cookies/dist/xml-http-request.js 41:9-22 Module not found: Error: Can't resolve 'os'…
2
votes
2 answers

Solidity - Check if an index exists in contract A from Contract B

I have two contracts called A and B. I defined an array variable in contract A. I want to check if an index exists or not from contract B. A.sol contract A { SomeStruct[] private myArray; /// @notice Check if an index exists function…
Milad Jafari
  • 1,135
  • 1
  • 11
  • 28
2
votes
1 answer

Solidity inheritance and VM Exception

I'm building a dapp using Solidity and Truffle. But when testing, I get the following error when I try to execute createPost (using js tests): Error: Returned error: VM Exception while processing transaction: revert Please look at the following…
Milad Jafari
  • 1,135
  • 1
  • 11
  • 28
2
votes
1 answer

Migrate with constructor parameters in Truffle

So basically I'm not quite sure how I can get my parameters from my solidity code and pass them in the deploy function of the deployer for my 2nd migration with Truffle. This is the constructor of my Solidity code: constructor( IBEP20…
2
votes
1 answer

can't update state in solidity test blockchain

I'm trying to connect this example to a frontend using web3. I have it copied exactly in my truffle project /contracts folder. Compilation and migration are both successful. (I have truffle configured to deploy on my ganache test network, and when…
David J.
  • 1,753
  • 13
  • 47
  • 96
2
votes
1 answer

input validation in solidity

I'm programming a Dapp. I need to calculate the area of a geographical coordinates (geo polygon). Can I calculate the area of these geographic coordinates on the client-side? Is it possible for the user to forge it? Would you suggest I do this on…
Milad Jafari
  • 1,135
  • 1
  • 11
  • 28
2
votes
1 answer

Error trying to obtain set of fields from array of Solidity objects

I am trying to write a test for the voting example Ballot.sol here: https://docs.soliditylang.org/en/v0.8.11/solidity-by-example.html My test code looks like this : const ethers = require('ethers'); const BallotContract =…
femibyte
  • 3,317
  • 7
  • 34
  • 59
2
votes
1 answer

Solidity Error : Construction of struct that contains a nested mapping

I'm using solidity solc^0.8.0 to build a smart contract, and I've got the following problem: // some lines of code oracleResponses[key] = ResponseInfo({ requester: msg.sender, isOpen: true}); // here the compiler complains about a the…
Yaa_seen
  • 21
  • 4
2
votes
1 answer

Error when attempting to call smart contract with javascript

I am trying to write a piece of javascript that calls a smart contract. The smart contract has been deployed to a local test net with truffle and ganache and the javascript is producing the following error: Promise {
John11727
  • 85
  • 1
  • 6
2
votes
2 answers

Truffle's artifact is undefined when running truffle migrate

I'm trying to run truffle migrate on two js files: 1_initial_migration.js and 2_deploy_contracts.js. I can successfully compile my .sol files to .json ABIs but then when I try to migrate I get the following error: const Migrations =…
crevulus
  • 1,658
  • 12
  • 42
2
votes
0 answers

Is the gas cost of maintaining a large array in the blockchain greater than removing unnecessary elements and making it smaller?

So, lets say that we have an uint256[][] array. Using solidity 0.5.16. uint256[][] example_array; Every time a function is called, that array has an array of four elements assigned. function n() public { example_array.push([1, 2, 3,…
Senses
  • 43
  • 3