Questions tagged [solidity-0.5.0]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
1
vote
1answer
8 views

What is the unit for the tx.gasprice?

Is it a wei, kwei, mwei, gwei, ... Something else? The API doesn't say much.
0
votes
0answers
25 views

Simple functions and constructors not working

I am working with a private blockchain, and am having a problem where simple functions and constructors simply fail to work. For instance: constructor(address admin) public{ owner = msg....
0
votes
1answer
18 views

How do I get an address with a correct checksum, from an address with an incorrect checksum, using Solidity?

Example of an address with the wrong checksum: 0xa54D3c09E34aC96807c1CC397404bF2B98DC4eFb Example of an address with the right checksum: 0xa54d3c09E34aC96807c1CC397404bF2B98DC4eFb -Difference ...
0
votes
1answer
23 views

Combine BytesX and BytesY to create BytesZ?

I am working on a Solidity Smart Contract (^0.5.10) where I want to return an array of Ratings elements. struct Ratings { address restaurant uint8 score }; Since returning Rating[], string[]...
1
vote
1answer
10 views

ganache test returns characters instead of numbers

mapping(uint256 => uint256) public amount; function saveAmount(uint256 _id, uint256 _amount) public { amount[_id] = _amount; } I have a function that saves amount in mapping. When I test ...
0
votes
1answer
9 views

How does the named return variables in solidity work

I have below solidity contract from Truffle quick start guide. pragma solidity >=0.4.0 <0.6.0; contract TaskMaster { mapping (address=>uint) public balances; ...
0
votes
1answer
18 views

openzeppelin mint sequence

// openzeppelin v5 contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata { constructor (string memory name, string memory symbol) public ERC721Metadata(name, symbol) { // solhint-...
0
votes
1answer
33 views

address payable type error

Just upgraded truffle to version 5 and having a problem with this new address payable type. contract Test { ERC721Full public tokenAddress; constructor(address _address) public { ...
0
votes
3answers
39 views

transferFrom function not working in ICO Smart contract

I am facing issues with the transferFrom function of smart contract address 0x6560a9b6436e129cf835ab9da96201207facd4f8: I copied the smart contract code from etherscan.io and deployed on ropsten ...
0
votes
1answer
32 views

Solidity group addresses with a name. Eg: Whats app groups

I want to create a squad(group) which consists of a group addresses. Like Squad XYZ consists of Addr1 with name 'A',Addr2 with Name 'B', Addr3 with name 'C'. pragma solidity ^0.5.9; contract Squads{ ...
2
votes
0answers
24 views

How Can You Map a Struct Twice With Different Keys?

I have a struct mapped with an address as the key. I want to iterate through all values of that mapping with another key value, in this case a nonce that I generate in the contract. Is this possible? ...
3
votes
1answer
40 views

Why solidity's keccak returns different value from online generators?

I try to implement my own little modifited commit&reveal voting. I have problem with revael phase. Reveal metod signature look like: function reveal(bytes32[] memory _reveals, bytes32[] memory ...
2
votes
2answers
31 views

Geographic location in Solidity

Does solidity have a way of fetching a persons geographic location(using something like msg.sender)? Im building a dApp for national elections, and would need to verify the geographic location before ...
0
votes
1answer
25 views

Deposit event is not call while contract get token

My contract pragma solidity ^0.5.0; contract Transfereventaction { event Deposit( address indexed _from, bytes32 indexed _id, uint _value ); function deposit(...
0
votes
1answer
26 views

uint[] to address with correct checksum

Lets say we have something like this as a given: bytes20 b = bytes20(someAddress); uint8[] memory array = new uint8[](b.length); for (uint256 n = 0; n < b.length; n++) { array[n] = uint8(uint160(...
0
votes
1answer
83 views

Error when testing the contract

ApprovalContract.sol pragma solidity ^0.5.1; contract ApprovalContract{ address public sender; address payable public reciever; address public constant approver=...
2
votes
2answers
127 views

Avoid using “now”

I am using "now" to save the block timestamp details. But there is a warning to avoid its usage. If we need to avoid it what is the best alternative to it.
1
vote
1answer
82 views

Explicit type conversion not allowed from “bytes1” to “uint256”

Just tried to convert byte to uint using Solidity 0.5.x: uint length = uint(arr[i]); and got: MyCode.sol:88:29: TypeError: Explicit type conversion not allowed from "bytes1" to "uint256". ...
0
votes
2answers
31 views

How can I pack two int16 into a single byte32?

I have a contract that makes use of cartesian coordinates. My initial thought is to map a single location (x,y) to a value/struct. I would like to define any given pair of coordinates by a single ...
0
votes
1answer
78 views

How to hash multiple values including array keccak256 Solidity v5.0.x and web3 'Autodetection of array types is not supported.'

How can I receive the same hash in solidity and web3? Multiple values where one is a multi dimensional array. Solidity v0.5.x: pragma solidity 0.5.6; pragma experimental ABIEncoderV2; contract Hash{...
1
vote
3answers
48 views

Verify if an input is a hash

What is the best way to verify that a text I received in mu function is a valid hash? In other words, contains a specified length and is composed only by numbers and "a", "b", "c", "d", "e" or "f"?
0
votes
1answer
19 views

Function to transfer tokens to a second address with fixed percentage

I'm trying to code a transfer function that automatically sends tokens to a second address taking a specific percentage from the original sent value. What I wrote: address public _ExtAddress; ...
0
votes
2answers
30 views

Split State Storage Contract

This is a follow-up question of Split Contract Design Pitfall Background: I have split my logic into two contracts A and B. A keeps the state and not ETH. All state change functions are only allowed ...
1
vote
1answer
44 views

Remix error : Function declared as view but this (potentially) modifies state

i'm following a tutorial but now it is old, because was written more then 1 year ago, with 0.4.24 pragma and i also want upgrade this code. I got this error and i'm pretty sure to know why: view and ...
1
vote
0answers
24 views

How to do loop all the metamask Accounts loop and display data from that address in React frontend + Dapp App JS [duplicate]

I want to Display data stored on the Ropsten Network in more then 2 metamask accounts. I want to display the result on the Home page in the table form. For that I need to loop through each ...
0
votes
1answer
20 views

return array is not showing pushed value

This must be silly question but as a new learner i am trying to understand array in solidity and run this code in remix, compiled and deployed the contract on ropsten platform. I want to see the array ...
0
votes
0answers
22 views

What is best way of setting and getting string=>uint pairs in Solidity?

I am developing a game smart contract and it has 20 numerical settings. like time, fee, difficulty etc I want to access these values using identifier throughout contract get all these values from ...
0
votes
1answer
27 views

solidity 0.4.25 to 0.5.0

when I used 0.4.25, it compiles successfully. function callByFun(address addr)returns (bool){ bytes4 methodId = bytes4(keccak256("increaseAge(string,uint256)")); return addr.call(methodId,"...
1
vote
1answer
34 views

Encryption in Solidity - and yes of course the plaintext will be visible

I am using Solidity to write an Ethereum smart contract. I have a specific use case that requires a piece of data to be encrypted on the chain, despite the fact that both the plaintext and the ...
0
votes
1answer
43 views

Setting array.length to 0 triggers an error on solidity 0.5.0

Why setting array.length to 0 triggers an error ? I have a function that deletes an element from a dynamic array of structs within a mapping as follows: mapping(address => MyStruct[]) public ...
1
vote
1answer
50 views

How to pass a document as function argument(upload document)

I am working on a project in solidity where I want to generate a SHA256 hash value for the document. So which means when I pass a file to a function the function should return the hash value. can ...
0
votes
1answer
35 views

Hash bytes32 and uint32 in Soldiity 0.5.8

How can we efficiently calculate a hash value for a combination of bytes32 and integer value? Like in JavaScript "someString" + someInt. I tried: function fx(bytes32 _left, uint32 _right) public ...
1
vote
1answer
35 views

Event declaration which fix my tests

I'm going to try to put this in simple. This is the code of my contract: pragma solidity ^0.5.0; contract Lottery { address public manager; address[] public players; event Deposit(...
0
votes
1answer
49 views

passing variables between different contract by solidity (0.5.0+ version)

I writed ERC20 contract and ICO contract for a test , but I meet a lot problem with compile problem. My ERC20 contract have own constructor but,I also need a ICO contract(a control)for passing ...
0
votes
1answer
39 views

When I create contract using another contract how could I access his methods in web3js?

Hey I have file 'contractFactory.sol' inside this file I have contract contractFactory{ event contractCreated(string name, address institution, address parent); function createContract( ...
2
votes
1answer
21 views

What is meaning of “address: equivalent to uint160, except for the assumed interpretation and language typing.”?

I'm reading solidity document and cannot understand the meaning of "address: equivalent to uint160, except for the assumed interpretation and language typing." in the doc Does anyone know what is the ...
1
vote
1answer
26 views

Will ERC223 Tokens work after Serenity Update?

Trying to understand what we should expect after External Owned Accounts will be treated as Contracts after second Serenity update will be live. How does it influence ERC223 Tokens, will they break ...
3
votes
1answer
539 views

Timeout exceeded during the transaction confirmation process

I am trying to figure out the right syntax for solc 0.5.7 and web3 1 beta 52 Follow my source code: contract.sol pragma solidity ^0.5; contract Hello { string public message; constructor (...
1
vote
1answer
88 views

Using address.call.value to send ether from contract to contract in 0.5.0 and above

In Solidity v0.4.24 and below, I would send ether from contract to contract using the following code within a bigger function : if (!_address.call.value(_ether)()){ revert(); } ...
1
vote
1answer
331 views

Solidity 0.5.2 - OpenZeppelin - New SafeERC20 callOptionalReturn(token,data)

i've been trying to mix ERC20 functionality with ERC223 function overloading technique and create a bridge for backwards compatibility using SafeERC20. For relevancy sake i renamed SafeERC20 into ...
2
votes
1answer
121 views

Update Solidity - 0.5.4 (ERC20 + ERC677)

I'm trying to create an ERC20 Token that can send Tokens to a Receiver Contract similar to how ERC223 does and i decided to try ERC677 but i can't understand how to update this code to match Solidity ...
1
vote
1answer
31 views

Create Contract Solidity 0.5

My code works with compiler 0.4.25 but not with the latest version. I want to keep track of every "Contract 2" that "Contract 1" create. Contract 1 uint public countContract; address[] public ...
1
vote
2answers
32 views

Why is solidity throwing “Note: The constructor should be payable if you send value. ”, when clearly the issue is elsewhere?

I'm writing a contract on Remix that is able to deploy and track child contracts. Here are the 2 contracts: pragma solidity ^0.5.0; Contract Factory contract ContractFactory{ ChildContract[] ...
0
votes
1answer
70 views

How to test kill function including selfdestruct()?

there. I'm coding kill function below: function kill() public onlyOwner returns (bool) { selfdestruct(msg.sender); return true; } and my unit test code: function testOwnerCanKillContract()...
4
votes
1answer
79 views

Is pre 0.5.0 keccak256(a,b) equivalent to post 0.5.0 keccak256(abi.encodePacked(a,b))?

In pre 0.5.0 Solidity if you wanted to hash a some set of data you would do keccak(a, b, c). Post 0.5.0 keccak only takes 1 arg and it is suggested to use keccak(abi.encodePacked(a,b,c)) instead But ...
3
votes
1answer
273 views

Solidity Vs Vyper

What is the key differences between Solidity and Vyper? In present and future which one can more acceptable for making smart contracts and why?
0
votes
0answers
16 views

Duplicate values added to array and map for a particular function

I'm trying out my hands on a dApp development. For some reason, I'm unable to understand what went wrong in the following function. contract transactions{ enum ExpenseTypes {DEFAULT, EQUAL, ...
0
votes
1answer
56 views

Contracts not running in Web3 after upgrading to solidity 0.5

I have a cotract that used to work with web3 and solidity 0.4.21 now I'haven't been able to get a god answer from web3 although my tests work perfectly. this is my contract: pragma solidity >=0.4....
0
votes
1answer
575 views

Truffle console error “Error: Returned error: VM Exception while processing transaction: revert”

I compiled and migrated my solidity codes of erc20 token to development networks on truffle, and use it on truffle console. truffle(development)> let instance = await XToken.deployed() truffle(...
1
vote
1answer
16 views

Use Values Returned from One Function in Another

need a little help if you can spare the time. Making a little card game where people can collect "warrior" cards. We'll have an initial 12 master "cards" that supply the initial traits for the ...