New answers tagged

0

There are two reasons for this error : You are not passing enough gas for your contract, to be sure of this when deploying, use the maximum gasAmount allocation possible and the max gasPRice allowed by rinkeby. This error stems from the contract code being very big in size. for exact measurement its bytecode is bigger than 24Kb in size. the error message ...


1

I think you need to wrap deploy() function in async (async () => { deploy('myContract'); })(); In general I prefer to use Truffle for contacts testing and deployment.


0

Ok, so I managed to fix the issue (if someone else is struggling). I tried downgrading truffle several times, but faced other error messages with my contract. I realised I had used truffle install with -g flag and created global truffle package. Once I delete the global package and reinstalled the v5.4.1 locally and everything started working again.


0

All answers are moot above. Add a 2nd line to the truffle-config. Where it says version: "X.X.X" Add a comma, then copy paste without the comma to the next line. Now your config should look like this: version: "X.X.X", version: "Y.Y.Y" Do not add a comma to the 2nd one. Save the changes. Now try compiling. It will use BOTH ...


0

Try changing the rpc url to // Mainnet "https://rpc-mainnet.maticvigil.com/" // Testnet "https://rpc-mumbai.maticvigil.com/" Hope it helps!


0

I was seeing this when my build/contracts directory had some old files in it. This is an easy fix: rm -rf build npx truffle compile && npx truffle migrate && npx truffle test


1

you did not declare expectedAdopter as address and set it equal to address(this) in your test file. or maybe typo somewhere


0

you can do something like this... NB: accounts is a global variable with test wallets passed in to the test by truffle. should.be.fulfilled is using the chai-as-promised NPM module - checks for errors it('Checks we are keeping track of total enlisted', async function() { for (var i=0; i < accounts.length; i++) { await this.WhitelistV2.enlist(...


0

node_modules is for installed libraries and developing code there is not going to do your any good. You need to learn how properly Create your own JavaScript project Manage NPM based dependencies Extend smart contracts from other projects Most of this is not relevant to Ethereum, but how to become a JavaScript developer.


1

Truffle-Contract is now deprecated: https://www.npmjs.com/package/truffle-contract We should be using now: @truffle/contract https://www.npmjs.com/package/@truffle/contract Also as of today this works on truffle console: const CakeToken = artifacts.require("./CakeToken.sol") module.exports = async function(callback) { const cakeToken = await ...


0

Found the answer in another thread. What I did was change import "./extensions/IERC20Metadata.sol"; to import "IERC20Metadata.sol"; save all the files and try to upload them again with multifile on etherscan.


0

Did you specify --network development? Because the standard network for deploying with the "migrate" command is called "develop" (you can see it in your truffle-config.js, so you need to explicitly specify the network "development" NOTE: you may also use the "truffle develop" command to get a truffle console and launch ...


0

before deploying you have to run ganache-cli or any other client similar to it. try truffle develop before truffle migrate develop: { host: "127.0.0.1", port: 8545, network_id: "*",


0

in my case, same problem was because my ip local address was automatically changed. So, I'm turn back old configuration, and turn off automatic dhcp.


0

The SimpleStorage contract abstraction has MyEnum as a property so you can do: assert.equal(ret, SimpleStorage.MyEnum.step3);


1

I went through this error recently. This is happening because the compiler version configured on VS Code workspace is different from the version you want. To fix that just right click on the error and select the option Solidity: Change workspace compiler version (Remote) It will open a drop-down with the available versions and you just pick the 0.7.6. You ...


1

There's a wrongly placed }. I suggest to format the file then it should be obvious that compiler is in the wrong section. module.exports = { networks: { live: { host: "127.0.0.1", port: 8545, network_id: "1", // Only mainnet gasPrice: "10000000000", // 10 gwei gas: "5000000", // 0.02 ...


0

Try to pass the value as a string, example - "10000000000000000". Or if it's dynamic value you could use .toString() method.


1

If you are equally strong in Python and JavaScript, Brownie is a better choice, because Python as a programming language is more suited for tasks needed from a smart contract programming framework. You can handle numbers, like uint256 and decimals, as numbers in Python whereas in JavaScript you need use strings or hacky classes. There are a lot of big ...


0

I was able to solve this by creating a payable function in my smart contract and sending eth to that function instead of directly to the contract. Still not sure why I ran into this error in the testing environment but not in the truffle develop environment though.


2

In the contract, you just treat msg.value like any other uint256. It's "given" by the transaction. But how did it get there? The first thing to understand is that it's not simply a message the user signed. It's actual ETH that got sent with the message. So, it's treated differently. Truffle = Javascript. You use the transaction object that contains ...


0

Resolved: I was able to fix the issue by unboxing a new truffle project on another folder and copying over truffle-config.js and the contracts. Though I'm unsure what actually caused the issue.


1

To begin with, you are not running your script as an unit test, so I guess it isn't meant to be one. If it's not meant to be a unit test, it probably shouldn't have asserts. You should run unit test with the truffle test functionality. Otherwise, in general, as is also said in your link, you should only have one assert per unit test. I personally don't often ...


1

If you are importing other contracts, those too need to be supporting the same pragma solidity version you are using on your main contract. Another thing would be an issue with truffle, where the solc version you are using is not the same one that you are downloading when trying to run the compile command. this used to occur before but it might be the issue. ...


0

You are using a bad version of truffle contract js file. What you need to do is add the new version via CDN or form the node_modules in your index.html file. first you should install @truffle/contract : npm install -s @truffle/contract second, go to your index.html file and add the js file like follows : <script type="text/javascript" src="....


1

To retrieve the transaction receipt object, sender, and receiver, you can do this at the end of the script : result = await web3.eth.sendTransaction({to:sc1.address, from:acc2, value: web3.utils.toWei(amount)}) console.log("receipt : ", result) console.log("sender : ", result.from) console.log("receiver : ", result.to) You can ...


0

Updated Answer: 2021 We can use the expect module from chai to catch reverts. Solidity Contract: Contract ContractA { function doRevert() public { revert(); } } Javascript test import {expect} from "chai"; it("Catch the revert", async ()=>{ let a = await ContractA.deployed(); await expect(a.doRevert()).to....


0

In your truffle configuration file, you can include your compiler configuration and set your solc version there. You can reference the documentation here module.exports = { compilers: { solc: { version: <string>, // A version or constraint - Ex. "^0.5.0" // Can also be set to "native" to use a ...


0

Let them sign in via Metamask. You can let them sign without using any gas.


0

For artifact conversion, I would just suggest to delete all pairs from the remix artifact keeping only the "abi" pair, and also adding a "contractName" pair as follows: { "contractName": "StakDrop3", "abi": [...] }


1

The error has nothing to do with the compiler version; you need to return an array (e.g. uint[], address[]) if you specified an array in the return statement: // return uint[], not uint function get_patient(address addr) view public returns (string memory, string memory, uint[] memory, string memory){ // if(keccak256(patientInfo[addr].name) == keccak256(&...


0

I randomly uninstalled and reinstalled a 2nd time and it seems that I can get the dropdown for all networks if I start a new project. The old project seems corrupted so I ended up deleting it and restarting my project. I'm not sure what exactly happened.


Top 50 recent answers are included