Questions tagged [solidity-0.6.x]

Solidity is a contract-oriented, high-level language whose syntax is similar to that of JavaScript and it is designed for writing smart contracts in Ethereum to run on the EVM. Solidity is statically typed, supports inheritance, libraries and complex user-defined types among other features. Solidity version 0.6.0 is a specific version that includes a number of changes to the language and introduce new features.

Filter by
Sorted by
Tagged with
0
votes
0answers
15 views

How to send ether to call fallback function

Im currently working on a project which can create a uniswap liquidity pool on the fallback function however the transaction is not even broadcasted to the blockchain when trying to send some ETH via ...
0
votes
0answers
11 views

Getting the same hashes on the web3 and Solidity side

How can I repeat this operation on web3.js and get the same hash function test(uint a, uint b) pure public returns (bytes32) { bytes32 hash = keccak256(abi.encodePacked(uint40(a), b); return ...
0
votes
1answer
50 views

swapTokensForEth transaction fail when called within a contract in a swap

I have this token test contract: The contract has a transaction tax of 1%. The transaction fee is converted to (myContractToken to bnb) and sent to a wallet. It is used the balance of the token that ...
0
votes
2answers
77 views

I wonder where this hack started from

before I start, let me first give you the txn history. https://polygonscan.com/tx/0xc7927d4a8b0549dfd650eeab8b9570195d8fb9161884785e9b328c04b6a49232 And also adding my Metamask adress history for WETH....
0
votes
1answer
26 views

Alter data in a struct using solidity

I am trying to create a students record using remix I am trying to replace data from an already stored struct. How can I do that? Below is my implementation untill now. contract StudentContract { ...
1
vote
0answers
45 views

Include library function without function body

Using solc 0.5.0 it's possible to compile a contract that has a library function implemented with no body. For example: library Hasher { function MiMCSponge(uint256 in_xL, uint256 in_xR) external ...
0
votes
1answer
59 views

How to compile solidity docs for a particular compiler version

Im trying to run solc --userdoc --devdoc myContract.sol to generate docs. However, the compiler complains that the contract has a different pragma-version. In fact the contract pragma is at ^0.6.0 ...
0
votes
1answer
239 views

NotFoundError: Key not found in database [hn]

I'm playing Ethernaut (https://ethernaut.openzeppelin.com/). I'm currently on level 3 (Coin Flip). This is the Coin Flip contract: // SPDX-License-Identifier: MIT pragma solidity ^0.6.0; import '@...
1
vote
2answers
28 views

Getting an error even using the same compiler version (Visual Code)

I made a contract using Remix and it's working perfectly. When I create a project in Visual Code (in order to make a DApp) I'm getting this error when I import a source of Chainlink: If I compile ...
1
vote
1answer
65 views

What is the ':= ' operator?

I am familiar with the walrus operator := in Python but cannot understand its use in solidity. A sample snippet is : assembly { codehash := extcodehash(account) }
0
votes
0answers
31 views

TypeError: No matching declaration found after argument-dependent lookup

How do I fix this? TypeError: No matching declaration found after argument-dependent lookup. require(instance.execfunct(address(this),2100,gaslimit,hex"00")); ^-----^ Candidate: function ...
0
votes
0answers
38 views

ParserError: Expected ';' but got '{'"?

ParserError: Expected ';' but got '{' aion.ScheduleCall{value:callCost}( block.timestamp + 1 minutes, address(this), 0, 200000, 1e9, data, true); pragma solidity ^0.6.0; contract Aion2 { using ...
0
votes
1answer
32 views

I read the description, but I don't understand it. Thank you for every day

ParserError: Expected type name function execfunct pragma solidity ^0.6.05; abstract contract AionClient is Aion, Context, Ownable{ using SafeMath for uint256; address private AionAddress; ...
2
votes
1answer
38 views

delegatecall call internal functions from caller contract

Is it possible to call internal functions from a function called using delegatecall? Contract A call contract B using delegatecall, contract B needs to call an internal function from contract A.
1
vote
1answer
23 views

call method in compiler 0.8

how can i change this for older compiler versions like 0.4.24? (bool success, ) = transaction.to.call{value: transaction.value}(transaction.data); and if you have time please explain to me the call ...
0
votes
1answer
20 views

Error Occurred while changing compiler version

below is my contract with compiler version >=0.6.0. when I change the compiler version ^0.8.2 I am getting error as: Return argument type address is not implicitly convertible to expected type (...
0
votes
0answers
35 views

How to deploy a smart contract? [duplicate]

I have the stupidest question. I have the source code of a smart-contract written in solidity. In Remix, it compiles normally, in the BSC test network, transactions pass. And actually, what to do next?...
0
votes
0answers
314 views

How To Copy And Paste Token Code

i want to copy and paste this code and use it for my token just want to change symbol and everything . https://bscscan.com/address/0xf38acb6cea8f6701b06ec759f6cbc3fe23f377d3#code i try to post code ...
0
votes
0answers
16 views

Vesting contract is throwing an error 'subtraction overflow'

I scripted a contract for token vesting taking clue from VestingVault.sol But when I run function addTokenGrant(), it throws an error of subtraction overflow. I believe the error is coming from ...
0
votes
0answers
14 views

Is it possible to derive multiple public addresses for a smart contract to receive ERC-20 tokens?

I have a smart contract that deposits user's fund in the AAVE lending pool on behalf of users: lendingPool.deposit(stableCoinAddress, amount, address(this), 0) Users can deposit at different times ...
1
vote
1answer
358 views

How to call a function in parent contract from children contract?

I am new to solidity.. please bear with my foolish question I would like to get the variable called num in a parent contract from its children. So, what I have in my mind is to try to get the address ...
0
votes
0answers
17 views

Issue with Solidity Payable function?

I get error when I try to call this function AvailableEnergyAdvert with energy_produced greater value > 1. pragma solidity ^0.6.0; import "https://github.com/OpenZeppelin/openzeppelin-...
0
votes
2answers
70 views

How to I initialise an array inside the contructor in solidity?

I'm using the remix IDE.I want to define the size of the array at the time constructor is called. Someone please help. This is what I tried : pragma solidity >=0.7.0 <0.8.0; contract Vote { ...
0
votes
1answer
720 views

getting data from events

versions: solidity 6.0.0 python3.8 web3 5.13.1 I am trying to get return data from a smart contract function that changes a struct on the contract. I cannot do that using return because the ...
0
votes
1answer
101 views

Hyperledger Besu: Unable to decode the hex string returned by solidity function containing multiple values

I have set up a Hyperledger Besu network for private transactions using Orion. I am using a javascript client to write to and read data from a smart contract written in Solidity. I am following the ...
1
vote
0answers
48 views

TypeError: Library functions must be implemented if declared for solc compiler version ^0.6.0 library implementation

Suppose I have the following code: // SPDX-License-Identifier: MIT pragma solidity >=0.4.21 <0.7.0; library SomeLib { function add(uint256 a, uint256 b) public returns(uint256); } contract ...
0
votes
1answer
34 views

Sending Ether between two contracts not working

I am trying to transfer some Ether between two contracts but it is just not working for me. Here is my code: pragma solidity ^0.6.0; contract ContractA { uint public tips; /** * ...
0
votes
0answers
37 views

amount of gas used in receive and fallback functions in truffle tests

I have a contract that is written in solidity ^0.6.4 and has a simple implementation of reverting funds when someone directly transfers some eth or calls an unhandled function. Now it appears to be ...
1
vote
1answer
1k views

How to deposit to WETH in Solidity 0.6 and above?

Solidity 0.6.0 introduced a breaking change in how ETH transfers are performed. The following doesn't work anymore: weth.deposit.value(amount)(); What is the latest syntax for depositing ETH into the ...
1
vote
0answers
33 views

What's the difference between this.function() and function() in recursion?

I stumbled across some odd behavior that I can't explain regarding recursive functions in Solidity. As a note, I have attempted to run this on ganache in case it is actually ganache that is throwing ...
2
votes
1answer
204 views

Calling super class external functions

Is there a way in Solidity to call super class external functions? Normally with inherited contracts, when overriding inherited functions you can also call the original function logic with super....
0
votes
0answers
20 views

Issuing 1-1 eth for token problem

pragma solidity 0.6.6; // import "./XYZToken.sol"; contract Vault { mapping(address => uint256) balanceOf; mapping(address => bool) hasDepositedEther; mapping(...
0
votes
1answer
45 views

Transfer funds to inherited smart contracts [closed]

How would I make this work - the balanceOf[Pool, System + Cube] doesn't seem to work ;-; // SPDX-License-Identifier: GPLv2 pragma solidity ^0.7.0; import "./Pool.sol"; import "./Cube....
6
votes
1answer
958 views

How to import both VRFConsumerBase and ChainlinkClient in same contract

I would like to use 2 of the functionalities of Chainlink, One is VRF and another is making API requests. So I am importing two libraries together. ChainlinkClient.sol and VRFConsumerBase.sol Which ...
1
vote
1answer
262 views

Using inherited constructor in Solidity >=0.5.0

I want to use a contract inherit from another contract and use the parent constructor after using another commands in inherited constructor. So I wrote: pragma solidity ^0.5.10; contract A { ...
1
vote
1answer
23 views

Payable function that should not accept the money if X but still write changes

I have a function that is payable. Upon some checks, if it meet the condition, it should write some changes BUT refund the payable amount that was just sent. See: function rent(uint256 tokenId, ...
1
vote
0answers
159 views

How to get event from geth ethereum node using web3.js

I have created a simple contract where I am trying to write a value to a state variable in solidity smart contract, and emit that written value. I am using Truffle v5.1.28 (core: 5.1.28) Solidity - 0....
0
votes
1answer
172 views

Issue with dynamic matrices in solidity

I have a matrix in solidity like that string x[][] I'm trying to write functions to return rows and colums The following code works well: // SPDX-License-Identifier: unlicensed pragma solidity ^0.6.0; ...
0
votes
1answer
194 views

Convert a string in scientific notation to a number

my smart contract uses an Oracle to retrieve the price. The price is returned as a string in scientific notation, for example, "3e-8". How I can convert this to number (uint)? The token has ...
0
votes
0answers
515 views

When to use "memory" and "storage" keyword in solidity 0.6.0?

From what I've learned and noticed. Please add more point and rectify me if I'm wrong. Use of memory keyword 1)When initialising/declaring Struct, Array , and mapping. 2)In the parameters of functions ...
1
vote
1answer
116 views

Why fallback function cannot be declared public in solidity?

When declaring fallback function we needs to make sure that it is declared external but why fallback function cannot be declared as public. Since external is a subset of public why can't we declare ...
0
votes
1answer
168 views

Deleting an array in storage (>= 0.6.0)

I need to add elements to a resizable myArray and then delete the myArray. I don't know what the length of myArray will be before the loop, and it's not possible to resize a memory array; that leaves ...
0
votes
0answers
184 views

Weird error during buy tokens with eth on ropsten and other testnets

I get this error when executing swap token for ether on arb detection. Error Message: execution reverted (uint reserve0, uint reserve1,) = IUniswapV2Pair(pairFor(factory, tokenA, tokenB)).getReserves()...
0
votes
1answer
255 views

Adding Struct to Array - Invalid OpCode - Solidity 0.6

I've been wreaking my brain on this for a while, could use some help. Bottomline, the newProposal function throws an VM Exception while processing transaction: invalid opcode error. The puzzling thing ...
0
votes
1answer
69 views

Solidity ^0.6.10 returnBalance() returns "VM Exception while processing transaction: invalid opcode"

I am using Ganache and Truffle console. I compile and migrate the following contract: // SPDX-License-Identifier: MIT pragma solidity ^0.6.10; contract EthReceiver { address payable private owner;...
1
vote
1answer
3k views

Solidity Smart Contract withdrawal ETH with amount from contract address does not work

I have below smart contract and a test program to test transfer ETH out of contract address, but contract’s ETH balance not changed. I tested withdrawAmount(uint256 amount) but the assertion error ...
3
votes
1answer
2k views

Solidity ^0.6.0 Truffle Compile Error: Cannot read property ... of undefined

I initalised a new truffle project by using truffle init. I changed the solc version to ^0.6.0 in the truffle-config.js file. I ran truffle compile and got this error: TypeError: Error parsing C:/init-...
0
votes
1answer
82 views

Return multiple values from diferent smart Contracts

I have two contracts. The first contract has a function called get() that returns this values: uint _value1 address _value2 address _value3 string memory _value4 string memory _value5 uint _value6 ...
0
votes
1answer
643 views

Error compiling OpenZeppelin 3.0 ERC20 using Truffle

I'm trying to compile this code using the Truffle command truffle compile pragma solidity ^0.6.0; import "@openzeppelin/contracts/token/ERC20/ERC20.sol"; contract GLDToken is ERC20 { ...
1
vote
0answers
217 views

Remix contract balance transfers Failing (Metamask / JS VM)

There is an issue with my smart contract not transferring any funds to any other address on the connected ganache instance. Regardless if I choose "JavaScript VM" or connect to my Remix, the ...