New answers tagged

2

Generally call will default to using 0x0000000000000000000000000000000000000000 as msg.sender, which is why this is reverting. That address is indeed not owner, so a revert is what you would expect. You can do call though and specific the msg.sender by doing await exchange.methods.isAdmin().call({from:addressYouWantToUse}) and replace the placeholder with ...


0

You used this URL to get Truffle boxes for a project. There is another method to get them. Moreover, because you mentioned that you want to create a Truffle project i provide this answer to you. However, i think this URL doesn't create a directory. Anyways, you can follow this answer to create it perfectly. In terminal ,go to your folder or directory you ...


1

You should be able to use truffle console --network rinkeby. You will need to configure truffle-config.js properly, e.g. using Infura and the hdwallet-provider package: const HDWalletProvider = require('@truffle/hdwallet-provider'); const infuraURL = 'https://rinkeby.infura.io/v3/YOUR-INFURA-PROJECT-ID'; const fs = require('fs'); const mnemonic = fs....


0

Himanshu I am also learning Solidity. You can do what you are asking for from Remix in the Deploy tab. http://remix.ethereum.org/


0

Looks like it was a version thing. According to Truffle's official readme (available here: https://github.com/trufflesuite/truffle/tree/develop/packages/hdwallet-provider#truffle-usage) the way to do this now is as follows: rinkeby: { provider: () => new HDWalletProvider({ mnemonic: { phrase: rinkebyMnemonic }, ...


0

Have you tried reading the docs on the @truffle/contract docs? https://www.npmjs.com/package/@truffle/contract There are several steps to do before including the truffle-contract.min.js file in the index.html.


1

If you run npm uninstall @openzeppelin/contracts and then npm install @openzeppelin/contracts@2.3.0, then retry the import, then it should work. Also, check your truffle-config.js file and see if the root directory is configured properly to find your node_modules folder properly.


0

You can use any of the built-in Solidity time units. For example, you can do: function f(uint start) public { if (block.timestamp >= start + 365 days) { // ... } }


0

That's because ERC721Full.sol no longer exists, as you can see in the Github repository. From the latest update (v3.0) of the OpenZeppelin contracts, you can read the following: ERC20 and ERC721 were simplified and streamlined, including all optional parts of the standard by default, and simplifying some of our own custom extensions. [...] If you're using ...


0

Configure your network in the truffle configuration. Notice that truffle expects the network id as decimal value. An it is a good idea not to store private keys in your project files. Try something like this: require('dotenv').config(); let PrivateKeyProvider = require("truffle-privatekey-provider"); module.exports = { networks: { ...


0

Truffle now doesn't supports the solidity version below the 0.5.16. So you have to write the smart contracts which are equal or above this version


1

What worked for me : Launch truffle console : truffle console --network live --verbose-rpc with live the main network configured in the truffle-config.js file. Instantiate the contract : truffle(live)> const abi = require("./wethAbi.json"); truffle(live)> var wethContract = new web3.eth.Contract(abi,"...


0

I haven't tried this, but it should work according to the documentation. Please let us know if it does indeed work. As described in https://github.com/nomiclabs/buidler/tree/master/packages/buidler-ethers#environment-extensions, the buidler-ethers plugin adds a getContractAt object to the ethers object. What that means for you would be Install the plugin if ...


1

You can use: token = await Token.new('name', 'symbol', decimals) in order to deploy and interact with a new Token instance token = await Token.at('0xSomeAddress') in order to interact with an already-deployed Token instance Depending on your Truffle version, the await before the at may be redundant. But you can leave it there in order to stay on the safe ...


1

Yes, with truffle console : truffle console --network ropsten --verbose-rpc. You can then interact with the smart contract using the truffle API : https://www.trufflesuite.com/docs/truffle/getting-started/interacting-with-your-contracts.


0

From the official documentation: When running sha256, ripemd160 or ecrecover on a private blockchain, you might encounter Out-of-Gas. This is because these functions are implemented as “precompiled contracts” and only really exist after they receive the first message (although their contract code is hardcoded). Messages to non-existing contracts are more ...


1

I'm also trying to do a fork of Uniswap and got an error when running truffle migrate. It errors out when deploying the Migrations contract: VM Exception while processing transaction: invalid opcode at Migration._deploy (/usr/local/lib/node_modules/truffle/build/webpack:/packages/migrate/Migration.js:97:1) at process._tickCallback (internal/process/next_tick....


0

After quite some time, I realized that the problem was the nodejs version. Truffle is incompatible with nodejs 14, I downgraded to nodejs 12 and it works on all operating systems.


1

First of all, you can always specify the account with which you want to interact with the contract, using the from keyword, e.g., instance.someFunction({from: accounts[0]}). Second, you can edit the default address in the truffle-config.js file at networks.advanced.from, which equals to accounts[0] per default.


0

Looks like it's a bug in ganache. From: https://spectrum.chat/trufflesuite/ganache/mappings-wont-show-up~31d934cd-7015-4ac3-9d35-05b4737005a2 sadly Ganache UI doesn't support decoding mappings right now. This is something we're aware of and have in mind to add, but there's a few technical limitations we'd have to overcome for that to be possible.


0

Node 12 works with truffle version 5.0.x and 5.1.x I had to downgrade node that I installed through 'brew install node' which installed node version 14.12.0. steps to downgrade node using brew... brew install node@12 brew unlink node brew link --force --overwrite node@12 back in your truffle project folder $ truffle version Truffle v5.1.47 (core: 5.1.47) ...


0

ATM, what you can do is: constructor(address[] memory addresses, uint256[] memory balances, bool[] memory flags) public { uint256 length = addresses.length; require(length == balances.length, "INVALID_INPUT"); require(length == flags.length, "INVALID_INPUT"); for (uint256 i = 0; i < length; i++) { // do whatever ...


0

You cannot call approve in a contract on behalf of a user. The first parameter of approve is the spender: the address of who or what is allowed to transfer funds for msg.sender. Specifying msg.sender as spender does not let your contract send tokens for msg.sender. What you want to do instead is have the user send two transactions: First, an approve ...


0

You need to increase the transaction data size, not the code size. The transaction data size can be increased on Quorum with the genesis txnSizeLimit value (up to 128kb). This is documented here: https://docs.goquorum.consensys.net/en/latest/HowTo/Configure/GenesisOptions/#configurable-transaction-size


0

In the case your node is syncing, then do: this.web3.eth.isSyncing((error: Error, sync: any) => { if (!error && sync) { console.log(sync.currentBlock); console.log(sync.highestBlock); } });


Top 50 recent answers are included