Hot answers tagged

4

EDIT: I recommend using Buidler! The key feature their software provides is modularity, where compilation and testing of contracts can be done separately. Migration from Truffle is also seamless, as specified in their guide. What you can do is to specify 2 separate configuration files for compilation of your v4 and v5 contracts, then use the --config flag. ...


3

Error says it all, you need to break down your struct data. Either separate it to different structs, contracts or keep some of the data offchain (database), make connection/ linking with unique parameter and save that unique parameter into the struct. Another solution is what I did for another project I had to save many variables including files for single ...


3

You may want to take a look at the docs on Layout of a Solidity Source File. The solidity compiler can only reference files that exist locally on your computer. So importing directly from GitHub (as an example) is not possible. Now, let's imagine you want to use OpenZeppelin's amazing library of smart contracts, @openzeppelin/contracts-ethereum-package: ...


3

I have had a similar error, then I realized the culprit in this case was in fact a malfunctioning VS Code plugin not Solidity nor truffle. Please check your plugins list in VS Code and see if one of your plugins is called "Solidity Extended" by beaugunderson and disable it.


3

Yes, list.push will not return the length of it anymore. From https://solidity.readthedocs.io/en/v0.6.0/060-breaking-changes.html#how-to-update-your-code: Change uint length = array.push(value) to array.push(value);. The new length can be accessed via array.length. So, now you must do it "manually": pragma solidity 0.6.0; contract Test { struct ...


3

Per this comment on solc-js issue #31, you can append this stanza to package.json. "jest": { "testEnvironment": "node" } (which I guess tells jest to run in node, which will bring in the things that solc needs).


3

You can modify the AST and generate new source code from the AST using this tool: https://github.com/chao-peng/SIF


3

Below calculations are valid as of 09 December 2019 on Ethereum mainnet. My guess is that most of the confusion comes from the fact that constant of 2300 is used both by Solidity compiler and EVM itself. Here is what I've found so far (assuming that target account is an already created, and not self destructed, contract). EVM: During the CALL(gas, ..., ...


2

This is all wrong: var result = await contractDeployed.methods.getOwner().call(); console.log('\tgetOwner: ' + result); // Works contractDeployed.methods.setTestData('testing store data').call() .then(result => { console.log('\tSet: ' + result); contractDeployed.methods.getTestData().call() ...


2

Truffle installs its own internal version of solcjs. If you're on Truffle 5.x, then you can configure it (after the installation) to use a different compiler for the various commands that it provides (truffle compile, truffle test, truffle deploy, etc). In your Truffle configuration file (truffle.js or truffle-config.js), add this section: compilers: { ...


2

Truffle is not using solc. You can see what it IS using with ./truffle version This is a little ambiguous, IMO. pragma solidity ^0.5.5; In practice, what I like to do is specify exactly what compiler to use for top-level contracts and ^ for inherited contracts and libraries. That way, the toolchain will emit an error at the first sign of an ...


2

Just a guess because the link seems to be dead, but maybe you're using libraries? From https://solidity.readthedocs.io/en/v0.5.11/using-the-compiler.html: If your contracts use libraries, you will notice that the bytecode contains substrings of the form __$53aea86b7d70b31448b230b20ae141a537$__. These are placeholders for the actual library addresses. The ...


2

I figured it out... You have to cast the uint to the same length so in this case it would be: bytes28 bar = bytes28(uint224(foo)); If it were bytes16 it would be: bytes16 bar = bytes28(uint128(foo)); bytes vs bits: 28 / 32 == 224 / 256 16 / 32 == 128 / 256


2

ERC20Detailed's constructor receives three parameters to use ERC20Detailed you should pass those three parameters. The problem is that VrapzCoin inherits from ERC20Detailed and never initializes it correctly. Since those parameters are not used you can remove them, and the contract should compile constructor() public { _name = 'VrapzCoin'; _symbol ...


1

