New answers tagged

0

There is many ways to use Metamask for deploying to mainNet one of the best way for your question is: Deploy Contract using Remix IDE and select injected web3 option to connect and deploy using metamask.


0

how did you connect with your private key? maybe you need to add 0x to your private key before using it to call the contract function.


0

Actually, the call does not use gas. However, it seems to be calculating gas in the truffle console. In truffle-config.js, set a larger number in networks.kovan.gas as in the example below. ropsten example) networks: { ... ropsten: { ... gas: 5500000, ... } },


0

As another valid answer pointed out, the eventual gas cost is gas price * gas used. In your case your gas price is 211000000000. Your questions doesn't state the required gas used, but it states the maximum allowed: 4712388. Now, if we assume that your contract requires all of the allowed gas, its gas cost would be: 4712388 * 211000000000. And, the result ...


1

First, I am not an expert on this and you can very well see me as a beginner. This upfront cost is gas price * gas you are sending which is set in your config. This does not necessarily match the real cost. What is important is how much gas your deployment will cost. The rest of the gas sent will not be used. In your case, you are willing to pay: ...


0

The array elements start at row 0. This looks suspicious. uint public nextId = 1; Pursuing that a little farther ... it('Should create a new user', async () => { await todo.create('Kirean'); const user = await todo.read(1); You pushed Kirean into row 0 and then tried to access row 1 which is out of range, so the contract reverted. Hope it ...


0

Not an answer, but I am getting the following error(using version 0.8.1): CompileError: TypeError: Operator % not compatible with types int256 and uint8 --> truffle/AssertInt.sol:247:41: | 247 | bts[i++] = _utoa(uint8(uint(n % radix))); // Turn it to ascii. | ^^^^^^^^^ ,TypeError: Operator /= ...


0

The default unit used by Truffle in truffle-config.js is Wei (1 Wei = 10^(-18) Ether). You should set the gasPrice in this unit. You can use this website for conversions : https://eth-converter.com/.


0

If you look through the comments on OP's question, it becomes clear that there was an issue with the ABI the OP was originally using (h/t @Ismael) - perhaps it was copy pasted incompletely, or maybe there was some file corruption. By regenerating the ABI, the code worked as expected.


0

For those who may stumble across this: I was stuck on this recently - everything seemed to be set correctly but Truffle refused to connect to Ganache (or vice versa). I kept getting the "Could not connect to your Ethereum client" message. On a lark, I tried changing the host address in truffle.js to reflect the computer's actual internal IP address ...


1

For those who may stumble across this: I was stuck on this recently - everything seemed to be set correctly but Truffle refused to connect to Ganache (or vice versa). I kept getting the "Could not connect to your Ethereum client" message. On a lark, I tried changing the host address in truffle.js to reflect the computer's actual internal IP address ...


0

The contracts_build_directory goes outside the networks section. module.exports = { contract_build_directory: "./client/src/contracts", networks: { development: {


0

It's declared as async, so use await. const accounts = await web3.eth.getAccounts();


0

If you want to compile from one version and upwards, you need to include symbol ^: pragma solidity ^0.4.18; However, this will only take up to version 0.4.26, which is the latest from 0.4, but not versions above (0.5, 0.6...). As described in the official documentation: pragma solidity ^0.5.2; A source file with the line above does not compile with a ...


0

I'm embarrassed to report that I found my problem. It had nothing to do with the Truffle contract abstraction or web3.js contract object. The problem was in the web3.js function estimateGas. This function doesn't just give you a gas estimate, it simulates the transaction and so throws any errors that the function call would throw when used in anger. So, when ...


0

Truffle compiles everything, including those imported. The imported SafeMath is included in your contract, and only your contract is distributed. It refers to the deployed contract by setting the deployed contract address as an argument of AggregatorV3Interface.


0

Say you have a contract like the one below deployed at address 0x1f2deF1210B4D06B267A64b9888990734Aba7e24 pragma solidity ^0.8.1; contract test { string public initialString = "Hello World!"; function getString() public view returns (string memory) { return initialString; } } To create an instance of that contract: truffle(...


0

remixd -s C:\blah\blah\blah --remix-ide https://remix.ethereum.org You must use -s and not -d


0

From what I understand, the eth gas comes from the sender, separate from the amount sent in the transaction value. Hope that can help you 2 years later :)


0

Use ganache mainnet fork. Check this repo https://github.com/t4sk/defi-by-example#test


-1

function addCandidate(string memory _name) This works so go for it and vo solidity version Unistall the old version and go for the new version. $npm install sol@version


2

You need a couple of changes to see the value of iVar: Make it public in order to generate a getter function: uint8 public iVar = 0; Call the variable with parenthesis (because it is now public and has a getter): truffle(development)> await PR.getIVar() Alternatively, you could also add a function in the contract to retrieve the value, such as: ...


1

You can use HDWallet provider. It accepts an arrays with private keys as argument. Then calling the deployer with { from: account } should just work (tm).


0

You probably don't need to create a contract for every new product, as this would be expensive in terms of gas consumption. You can try something like this: // SPDX-License-Identifier: MIT pragma solidity 0.8.1; contract ManageProduct { struct Product { string name; uint256 price; } Product[] public products; ...


0

Here is what it should like in the 2_deploy_contracts.js migration file: const DappToken = artifacts.require("./DappToken.sol"); const DappTokenSale = artifacts.require("./DappTokenSale.sol"); module.exports = function(deployer) { const tokenPrice= 1000000000000000; // .001 Ether deployer.deploy(DappToken,1000000); deployer.deploy(...


Top 50 recent answers are included