2022 Developer Survey is open! Take survey.

New answers tagged

0 votes

Compatible versions of npm, truffle, node and web3 for Solidity 0.7.2

Personally, I have used Node v12.18.4 for the longest time and I work with Solidity daily. Haven't had any problem.
user avatar
0 votes

'Error: getaddrinfo' after trying to run 'truffle unbox react'

According to their github page (https://github.com/trufflesuite/truffle/issues/2995#issue-604582346) It seems like other people have come across this issue. Basically I just added the following line ...
user avatar
0 votes

Can't install Truffle Framework to Mac OS Big Sur

I just did brew install truffle and it worked for me. Brew may ask you for the cleanup after installing. Use: brew cleanup truffle
user avatar
0 votes

Truffle Test Console Logging

Is this some new kind of feature? I have never seen this before. It just started doing it today. Also, truffle test works even if ganache is not running, so I think it automatically runs its own ...
user avatar
1 vote
Accepted

How to deploy a contract from a different account (using truffle)

In Truffle when calling a transaction the last parameter has an optional dictionary with the transaction's parameters. For example something like this should work: contract = await Contract.new( ...
user avatar
  • 29.2k
0 votes

Choosing between Javascript and Solidity for testing smart contracts

Here's a great Medium article that covers everything related to testing on Ethereum. Solidity tests Writing tests in Solidity gives us the ability to run Blockchain layer tests. They allow tests to ...
user avatar
  • 1
0 votes

Truffle invalid address

using an old version of web3 for a tutorial web3@0.20.6 and Firefox 100.0.1 this was what I added to react to get resolve the error web3.eth.defaultAccount = web3.eth.accounts[0]
user avatar
0 votes

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

I thought I had a phantom ganache-cli process still running as that's how is looked, but it turns out it's just MetaMask/Ganache weirdness. I gave up trying to change the settings in MetaMask and ...
user avatar
0 votes

Error with "truffle compile" - Could not find a compiler version matching

It's an answer after half a year, but I thought I'd post it here for the benefits of other beginners. I just experienced similar issue in my Mac and after some research I found out it's because it's ...
user avatar
  • 101
0 votes

ERC-721 safeTransferFrom() not working when sending an NFT from a regular address to a smart contract address

Try this: safeTransferFrom(ownerOf(_tokenId), payable(this), _tokenId);
user avatar
0 votes
Accepted

Truffle default account private keys

I think there are two possible solutions to this. The first is to use HDWalletProvider https://www.npmjs.com/package/@truffle/hdwallet-provider You can configure it in your truffle-config.js Second ...
user avatar
  • 557
1 vote

Truffle Chai Assertion Error with Truffle Unit Cases

Your .to. should be replaced with .should. to support the .eventually. interface. Explained in Chai docs, you The most powerful extension provided by Chai as Promised is the eventually property. With ...
user avatar
  • 1,291
0 votes

Truffle Chai Assertion Error with Truffle Unit Cases

I think this might be a concurrency issue. Have you tried placing await before each and every possibly async call? Example: await expect(instance.balanceOf(deployerAccount)).to.eventually.be.a....
user avatar
0 votes

Unhandled promise rejection(gas limit) when deploying Contract to rinkeby using truffle-hdwallet-provider

The issue for me was that the bytecode was too large. Deleting all the inline comments worked for me.
user avatar
1 vote

Simulating the passage of time with testrpc

1.evm_increaseTime: increases the time for the next block. 2.evm_mine: mines a new block. You don't even need a Tardis or a DeLorean for this kind of time travel. Let me explain how these functions ...
user avatar
0 votes

Encountered an error while attempting to update latest block (error code 1020 on Polygon mainnet)

This seems like CloudFlare Access Denied, possibly from infura's servers, etc. It's possible you've exceeding the request rate limit they allow. You can try to register and get a key with a higher ...
user avatar
  • 1,291
0 votes
Accepted

Transfering token balance away from a smart contract

Problem solved. I was hitting an overflow, switched to using SafeMath, and got the transfers working as expected with g.token.transfer
user avatar
0 votes

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

This worked for me: compilers: { solc: { version: "pragma", }, }
user avatar
1 vote
Accepted

ParserError: Expected identifier but got '('

You're probably using an old version of solidity to compile the contract, receive is a keyword of the language that was added around 0.6.x. https://blog.soliditylang.org/2020/03/26/fallback-receive-...
user avatar
  • 1,291
0 votes

How to get Truffle to generate artifacts for contracts outside of project?

In order to deploy a different project, you need its json compiler output, within this file you'd find the compiled bytecode which can then be deployed locally for testing. Doing so using ethers.js is ...
user avatar
  • 1,291
0 votes

Running a geth light client, how do I resolve the error: "No trusted canonical hash trie"?

Since a light client doesn't hold full database, it needs to have a canonical hash to validate a newly received block. If the node is pruned (or new), it needs to download block bodies and receipts on ...
user avatar
  • 1,291
0 votes

deploy contracts, invalid number of parameters

How are you doing the migration? I have found that specifying reset: truffle migrate --reset cures a great many of these issues ;)
user avatar
0 votes

How to deploy smart contract using truffle and ropsten with Metamask account

It looks fine, my guess is that there's an issue with rpcURL. Double check you're connecting to the correct URL. Try using https://ropsten.infura.io/, maybe there's an error with your node. Try ...
user avatar
  • 1,291
0 votes

Contract should be marked as abstract

@Markus's answer is correct, @sloreti made a nice suggestion, and I don't have enough rep to add a comment... If you're using hardhat, and your error doesn't have additional info, you can compile your ...
user avatar
0 votes

change solc version

I did find the correct method I believe is to modify the truffle-config.js. This works for me. }, //make sure you have the comma here compilers: { solc: { version: "...
user avatar
0 votes

Metamask wont show up when I am calling approve function using Erc20 token

You do not seem to have set the contract field in your stateToken1 and stateToken2 state objects to point to the "Token1Contract" and "Token2Contract" objects respectively. If ...
user avatar
1 vote

truffle compile error

use compilers in truffle.config.js to change the solc version to match the contract's solidity version. need to mention that i use solc-select to change my solc golab version before truffle compile. ...
user avatar
  • 11
0 votes

unable to install truffle

Try to use different node version. You can install and use a new version by saying: nvm install 12.20.2 nvm use 12.20.2 And then check if the correct version is being used with nvm list. You should ...
user avatar
  • 118
0 votes

Truffle. How to link deployed library by address during migration?

Truffle does support this Your migration file needs to look like this; const CrowdsaleTokenExt = artifacts.require("CrowdsaleTokenExt"); const Lib = artifacts.require("Lib"); ...
user avatar
0 votes

Truffle test doesn't recognize estimateGas function

It is called wrongfully. It should be: const instance = await MyContract.deployed(); const gasCost = await instance.fillUser.estimateGas(users, names, ids, { from: accounts[0], gasPrice: ...
user avatar
1 vote

How to unit test struct values

You can deconstruct a struct's values when doing unit tests in Hardhat. In your example, if you would like to get the age and name from a struct then the code would be: let [age, name] = ...
user avatar
  • 11

Top 50 recent answers are included