Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

New answers tagged

0

with that simpleStorage contract, you are storing a value in a smart contract on the blockchain. So User B need only the address of that deployed smart contract and then he could call the method get() from that contract to get the stored value. contract SimpleStorage { uint storedData; function set(uint x) public { storedData = x; } function ...


0

Yes it is possible, previously I wrote an answer for getting truffle working for various CI services and this gist also supports the same idea https://gist.github.com/maikotrindade/2d544de08215085abfbba59ce3378a2c. What Continuous Integration services support running Truffle Solidity tests? As for Jenkins, I assume you can use a docker image or install ...


0

Truffle version prior to 5.0.14 have some Quorum related bugs. Please upgrade to 5.0.14+ and try again.


0

The name of an artifact is defined according to the contract's name, not the file's name. Typically, the best practice is to have both names identical. In your case, however, it seems that: SolnSquareVerifier is the file's name SolnSqaureVerifier is the contract's name Note that the a and u appear in a different order in each name.


0

In OpenZeppelin v1.x, variable owner is public, hence a getter function owner() is implicitly added by the compiler. In OpenZeppelin v2.x, they realized that since contract Ownable is designated to be inherited from, any contract which inherits from it may choose to change the owner variable. This capability is undesired for this variable, so in order to ...


1

Great to hear that you are using Ethernaut to learn more about smart contract security. I would suggest that for the Fallback level you just use the console. I can then help with getting an environment setup. Some hints on the Fallback level. How to send ether when interacting with an ABI e.g. await contract.someFunction(parameter1, {value: toWei(0.1)}) ...


0

Enums are returned as uint256. BN means big number, it is a javascript object that wraps an arbitrary precision integer, it is used to wrap uint256. When it prints some values like words, red, negative, etc. it is javascript that is trying to show some internal data that is not useful unless you develop BN package. You get more info if you convert to ...


1

Maybe it will be easier for you to start with http://remix.ethereum.org and move to ganache after you gather some experience (or just stay in remix). The main problem here is that you will need openzeppelin-solidity@1.5.0 not openzeppelin-solidity@2.0.0 Then in Remix make sure to select v0.4.18 as your compiler


0

I'm assuming you're using Truffle HDWallet Provider with an Infura node. If so, go in truffle.js (or truffle-config.js) and under the ropsten provider (under networks), try passing the Infura API URL with https://. So it should look like this: // Inside truffle.js // imports module.exports = { ... networks: { ... ropsten: { provider: ...


0

In truffle.js (or truffle-config.js) under the ropsten provider, try passing the Infura API URL with https://. So it should look like this: // Inside truffle.js ... module.exports = { networks: { ... ropsten: { provider: function() { return new HDWalletProvider(MNEMONIC, "https://ropsten.infura.io/v3/my-key") }, ...


1

You need to import HelloEth where you import another contracts. You are creating an instance here, but Solidity doesn't know what that HelloEth means until you import the contract. Also, in the future, try use Mocha.js so you don't have to spend gas and it will be faster. You will use the same truffle and code in asynchronous way.


1

With seeing the code it is impossible to confirm this, but I suspect your code contains an endless loop, or possibly just one that loops an unreasonable number of times. Unbounded for loops and recursion are anti-patterns. See this: https://blog.b9lab.com/getting-loopy-with-solidity-1d51794622ad From your question, I think you understand that it is rather ...


0

It needs to be function bytesToAddress(bytes memory bys) ... Hope it helps.


0

All accounts in Ganache are unlocked by default, but when you want to connect to other network and deploy contracts there (using truffle) then you should use this library https://github.com/trufflesuite/truffle-hdwallet-provider,


0

This is a rite of passage. A favorite one-liner, in the Geth console: web3.personal.unlockAccount(web3.personal.listAccounts[0],"<password>", 15000); Meaning, unlock my first account, with this password, for 15,000 seconds (i.e. don't bother me for a while). When you are finished, manually lock it or just restart the node. PSA: Don't expose the ...


1

I was also getting similar error, when I was referring to a website which was not using network_id (May be due to configuration update as I was using the latest truffle version). This worked for me! Edit your truffle.js or truffle-config.js file as below: module.exports = { networks: { development: { host: "localhost", port: 8545, network_id: "*"...


-1

You can define your network in truffle-config.js For example: const HDWalletProvider = require('truffle-hdwallet-provider'); module.exports = { test: { host: `127.0.0.1`, port: 9999, network_id: 3, gas: 5500000, confirmations: 2, timeoutBlocks: 200, skipDryRun: true }, ropsten: { provider: () => new ...


1

Not sure if this is the best method, but the arguments you pass to truffle, including the network, are available under process.argv. script.js: process.argv.forEach(function (val, index, array) { console.log(index + ': ' + val); }); Then: > truffle exec script.js --network development Using network 'development'. 0: /usr/bin/node 1: /usr/bin/...


1

I get the transactionhash, as it verified I believe you are mistaken about this. The returned value from ...newTransact() is a transaction hash. This is an acknowledgment that the transaction was submitted, not a confirmation that it was mined. That transaction will hang around in the transaction pool for a little while before it is included in a block. ...


0

Use the truffle assertions library and as goodvibration said don't forget the await const truffleAssert = require('truffle-assertions'); ... it('should fail', async function () { await truffleAssert.fails(<your_contract>.<your_function>(..., { from: ... })); }); https://www.npmjs.com/package/truffle-assertions


1

It looks like this issue: https://github.com/ethereum/go-ethereum/issues/19424. Because you were sending LES/1 version of transaction through LES/2 protocol. I think the only way to fix this is upgrade the geth.


1

Turns out truffle test automatically starts a ganache instance if there is no test network. See the github issue. The truffle test --network foo seems to fall back to the default instance if the network foo is down.


0

One of the ways is that you can purchase or try free tier ec2 instance of AWS for deploy and install truffle over there then you can access it globally. Hope this will help you.


0

You can follow the tutorial on this site: https://truffleframework.com/tutorials/using-infura-custom-provider.


0

Solidity got bunch on backward incompatible changes between 0.4.24 (last released 0.4.x version) and 0.5.0. Strictly speaking, solidity 0.4.x and 0.5.x are different programming languages, and the former is not maintained anymore. You have to either modify your code to comply with Solidity 0.5.x, or install solidity 0.4.24 side by side with 0.5.x and make ...


1

I had the same problem with truffle-hdwallet-provider@1.0.0-web3one.0. Upgrade to truffle-hdwallet-provider@1.0.8 solved the problem.


0

You don't have a compilation problem, you have a runtime problem. The statement mTokenAddress = address(new ERC20(name, decimals, symbol, totalSupply)); is compiled successfully. The runtime problem takes place when you execute the script 2_deploy_contracts.js. Although you haven't posted the contents of this script, I am inclined to guess that you pass 4 ...


0

I think the problem is in your config: module.exports = { networks: { development: { host: 'localhost', port: 8545, network_id: '*', compilers: { solc: { version: "^0.4.24", // this line optimizer: { enabled: true, runs: 200 } } } If you want to use v5, you have to change to appropriate ...


0

You declared _totalSupply as uint256 private _totalSupply = 10000 * (10 ** uint256(decimals)); Since it's a private variable inside your base contract, you won't be able to call it from any of your derived contracts (Reason). Now, it's even simpler to bypass the same in Solidity ^0.5.0: pragma solidity ^0.5.0; import 'openzeppelin-solidity/contracts/...


2

A require(cond, msg) statement is technically a "shortcut" for: if (cond) /* do some stuff */; else revert(msg); Hence an E in the solidity-coverage report means that although the if case has been covered, the else case has not been covered. In your specific case, the function has been executed only with to != address(0). In order to cover the ...


0

So found the reason: 1. The contract should be deployed 2. You need to send a deposit you can implement own function in your contract.sol function deposit() public payable { get_relay_hub().depositFor.value(msg.value)(address(this)); } or use external script like http://gsn.tabookey.com/webtools/contractmanager.html 3. For tests you ...


0

You need to define the address as a constant in the deployment file: const MyAddress = '0x123...' deployer.deploy(MyContract, MyAddress)


0

This question inspired me to create truffle-test-generator. It's not perfect, and follows my own style-guide for Truffle tests, but it should be useful for getting the initial boilerplate of a Truffle test done. It reads the json file of your compiled contracts and creates a describe block for all external and public functions. It can also create the input ...


0

Function getMessageString takes 0 parameters, yet you are calling it with 1 parameter. Therefore, change this: messageInstance.getMessageString(function(error, result) To something like this: messageInstance.getMessageString().then(function(result)


0

The solution is in the error message you shared. Truffle is currently using solc 0.5.0, but one or more of your contracts specify "pragma solidity ^ 0.5.2". Since your version of truffle uses solc 0.5.0 which can only compile files using a Solidity version up to 0.5.0. If you want it to work, change pragma solidity ^ 0.5.2; to pragma solidity ^0.5.0;


1

That property was required by SOLC compilers lower or equal to version 0.4.8 as it is explained at this Truffle Github issue Modify your solidity code and the truffle-config.json to use at least version 0.4.9. I hope that answer solves your problem. It did to me


2

This is tracked by Truffle issue #1879. (Not entirely sure what the code flow would be after its implementation, but getTruffleConfig.js might be a good place to start having a poke around if you're feeling brave.)


0

I resorted to checking for some environment variables in the truffle-config.js file, although I'm not fully satisfied by this solution. I'll keep this thread open until I find a better alternative.


1

You should try the same as suggested by Ismael. But this will work in two cmd commands like this if you try only account = (await web3.eth.getAccounts())[3]. This will give you undefined . You should try like this truffle(development) > account = (await web3.eth.getAccounts())[3] undefined truffle(development) > account


0

tokenInstance is an instance of DappTokenSale, which indeed does not have a method called balanceOf. So the issue is exactly what the error message says.


1

It seems tokenInstance is improperly initialized in 'end token sale'. it('end token sale', function() { // Here it should be DappToken and not DappTokenSale // like in your unit test // vvvvvvvvv return DappToken.deployed().then(function(instance){ tokenInstance = instance; return DappTokenSale.deployed(); })....


0

You have too many }); in your code. As you can see from the indentation you end up the contract part too early so the admin variable is no longer in the scope. Just remove one }); before end token sale and it should work as far as I can see.


Top 50 recent answers are included