21 votes

TypeError: Web3 is not a constructor when trying to use node.js with truffle-contract

I was stuck with the same error while trying to use this in nodejs.. I finally found the fix. Apparently, in Web3.js 4.x, we're supposed to import it like this: const { Web3 } = require('web3'); ...
Siddharth Maurya's user avatar
3 votes

Got `invalid opcode` when deploying a contract to Ganache test network from Truffle

This is because solidity 0.8.20 introduces the PUSH0(0x5f) opcode which is only supported on ETH mainnet and not on any other chains. That's why other chains can't find the PUSH0(0x5f) opcode and ...
Zartaj Afser's user avatar
  • 3,754
2 votes

How to unit test contract private and internal functions?

For anyone using Foundry, the recommended advice for testing internal functions is to inherit and expose them as external ones. This can be done directly in the .t.sol file, so you don't have to worry ...
NNNComplex's user avatar
1 vote

Deploy contract on live testnet using private key + truffle

I think it is better for you to use the official HDWalletProvider instead of the PrivateKeyProvider. For that, you need to include it: const HDWalletProvider = require('@truffle/hdwallet-provider'); ...
Guilherme Sampaio's user avatar
1 vote

truffle console doesnt work: Unexpected error setting up the environment or provisioning contracts while instantiating the console

i uninstalled truffle and install truffle of 4.x.x; It worked!
yuyang yu's user avatar
1 vote

Wrong type of smart contract being instantiated on using new keyword

If you're referring to this line: newPatientSmartContract = new patient(msg.sender, name); Then, indeed it's creating a new patient contract, not RC3. The same can be confirmed by invoking the public ...
SYED ASAD KAZMI's user avatar
1 vote


Note that Truffle is deprecated. If you still want to use it though, here's what truffle-config.js may look like interact with Sepolia: const HDWalletProvider = require('@truffle/hdwallet-provider'); ...
Ake's user avatar
  • 1,109
1 vote

Controlling Contract

You could use Remix, a web IDE which allows you to deploy a contract or call a deployed contract's functions using their interface. You can access it there: https://remix.ethereum.org/ It includes ...
Pacdac's user avatar
  • 80
1 vote

ERC20 transfer amount exceeds balance error in Solidity contract

There is a problem with the way you are interacting with the contracts. When the Token contract is deployed, it's constructor executes _mint which mints 1M tokens for the msg.sender which is the ...
Soham Zemse's user avatar
  • 2,031
1 vote

Cannot read properties of undefined (reading 'address') when trying to use 'truffle run verify'

Turns out the version of truffle-plugin-verify was causing it to not work. The version I originally had was ^0.6.3 but when switching to ^0.5.32 it worked.
ohShoes's user avatar
  • 53
1 vote

Error: error:0308010C:digital envelope routines::unsupported

Hope you've fixed this by now. Else, In Vercel Environment Variables create new variable: Variable:NODE_OPTIONS Value:--openssl-legacy-provider Works!
RussFerns's user avatar
1 vote

Cannot deploy contracts on local ganache instance

I faced the same issue, here are the changes which i did to make my code work: If you are using ethers.js ,downgrade it to version 5.6.2. Now add some manual gas amount to deploy the code such as: ...
Rishabh Sharma's user avatar
1 vote

UniswapV2 addLiquidity revert ds-math-sub-underflow

This error occurs when in addLiquidity or removeLiquidity (I encountered this error when I wanted to removeLiquidity) via Uniswap router, it's because the caller is the router address or your smart ...
ParsaAmini's user avatar
1 vote

"Migrations" hit an invalid opcode while deploying on deploy Migrations.sol with Truffle

Downgrading solc from 0.8.20 to 0.8.13 resolved the problem for me. I got to that version by downloading the metacoin truffle box, verifying that migration works and then getting the version of solc ...
Michelin Man's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible