Questions tagged [solidity]

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.

Filter by
Sorted by
Tagged with
0
votes
1answer
30 views

Ethereum 2.0 (Serenity) & PoS

I understand that the underlying consensus model changes from PoW to PoS. However, will it also result in changes to how wallets interact with the network? Will transaction fees still have to be paid ...
0
votes
1answer
27 views

TypeError: Type contract Campaign is not implicitly convertible to expected type address [closed]

pragma solidity ^0.5.11; contract CampaignFactory { address[] public deployedCampaigns; function createCampaign(uint minimum) public { address newCampaignAddress = new Campaign(...
0
votes
1answer
13 views

Check if Struct already exists in array of structs

I am new to solidity. I have a struct and an array of structs, like this: struct Adopter{ uint age; uint gender; // 0 woman, 1 man // maybe add an id field } Adopter[] adopters; So, a ...
0
votes
1answer
16 views

Solidity. Check if key has value in mapping. Operator != not compatible with types struct

I am new to solidity. I have a Person struct and mapping: struct Person{ uint age; string gender; } Person[] players; // holds the 24 players mapping (string => Person) ...
0
votes
1answer
30 views

How is Ethereum Virtual Machine (EVM) isolated (sandboxed)?

I always had this question in mind: What are the used technologies, in order to achieve the isolation of the EVM? does it just run as an isolated process in its own namespaces using the linux feature ...
0
votes
1answer
9 views

How can I debug a my Solidity smart contract with a GUI?

Is there any way to debug a Solidity smart contract with a GUI, like remix? How can I do it for both testnets and mainnet?
0
votes
1answer
15 views

function overriding is quite working when called with web3.js

function getDetails(address publicKey) public view returns (Organization memory) { return s.getOrg(publicKey); } function getDetails(string calldata orgID) external view returns (Organization ...
0
votes
1answer
14 views

What are the ways to call a smart contract function during development?

What are the ways to call a smart contract function during development using Truffle simulated VM with a GUI interface (like Remix or EtherScan offer)? I know I could use CLI options like Truffle ...
0
votes
1answer
14 views

Solidity. Return a Sruct that lives inside an array

I am not sure how to return a struct that is inside an array of structs. This is my code: contract StudentsInfoTracker{ Student[] students; struct Student{ string name; ...
0
votes
1answer
12 views

return array of strings

how do I return an array of strings? This is my code: contract PlanetEarthContract { string[7] continents; constructor() public { continents = ["North America", "South America", "...
0
votes
1answer
25 views

Solidity. How to add an address to a mapping

I have this: contract Diary { string[] private facts; mapping (address => bool) approvedAddresses; address owner; constructor() public { owner = msg.sender; ...
0
votes
0answers
21 views

One Proxy delegate contract to ten another proxy contracts

I'm trying to figure out why this code reverts. I need to make 10 bottles. This is how I do this: deploy Logic contract deploy 10 Proxy contracts call "upgrade" at each Proxy and pass Logic address ...
0
votes
1answer
22 views

Error returning array in function

I wanted to do a get() to return some contract information, including an array, but when I put it gives this error: browser/leilaoSimples.sol:34:9: TypeError: Data location must be "memory" for ...
0
votes
0answers
21 views

Fetch ETH USD Rate from past using Oracle

Is it possible to fetch the USD rate of ETH at a specific time in the past to a smart contract from an external API using an oracle? i.e. I have a function which tracks whether now > start + 10 ...
0
votes
0answers
22 views

geth issues while running command

I am running the following command with added parameter miner.gastarget on a linux server since we had issues while developing, and have to increase gas limit sudo geth --ipcpath "/home/...
0
votes
1answer
26 views

Can I use import {address [ ] } from 'filename' to pass a address array to another smart contract's function?

In my PersonalInfo.sol file I want to pass address array Users(maybe by function SendUserArray, but I don't know how...) to another contract System.sol file. Is it possible to use import {Users} from ...
0
votes
1answer
22 views

Cannot mint ERC223 token

Hello I have a simple implementation for a ERC223 Token. I use this repository: ERC223-token-standard Here is my contract Code: pragma solidity ^0.5.8; import "./ERC223-token-standard-development/...
0
votes
0answers
11 views

How to find which transaction cleared a specific address into a specific contract?

I have a contract with contains the following solidity code mapping (address => mapping (bytes32)) public sealedBids; But I failed to find in the solidity code which part can clear it. As result,...
0
votes
1answer
32 views

Gas optimisation for my art experiment spacecans.com

so I was microdosing some research chems and the thought came to me that I need to do some artsy blockchain stuff for once. It's two tin cans floating in space that you can advertise your so-called ...
0
votes
1answer
12 views

analyzing transaction cost for a smart contract

Given a smart contract, How do I figure out the total amount of gas used? Say for example a smart contract which has a parameterized constructor which stores 5 variables which are address type ...
2
votes
1answer
30 views

Getter functions for loop security

Is there any security issue when making for-loops inside getter functions ? Let's say the array is very large, and it takes a long time to loop through the array. Is it a potential threat or I can ...
0
votes
1answer
16 views

Contract not deploying with web3

I'm writing a web-based DApp with web3, and am trying to get my JavaScript to deploy a contract. I've set up the abi, contract, and bytecode as follows: const trade_abi = [ ... not shown: ABI copied ...
0
votes
1answer
20 views

Warning: Unused local variable: bool

contract Puzzle { address payable public owner ; bool public locked ; uint public reward ; bytes32 public diff ; bytes public solution ; /*constructor () payable public {...
0
votes
1answer
29 views

Contract with multiple signing keys

How things work I have a Factory contract, FContract. FContract can be called by a user as many times as they want, creating instances of, let's call it, contractA. Thus, they're able to own as many ...
0
votes
1answer
18 views

Call smart contract function in geth

Environment, Ubuntu 18.04: bs@dharma ~/Schau $ geth version Geth Version: 1.9.3-stable Git Commit: cfbb969da803d4cc92e1a64fc1b3c06db299b564 Architecture: amd64 Protocol Versions: [63] Network Id: 1 ...
2
votes
1answer
25 views

What size is an enum member inside of a struct

Let's consider the following code: pragma solidity ^0.4.18; contract Test { enum EnumTest { Test0, Test1 } struct StructTest { EnumTest Foo; uint256 Bar; } } Not taking ...
0
votes
0answers
27 views

Note: The called function should be payable if you send value and the value you send should be less than your current balance

interface ERC20Interface { // function transfer(address _to, uint256 _value) external; function transfer(address _to, uint256 _value) returns (bool success); function transferFrom(...
0
votes
1answer
34 views

Error: Explicit type conversion not allowed from “int_const 11111” to “bytes32”

I have the following code snippet: pragma solidity ^0.5.1; contract Puzzle { address payable public owner ; bool public locked ; uint public reward ; bytes32 public diff ; ...
1
vote
3answers
203 views

How does solidity handle mod 0?

Imagine you have a function like this: function compute(uint256 a, uint256 b) external pure returns (uint256) { return a % b; } Does it revert when b is 0?
1
vote
0answers
33 views

Help hacking this contract

This is a very simple contract that I can't hack and I'm stuck, I need some help to get the concepts right. pragma solidity ^0.4.10; contract SimpleToken { mapping(address => uint) public ...
2
votes
1answer
22 views

Is it possible to disable “Stack too deep” errors while in development?

I know about the Stack too deep error and the workarounds for it, but I was wondering whether it's possible to disable it while in development. Is there a pragma experimental flag for this, similar ...
0
votes
1answer
29 views

Web3 - how to add WEI and ETH values correctly

I'm working on an auction feature in my DApp and having problems correctly adding together two WEI values. The contract stores two important values: 1. A minBidIncrement variable - which I've set to ...
0
votes
0answers
10 views

Feeding a contract address to echidna

Simple question: Can I use echidna on a contract address? Like in mythril the command I use is myth -v4 analyze -1 -a 0xec410f642db4a2bcc4d7a69bc13b1165ebad3cea. I don't see any supporting ...
0
votes
1answer
9 views

Cannot call functions from another deployed contract that inherits yet another contract

I am just trying this using Remix editor. I am able to call functions from another deployed contract(plain as simple) but when that another deployed contract inherits yet another contract, Now the ...
0
votes
1answer
37 views

How to get absolute value in solidity?

In JavaScript, there is "Math.abs": Is there a similar function in solidity itself or some other popular library such as SafeMath?
0
votes
2answers
41 views

How to save an array of address?

I wrote a smart contract PersonalInfo.sol. In this smart contract, I want to save an array of address. Each address is the place where smart contract were deployed. However, each time I deployed the ...
0
votes
1answer
57 views

Web3-core-helpers error: Uncaught (in promise) Error: Provided address “undefined” is invalid,

When I launch the app with with react.. this error occur when my exchange contract is loaded.. Here is the code i wrote to talk to the blockchain: export const loadBalances = async (dispatch, web3, ...
0
votes
1answer
27 views

How to access Struct field dynamically

I have a struct struct lineItem { string idNo; string date; string code; string docCode; string vendorNumber; string invoiceDate; string ...
0
votes
0answers
95 views

Remix never returns a transaction - but everything works - why?

This code supposedly works. Its supposed to let the owner withdrawal collected ERC20 tokens in a contract. It calls the balanceOf() for the erc20, then calls transfer(). Only have this error when ...
0
votes
1answer
50 views

Ethereum Smart contract calling a function in another smart contract that has a address payable return value give error

I am new to solidity. Anyway, I have written the following smart contract: pragma solidity >=0.4.22 <0.7.0; contract SP { address BlockAddress; bytes32 _Mhash; function ...
1
vote
1answer
13 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
1answer
21 views

Loading modified contracts keeping the same super class

I am trying to implement upgrade of contracts. One pattern by [1] is to have a layer to resolve the actual address of a contract. I implemented that adding the Pausable manipulation. My idea was to ...
0
votes
1answer
42 views

One contract accessing data from another fails

I am trying to get two contracts to interact: pragma solidity ^0.5.10; contract C2 { address public addr; constructor(address per) public { addr = per; } function ...
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....
1
vote
1answer
35 views

How to get top 5 token holders?

I want to keep a track of top 5 token holders inside the contract in terms of their token balances, is there any efficient way to do that in solidity?
1
vote
1answer
28 views

Weighted Random Number Array generation in solidity

I have an array like this in the array, uint256[] public numberArr= [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]; Each number in an array have their own weight, uint256[] public weightNumberArr = [1, 3, 9, 7, 15,...
2
votes
1answer
27 views

Shuffle Array of integers in solidity

I have an array of integers like this, uint256[] public numberArr = [0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,4,5,5,5] What can be the best way to shuffle this array in solidity
0
votes
4answers
40 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
22 views

How to match the data in the struct?

If the Set function receives two inputs 1.["0xca35b7d915458ef540ade6068dfe2f44e8fa733c",50,"ROC","park"] 2.["0x14723a09acff6d2a60dcdf7aa4aff308fddc160c",60,"AU","school"] How can I return all the ...
0
votes
1answer
36 views

BigNumber string error when passed as uint256

I get the following error when passing (new BigNumber('2')).exponentiatedBy(100) big number value as uint256 Error: invalid BigNumber string value (arg="value", value="1....