Questions tagged [solidity]

Solidity is a language for smart contracts for blockchain technologies like Ethereum. It is designed to compile code for the Ethereum Virtual Machine. Use this tag for questions about programming smart contracts using the Solidity language.

Solidity is an object-oriented language whose syntax is similar to that of ECMAScript, but with static typing, and it is designed to compile to code for the Ethereum Virtual Machine for use in smart contracts in blockchain technologies.

6642 questions
143
votes
4 answers

In Ethereum Solidity, what is the purpose of the "memory" keyword?

When looking at sample contracts, sometimes arrays are declared in methods with "memory" and sometimes they aren't. What's the difference?
fivedogit
  • 8,374
  • 7
  • 34
  • 43
67
votes
3 answers

What is address(0) in Solidity

Can anyone explain to me what address(0) is in Solidity? I found the following in the docs but it doesn't really make sense to me: If the target account is the zero-account (the account with the address 0), the transaction creates a new contract.…
pizzarob
  • 11,711
  • 6
  • 48
  • 69
53
votes
2 answers

Warning: SPDX license identifier not provided in source file

I created a new solidity contract. The contract is up and running but giving me this warning. Warning: SPDX license identifier not provided in source file. Before publishing, consider adding a comment containing "SPDX-License-Identifier:…
user14606211
52
votes
5 answers

Data location must be "memory" for return parameter in function, but none was given

I tried solidity example like as above in remix, solidity version > 0.5.0 But I am getting this error now. What is the way to solve this error? contract MyContract { string value; function get() public view returns (string) { return…
venus12
  • 523
  • 1
  • 4
  • 4
41
votes
8 answers

How to convert uint to string in solidity?

In Solidity, is there a way I can convert my int to string ? Example: pragma solidity ^0.4.4; contract someContract { uint i; function test() pure returns (string) { return "Here and Now is Happiness!"; } function love()…
Bob Zheng
  • 825
  • 4
  • 14
  • 25
41
votes
5 answers

Are there null like thing in solidity

struct buyer { uint amount; Status status; } mapping(address=>buyer) public buyers; mapping(uint=>address) buyerIndex; uint public buyerNum; // Order a product. function() { uint doubleValue=value*2; uint…
Hao WU
  • 521
  • 1
  • 4
  • 5
37
votes
8 answers

How to find out if an Ethereum address is a contract?

An address in Solidity can be an account or a contract (or other things, such as a transaction). When I have a variable x, holding an address, how can I test if it is a contract or not? (Yes, I've read the chapter on types in the doc)
bortzmeyer
  • 34,164
  • 12
  • 67
  • 91
32
votes
5 answers

Why do I get the error "Method eth_maxPriorityFeePerGas not supported" when I try to run Web3py with Ganache?

Running Web3.py with Ganache-cli returns this error: Method eth_maxPriorityFeePerGas not supported. However this does work when working with a test-network like Ropsten directly without Ganache-cli. Running this code in following a tutorial: from…
Axceus
  • 407
  • 3
  • 7
31
votes
19 answers

File import callback not supported?

Tried to run: 1.) Dappuniversity project (dappuniversity/dbank) 2.) pet-shop-tutorial Truffle v5.3.3 (core: 5.3.3) Node v14.15.5 How can ser compile code @ the 0.8.4 to import OpenZeppelin’s ERC20.sol template, when Truffle requires it’s…
GoGetterMeme
  • 429
  • 1
  • 5
  • 5
29
votes
2 answers

Member "push" not found or not visible after argument-dependent lookup in address payable[] storage ref

In the statement players.push(msg.sender); I am getting following error: Member "push" not found or not visible after argument-dependent lookup in address payable[] storage ref. Thus I cannot push to address payable array in solidity. What's the…
Ayan
  • 8,192
  • 4
  • 46
  • 51
28
votes
3 answers

Solidity basics: what "msg.sender" stands for

I just started to learn Solidity as a personal challenge. I'm not a developer so I've a loooooong way to go. I'm following the Ethereum.org tutorial, here is what I've got doubt about: What does [msg.sender] stand for? I guess it is the wallet…
Sumak
  • 319
  • 1
  • 3
  • 8
27
votes
3 answers

No safeTransferFrom function in ethers.js contract instance?

I created a contract instance in hardhat console like so: const contract_fac = await ethers.getContractFactory("ContractName"); const contract = await contract_fac.attach("CONTRACTADDR..."); Contract object has all public/external functions except…
Lightstorm
  • 379
  • 4
  • 5
26
votes
3 answers

ERROR send and transfer are only available for objects of type address payable , not address

function finalizeRequest(uint index) public restricted { Request storage request = requests[index]; require(request.approvalCount > (approversCount / 2)); require(!request.complete); …
Juodas Baltas
  • 305
  • 1
  • 4
  • 6
26
votes
11 answers

How to generate a random number in solidity?

I have a couple of keccaks, which could be reduced to one if I would find a cheap way to get parts of the created uint. pragma solidity ^0.4.19; contract test { function test() { } function sup() returns (uint test) { uint _test =…
Garry Plays
  • 377
  • 1
  • 3
  • 5
25
votes
4 answers

How to return mapping list in Solidity? (Ethereum contract)

I want to make a simple smart contract that has a list, can set item, and can get the list. Code in solidity: contract lister { mapping(int => string) list; int id = 0; function getList() returns ( /*HERE*/ ) { return list; …
6londe
  • 557
  • 1
  • 8
  • 17
1
2 3
99 100