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
-1
votes
0answers
17 views

why TransferFrom is not working in Airdrop [closed]

address[] public dests; uint256[] public values; function multiSend(address _tokenAddr) public returns (uint256) { dests.push(0x5ed22c0B67A1775B64F76eB00A1243FfA259B1A0); dests.push(...
2
votes
1answer
31 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
44 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
18 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
23 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
27 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
45 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
48 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
27 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
54 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
50 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
32 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
41 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;...
0
votes
1answer
122 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 ...
0
votes
0answers
29 views

Polymorphism in Solidity

I understand that Solidity supports contract polymorphism, but what pattern would one use to create abstract data types for use in derived contracts? Motivating example: Say I have an abstract Storage ...
0
votes
0answers
28 views

Ether Transaction failed to crowdsale contract

I have deployed a token on ropsten. it works and i can transfer tokens. Now i deployed crowdsale contract but when i send ether to crowdsale contract the transaction fails. I am using remix and ...
2
votes
1answer
337 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
30 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
149 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 { ...
0
votes
0answers
53 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 ...
0
votes
1answer
43 views

Why solidity doesn't use “ Null ” and “undefined”?

Like Python or any other language why does Solidity avoid having the Null and undefined properties?
3
votes
1answer
49 views

Do we have 'null' keyword in solidity?

Like other languages , Does solidity supports 'Null' keyword.
1
vote
1answer
30 views

Is there an “after” keyword in Solidity?

This is to avoid any further question in the future.
2
votes
1answer
42 views

Is “type” a reserved keyword in Solidity?

If I define the following struct like this: struct MyStruct { uint256 type; } The Solidity compiler throws an error: Expected identifier but got 'type' I checked to have no mistake in my code ...
0
votes
0answers
33 views

Error calling view function: Returned values aren't valid, did it run Out of Gas?

I compiled my code on 0.6.6 solidity compiler and the code ABI for the function im calling is: { "inputs": [{ "internalType": "address", "name": "user", "type": "address" }], "name": "getAssetIds", "...
0
votes
1answer
25 views

Function withdrawReward “The transaction has been reverted to the initial state”

Dear colleagues of the Ethereum environment, I'm learning to code Solidity in a intermediate level. Trying to adapt existing old 0.4.19 contract for a experiment of crypto-investment fund. I have a ...
0
votes
1answer
31 views

Can't call coinFlip() function the second time

The first time when i run this it runs fine but the second time when i call the coinFlip() function it shows gas estimation failed can someone tell me why it is happening. pragma solidity ^0.6.0; ...
0
votes
1answer
55 views

What are the flaws of this example contract?

I am currently writing a paper/article on tokenization, in the beginning of which I introduce smart contracts. To this end, I present the following contract as an example: pragma solidity ^0.6.0; ...
2
votes
1answer
52 views

How to properly define an interface in Solidity 0.6?

One of the breaking changes of solidity 0.5 was making explicit function visibility mandatory, hence all interface functions must be defined as external today. In solidity 0.6, there seems to be two ...
3
votes
0answers
50 views

Passing constructor arguments from child contract to parent contract

The ERC721 standard contract requires a token name and symbol in its constructor. I have inheritance pattern that looks likes Contract A is B and Contract B is ERC721. If I want to set my token name ...
0
votes
1answer
50 views

Withdraw balance from external contract in Solidity 0.6

Getting two errors with the following code. abstract contract ReceiveBalanceContract is Ownable { receive() external payable { require(msg.sender == address(SendBalanceContract)); } ...
0
votes
0answers
14 views

Can I check whether any deployed contract has implemented some particular interface or not?

My concern is whether I can do interface detection with my own interface,,, Like suppose, i have implemented some interface say loyalty interface in my one contract and I have deployed that contract ,...
1
vote
1answer
75 views

can anyone explain why call, delegateCall, staticCall functions in solidity are called low level functions?

As i have read at many resources, that these functions are low level functions. I want to know, should i use these methods to interact with already deployed contracts or not ?
0
votes
3answers
45 views

Can i know by any method whether the particular address is contract address or simple ethereum address?

Here is the problem I am facing. I am calling some function of already deployed contract using its contract address. Below are the lines of code :- function registerYourBrand(string memory brand, ...
0
votes
1answer
30 views

Can I change state of mapping variable in deployed contract from another contract?

I am calling addCoin and subCoin function of my AirToken contract and Hotel contract. This is function defination of addCoin and subCoin in AirToken contract and Hotel contract function addCoin(...
5
votes
2answers
81 views

Can anyone explain how bytes memory can be converted to address type in solidity

when I am using below function to convert bytes memory to address, this is working fine. Suppose input to the function is 0X0000000000000000000000004af3246b4fff356261136f113411cb187134D675 I am ...
1
vote
1answer
47 views

API node js with call and send to a contract without metamask

I am new in Solidity. I'm trying to create a API in node js, which can be use without a navigator like chrome with MetaMask. I would like to test it with postman. But i have some problems with web to ...
0
votes
0answers
66 views

Deploy contract with web3 with ABI in JSON file give me “SyntaxError: Unexpected token o in JSON at position 1” [duplicate]

I got problem with my deploy.js script to te deploy my smart contract with web3. When I run it, I always got this error: Attempting to deploy from account XXXXXXXXXXXXXX (node:25929) ...
0
votes
2answers
19 views

Function to check string is only formed by lowercase letters [closed]

I have a string and I want to pass a test on it .. if it is formed by lowercase letters or not . how to do that please ?
0
votes
1answer
48 views

Remix not showing function buttons after the contract is successfully deployed

I am expecting Remix to show me buttons through which I could interact with the contract functions once I have deployed it successfully but the buttons are not showing you as can be seen in the below ...
0
votes
1answer
26 views

Sha256 and abi.encode of number

If I calculate the following in Solidity 0.6.3: bytes memory secretSalt = "abc"; hashedSecret = sha256(abi.encodePacked(secretSalt)) I get the result "...
1
vote
2answers
378 views

ParserError: Expected '{' but got reserved keyword 'override'

Can someone explain to me about this error? I just tried override feature in Solidity v0.6, but I got error Expected '{' but got reserved keyword 'override' function totalSupply() public override ...
0
votes
1answer
108 views

Overriding a function

I am trying the function override capability in solidity 0.6.0. However, when I am trying to override a function in the same contract it is giving me an error that the function has been defined twice....
0
votes
1answer
38 views

Calling another contract's state-changing function as view function

In Web3 we can do TestContract.methods.myMethod(myParam).call() to call a state changing function without executing it. But I am wondering if this is possible in Solidity or inline-assembly? So in ...
1
vote
1answer
20 views

Can I see an example that shows the use of .arrays and push(unint x) method in solidity 0.6?

I'm having problem to understand why the method push() does't work on Remix using Solidity 0.6. I have read the documentation about arrays fixed size and dynamic size doc reference for example in ...
1
vote
1answer
109 views

What is the difference between the constant and immutable keywords in Solidity?

What is the difference between the constant and immutable keywords in Solidity and how do I use them?
2
votes
1answer
342 views

What is the immutable keyword in Solidity?

What is the immutable keyword in Solidity and how do I use it?
0
votes
1answer
74 views

Which is the best way to interact between smart contracts for complex scenarios (solidity 0.6)?

I'm learning about Solidity. I would like to write a complex scenario of demo to test the power of Solidity and smart contracts. My doubts are about interaction between smart contracts. If there ...
0
votes
1answer
28 views

how to disable a contract by changing some internal state which causes all functions to revert?

In official documentation of Solidity about Self-destruct instruction is written: If you want to deactivate your contracts, you should instead disable them by changing some internal state which ...
2
votes
1answer
978 views

What is the receive keyword in solidity?

Solidity has a receive keyword. What is it and how do I use it?