Hot answers tagged

5

As of Solidity 0.5.0, there are two different address types in solidity: address and address payable. You can only transfer funds to an address payable. Therefore, your problem will be fixed by making admin an address payable: address payable admin;


4

The contract prologue instructions changed to provide an additional slot at 0x60, which should always hold the value 0. The documentation states that: The zero slot is used as initial value for dynamic memory arrays and should never be written to (the free memory pointer points to 0x80 initially). FYI I checked several contracts with JEB Decompiler, ...


3

It looks to me like the only difference in the emitted bytecode is in the contract metadata hash. This is likely due to something like using a different source file name.


3

In a Solidity constructor: this is the address of the contract that is being constructed. (even after using new or calling an external function of another contract) msg.sender is the address of whoever or whatever is deploying the contract. (user account or another contract using new) You cannot call external functions on a contract that is being ...


3

You'll need to use a proper 20-byte address. In this case, you want the quoted string: "0x0000000000000000000000000000000000000000".


3

Ultimately, the fix was to implement FooFactory as public: contract FooFactory { function createInstance(address[] memory _addrs) public { new Foo(_addrs); } } but another fix would be to remove the pragma experimental ABIEncoderV2; line if you don't need it. Compiler line throwing this error


3

The "3 days ago" is version agnostic: it just means the package, regardless of version, was last updated then. If you look at the version history tab (the purple tab on the right): Version History 5.0.0-next.18 ...... 3 days ago 5.0.0-beta.2 ..... 12 days ago ... You'll also notice that the tagged latest version is 4.1.14, whereas all 5.0 releases are ...


3

Thanks for this! Ended up doing: node --stack-size=4096 .\node_modules\truffle\build\cli.bundled.js compile, instead of truffle compile (after taking a look in node_modules/.bin/truffle). EDIT: on Ubuntu this works too: node --stack-size=4096 node_modules/.bin/truffle compile


3

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


3

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

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: ...


2

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).


2

The format is function accessTheString(string calldata _uri) external{ string memory contractString= _uri; } Now, I think you made a mistake while calling the function by without passing string between " ". You have to call function accessTheString, by passing a string enclosed in " " ex: accessTheString("hello"); I tested this in remix, and ...


2

The default is “I do not care about gas consumption, not when deploying and not when running. Just give me a bytecode easy to debug.” As a matter of fact the code size shall be bigger than the minimum and the execution cost shall be bigger than the minimum, but the mapping from source code to bytecode shall be as detailed and straight and clear as it can be....


2

solc can't get things over a network - it can only import local files, which was your initial error. I'm assuming your npm install step is still leading to failure because the compiler is still looking in the wrong place. (I'd assume the OpenZeppelin stuff has gone into the node_modules folder.) Take a look at how to manually map in localised - i.e. ...


2

Alright, I've found the answer after digging a little bit more into remix's compilation option. It seems that right now, the default setting on remix is: evmVersion: "petersburg" Whereas on Truffle it is set to evmVersion: "byzantium" Setting explicitely byzantium in truffle-config fixed the bytecode, and it's now exactly the same as remix's bytecode.


2

Found the answer. It turns out that the web3 options aren't exactly optional for Ganache: I had to change: const provider = ganache.provider() const web3 = new Web3(provider); To: const provider = ganache.provider() const OPTIONS = { defaultBlock: "latest", transactionConfirmationBlocks: 1, transactionBlockTimeout: 5 }; const web3 = new Web3(...


2

you need to see the new document. here that article is too old. var solc = require('solc') var input = { language: 'Solidity', sources: { 'test.sol': { content: 'contract C { function f() public { } }' } }, settings: { outputSelection: { '*': { '*': [ '*' ] } ...


2

Looks like you've found a bug in py-solc-x. As far as I can tell, the issue is specific to Windows paths that are given absolutely. I was able to compile successfully by using a path that did not include a drive letter. I am the maintainer of py-solc-x, I will push a new version with a fix as soon as possible. In the short term try running the script from ...


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

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

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 ...


1

When I change input.json to the following, without "file://" and with back-slashes instead of forward-slashes, solc is able to import the URL. { "language": "Solidity", "sources": { "StandardToken.sol": { "urls": [ "\home\myuser\myproject\contracts\vendor\StandardToken.sol" ] } } }


1

New opcodes were introduced in Constantinople/St. Petersburg hard fork. Solidity compiler was able to produce such opcodes since 0.4.24, but this feature became enabled by default only in 0.5.5. Ganache Core supports this opcodes since version 2.5.1, but Ganache 2.0.0-beta.2 is based on Ganache Core 2.3.3. That's why you contract failed to work.


1

That opcode is a recent addition to geth in the Constantinople release. You need to add the following to your genesis to enable Constantinople: "constantinopleBlock":0,


1

Opcode 0x1c is SHR or right shift, which was introduced in the recent update (more here). It was not available prior to February, 2019. It is likely that your Java tool (web3j?) is out dated and does not recognize this opcode. You may be able to upgrade to a newer version which has Constantinople/St. Petersburg support.


1

With Web3(1.0.0-beta.53) I have to set the number of confirmations: const OPTIONS = { defaultBlock: "latest", transactionConfirmationBlocks: 1, transactionBlockTimeout: 5 }; const web3 = new Web3(provider, null, OPTIONS);


1

I found the root cause after opening an issue here. I have multiple Z3 versions and cmake is confused.


1

I think it has to do with your folder permissions. Did you by any chance run sudo npm install truffle-hdwallet-provider? (sudo is the culprit here) I was struggling with exactly the same issue, so out of frustration, I made a new project folder, run truffle init and npm install truffle-hdwallet-provider, copied my contracts and configuration files to the ...


1

It sounds like you're installing solc-js but your code (via the py-solc library) requires solc. It's possible you can get away with renaming (or symlinking) solcjs to solc, but I think the two have different command-line interfaces. A better solution is to actually install solc. See https://solidity.readthedocs.io/en/latest/installing-solidity.html for ...


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