You could get rid of it in the function-call as well, i.e.: (uint128 stakeId, address behalf) = abi.decode(userData, (uint128, address)); But I suppose that would just beat your purpose to begin with. So the quickest workaround which comes to mind is to just add a dummy reference: (uint8 _, uint128 stakeId, address behalf) = abi.decode(userData, (uint8, ...


1

What are you doing here is fetching the 'bytecode' only from the JSON map. output.contracts["test.sol"][contractName].evm.bytecode.object The code snippet above is going in: contracts -> .sol file -> file_name object -> evm -> bytecode if you look closely in this console.log: console.log(output.contracts["test.sol"]["test"]); you will notice that it ...


1

Constructor arguments are passed during deployment, not during compilation.


1

Is there any difference if I compile everytime I want to deploy another multisig wallet. No, provided you haven't changed anything in the contract. In case if you haven't changed anything in the contract and try compiling it again, truffle returns the below result > truffle compile Compiling your contracts... =========================== > Everything ...


1

You have to covert the arguments to a bytes. abi.encodePacked(args) is a way to do it. pragma solidity 0.5.9; contract test{ //https://github.com/ethereum/solidity/issues/3469 address payable owner; mapping (address => bool) pd; uint public sS; function lnA(address addr) public view returns(uint8 n) { // 1 in 8 chance ...


1

According to this, you have used a gas-price of 0.00000000003 Ether (0.03 Gwei (30,000,000 wei)). According to your question, you have used in your transaction a gas-price of 1,050,000,000 wei. Conclusion: you are not telling the truth (though you are probably not doing it intentionally).


1

Assuming that is a TypeScript compile error, add a file at src/typings.d.ts containing: declare var BrowserSolc: any; That just let's the compiler know that BrowserSolc is a real thing even tho it can't see it (because the TypeScript compiler does not load the scripts in tags).


1

I maintain a Python library called py-solc-x that allows you to install and use multiple versions of solc at the same time. It supports versions >=0.4.11. I've included some code examples below to give an idea of how it works. Installing a new version of solc: >>> from solcx import install_solc >>> install_solc('v0.4.25') Checking ...


1

There are a couple of ways to do this and the Solidity documentation has a page on it: Keep in mind you have the option to use the "cli binary" version (solc-bin) which is quite faster than the solcjs ( javascript implementation ). In addition to all of these, if you use truffle, you can specify which version you would like to use with it in your truffle-...


1

OK, just found this very useful post which refers exactly to this specific problem! The proposed solution does indeed make use of the returndatasize instruction (that's how I found it, but then again, I've only become aware of this instruction while tagging this question, so I guess I had to go through the process of writig it in order to get to the answer)....


1

you are using old api on new version of solc. here is the implementation. const lotteryPath = path.resolve(__dirname, 'contracts', 'Lottery.sol'); const source = fs.readFileSync(lotteryPath, 'utf8'); var input = { language: "Solidity", sources: { "test.sol": { content: source } }, settings: { outputSelection: { "*": { "*": ["*"] ...


1

Brownie allows you to use multiple versions of solidity within the same project. All that's required is setting the compiler version to null within your project's config file. From the documentation: If the version is set to null, Brownie looks at the version pragma of each contract and uses the latest matching compiler version that has been installed. If ...


1

You are making a call, which will treat the function as view and it will not generate a transaction. contractDeployed.methods.setTestData('testing store data').call() You have to use send (like in deploy) contractDeployed.methods.setTestData('testing store data').send({ from: address })


1

The reason for this error is that truffle compile does some path remapping magic to find files which are imported from the node_modules folder. If you are using the command line compiler version of solc, you need to provide it these path remappings yourself. The following command should work if it is run from the same directory as the node_modules dir: ...


1

I found useful this solc version switcher tool https://github.com/crytic/solc-select. My experience to configure it: docker pull trailofbits/solc-select manually add https://raw.githubusercontent.com/crytic/solc-select/master/bin/solc to any location add permissions to execute the script to the owner chmod u+x ... add location from 2. to .bash_profile Now ...


1

Elsewhere in the contract, find address admin; and declare it as address payable admin;. Alternatively, selfdestruct(msg.sender); because require(msg.sender == admin); ensures they are the same and msg.sender should be payable.


Only top voted, non community-wiki answers of a minimum length are eligible