Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

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.

0
votes
1answer
10 views

constructor arguments require 'memory' as a data location but not uint?

Ok I am trying to figure out why Remix IDE is throwing an error saying the Data location 'memory' must be given..... for a string argument but the uint arguments don't throw any error? pragma ...
1
vote
1answer
19 views

Error when calling the selfdistruct method in solidity

I am quite new to solidity, and I have not managed to find a solution for this problem. I am passing the function an address but it says the following: "Invalid type for argument in function call. ...
2
votes
1answer
20 views

What is the best way to test calling a contract's function from another contract?

I'm playing around w/ Gnosis' MultiSigWallet and noticed in their replaceOwner function it has a modifier that requires msg.sender to be the MultiSigWallet contract itself: modifier onlyWallet() { ...
1
vote
1answer
10 views

Remix - Solidity IDE - function revealWinners not public

I defined a modifier in my contract Auction modifier onlyOwner() { //Part 2 Task 1 require (msg.sender == beneficiary); _; } This modifier should be used in ...
1
vote
0answers
15 views

Fail to verify source code on Etherscan using API with constructor arguments

I am trying to verify source code on etherscan using API listed here. I have successfully verified the simple contracts (without constructor). Now I am trying to verify a sample contract with ...
0
votes
1answer
12 views

Unusual error with bytes calldata

pragma solidity >=0.4.22 <0.6.0; interface tokenRecipient { function receiveApproval(address _from, uint256 _value, address _token, bytes calldata _extraData) external; } contract ...
0
votes
1answer
17 views

What is the gas cost of keccak256(“abc”)?

According to this answer, the gas cost of keccak256 is: 30 gas + 6 gas for each word (rounded up) for input data to a SHA3 Keccak-256 operation I'm assuming that the size of a word is 256 bits and ...
0
votes
0answers
14 views

Contract function cannot be executed

I wrote a contract for token and token sale by following a few tutorials. Contracts are deploying fine, tokens are created and functional. However I cannot execute a couple of functions in both of ...
0
votes
0answers
5 views

is there any method convert mutiple params to one bytes in web3js ,and then get these original data from bytes in solidity?

eg: the params in js code below,how to convert to one bytes var min=100; var max=100000000000; var price=1000000000000000000000000000; var name="john"; in solidity code below,how to get original ...
0
votes
0answers
5 views

Unable to pass the value to function's parameter in Remix

I am testing a contract which has a transfer function which accepts the array of values and address. It works fine when I pass a smaller value as mentioned in the below transaction. https://ropsten....
0
votes
1answer
18 views

How read events from solidity [duplicate]

I made a solidity contract but I want to get the event in another contract, is it possible to watch the event in that way?
0
votes
0answers
16 views

alternative commands for eth_getCompilers, and eth_compileSolidity

command: {"jsonrpc":"2.0","method":"eth_getCompilers","params":[],"id":1} the error code is: { "jsonrpc": "2.0", "id": 1, "error": { "code": -32601, "...
0
votes
1answer
10 views

Function of emitting event [duplicate]

I've recently started with Solidity and like to know about the emit event as I wasn't sure of why it is being used in the program. contract MyToken { string public name; string public symbol;...
0
votes
0answers
24 views

how to convert params to bytes in javascript and parse uint256 from bytes in solidity

for example: user call this function from javascript. function receiveApproval(address _from, uint256 _value, address _token, bytes _extraData) How can I put these three uint value to bytes and ...
0
votes
0answers
25 views

Safe deploy of ERC20Mintable token and crowdsale contract

I have created the Token contract and the crowdsale contract using open Zeppelin library. After migrating the Token and crowdsale contract, I have added the crowdsale contract address as a minter in ...
0
votes
1answer
21 views

Convert bytes to uint256[]

I am writing an implementation of ERC777TokensRecipient. So that means a function function tokensReceived(address operator, address from, address to, uint256 amount, bytes data, bytes operatorData) ...
0
votes
1answer
10 views

How to differentiate between different logs in ethclient

I have events like this in my .sol file event userActivated(address owner, address contractAddr); event userDeactivated(address owner, address contractAddr); And I am using ethclient Go module to ...
6
votes
1answer
411 views

Can a contract with no payable function have ether?

The question in the title says it all. To the best of my understanding, the only way to deposit ether into a contract is by calling a payable function, and set msg.value larger than 0 (and of course, ...
1
vote
1answer
16 views

Token transfer is not working

I am trying to transfer a token from a token contract. the control reaches till the point where I have the transfer statement later it fails. I do not understand why it is failing. I made sure the ...
1
vote
1answer
22 views

What about calls you can do safely in constructor?

As a matter of fact, there is more than one discussion about what are the call you can safely do in the constructor. Someone thinks “avoid all external call”, some other says “avoid to use ‘this’ or ...
1
vote
1answer
15 views

msg.sender problem for calling ERC20 token contract from another contract

I am using a ERC20 Token contract as indicated below. (I have deleted the irrelevant portions). pragma solidity ^0.4.24; import "../node_modules/openzeppelin-solidity/contracts/math/SafeMath.sol"; ...
1
vote
1answer
15 views

Event not visible on Etherscan transaction list

I have a BuyToken event when user send ether to smart contract they will receive tokens based on ether amount. For ex: 1 ETH = 1000 Token. /// This notifies clients about the Buy Token event BuyToken(...
1
vote
0answers
39 views

Unable to call setter function in solidity using Infura

Solidity code contract Greeter { string public greeting; function Greeter() public { greeting = 'Hello'; } function setGreeting(string _greeting) public { greeting = _greeting; } function ...
1
vote
2answers
28 views

how to join two bytes32 values in solidity?

Below is work example of joining two bytes arrays. I wonder how I can join two bytes32 using assembly or solidity? two bytes32 values should serve as an input and a joined bytes32 is an output. ...
0
votes
0answers
22 views

Adding a timer to the Voting System. Ethereum (Solidity)

This is smart contract for decentrilized Election System. Currently it voters can vote, and each voter have one chance to vote. pragma solidity ^0.4.2; contract Election { // Model a Candidate ...
0
votes
0answers
18 views

ERC20 token with expiration date

I would like to create a ERC20 token with an expiration date to represent for example a ticket or a gift card. I've created a contract which overrides the open-zeppelin ERC20 contract methods. ...
2
votes
1answer
29 views

Calculating a hash of a set of keys in Solidity

I have the following problem that I'm trying to think of an efficient solution for. Suppose I have a set of unordered keys (KEY_1, KEY_5, KEY_2, KEY_4), and I want to calculate a unique hash for this ...
2
votes
0answers
23 views

SOLIDITY: is anywhere formalized the assignment operator behaviour in nested statements?

As a matter of fact, solidity seems to have same behaviour of C in nested assignment. I.e. running the sample test contract below, calling nestedSum(1) results in the following: a=38, b=16, c=4 ...
0
votes
0answers
18 views

Convert a string received from oraclize like {54, 41, 42, 76, 10, 58, 27, 83,} to an array of uints in Solidity [duplicate]

Maybe if a lib like solidity-stringutils used to slice "," and then use parseInt to pass each number as uint to an array. Can you explain or help me with that?
2
votes
2answers
14 views

Format of Event logs structure in Remix

I am running a simple contract in remix. I have an event in my contract which will be emitted just to check values of stateVariables. contract stateVariable{ uint stateVariable1=10; uint ...
0
votes
0answers
19 views

How to get most expensive/cheap values in array?

I am working on a DEX solidity smart contract. I have an array orders[] which uses the struct struct Order { uint tokenAddress; uint pricePerToken; uint tokenAmount ... When the user ...
0
votes
0answers
5 views

Mythril not Installing when I do pip3 install mythril. Showing errors

Could not fetch URL https://pypi.python.org/simple/mythril/: There was a problem confirming the ssl certificate: [SSL: TLSV1_ALERT_PROTOCOL_VERSION] tlsv1 alert protocol version (_ssl.c:645) - ...
1
vote
1answer
32 views

Address checksum Solidity implementation

Looking at EIP-55, there are quite a few client-side address checksum implementations provided but no Solidity implementation. Are there any existing examples of computing address checksums directly ...
0
votes
1answer
18 views

What is the work of self destruct in a contract?

How it can be used for handling force sending of ether to a contract without triggering fallback function ?
1
vote
0answers
26 views

Connection of web3 with Ropsten

How do I connect my web3 to ropsten network. I know how to pass the url of ropsten netwrok in web3 instance in my script tag but when i try to to console.log(web3.eth.defaultaccount) it gives me ...
0
votes
1answer
12 views

Remix - Solidity IDE - Gas requirements high

Compiled an "Auction contract" and got a warning regarding high gas requirements. Means: cannot run it. Below the lines with comments and that lines I included (//Part 1 Task n Line n). // CANNOT BE ...
0
votes
1answer
19 views

Reading Ledger from etherscan API vs Emitting Events

Consider the following function from a solidity Contract: function createProduct(uint _price, string memory _desc) public payable{ emit UserLedgerUpdated(_desc, -1*int(msg.value)); } I want my ...
0
votes
0answers
28 views

How to return a map value string on a string memory function in Solidity?

so I have a map in contract and I am trying to build a get function to return a certain value which is string but I am getting an error because the value stored in my map is string while the return ...
0
votes
1answer
22 views

Transaction not getting confirmed because of transfer function even after making the address payable

The finaliseRequest transaction is not getting confirmed no matter what I do. I am sure it is failing at the transfer function. I had made the address to address payable also and changed the function ...
0
votes
1answer
27 views

How do I take value from array of objects?

I have a problem with my code. contract Registration { address public owner; uint conceptPrice; uint conceptValue; function Registration(uint _conceptPrice) public { owner = msg.sender; ...
0
votes
2answers
30 views

Refund Ether stored in a Contract

i'm trying to store Ether inside a Contract and refund it when I call the function paypackEther(). Inside of the Remix IDE with the JavaScript VM it works perfectly, but when I execute it on Rinkeby ...
0
votes
0answers
16 views

errored: Error encoding arguments: Error: invalid address (arg=“”, type=“string”, value=“”)

The contract code is getting compiler properly in remix but only when trying to deploy this error is coming creation of InsuranceClaim errored: Error encoding arguments: Error: invalid address (arg=""...
0
votes
0answers
11 views

Problem in executing GetHighestBidder() function

I am trying to get the highest bid of a user. Its working if i set the environment to JVM/ ropsten but is not working when i am connecting it to local host. pragma solidity ^0.4.24; contract ...
0
votes
0answers
13 views

Guys i am having trouble on showing my transaction details from my contracts.And my for loop is also not executing in app.js file [on hold]

pragma solidity^0.4.19; contract Banking { struct Applicants { uint id; bytes32 name; int date; bytes32 fatherName; bytes32 ...
0
votes
1answer
32 views

Remix - Solidity IDE - ParserError

Cannot compile the "contract Auction". Got this error for Miscellaneous methods. //Miscellaneous methods: Below methods are used to assist Grading. Please DONOT CHANGE THEM function getPersonDetails(...
0
votes
0answers
24 views

Election dApp. UI and backend

here is a code that i downloaded from GitHub and tried to learn, folowing this tutorial. It's simple dApp for election. It uses these dependencies: MetaMask Truffle Ganache Shortly ...
0
votes
1answer
15 views

Issues while sending raw transaction for calling smart contract methods?

let provider_url = "https://ropsten.infura.io/v3/d5bca90ec3084aee8abd468fdf876a11"; this.web3Provider = new Web3.providers.HttpProvider(provider_url); window.web3_ = new Web3(this.web3Provider); ...
1
vote
1answer
31 views

Problem with push

This is my code. When i push address into participants the length is zero. Why? pragma solidity ^0.4.0 contract Registration { address public owner; uint threshold = 2; address [] ...
0
votes
0answers
24 views

Auction contract execution ParserError

I am building an auction smart contract in Remix with random winners being picked. function revealWinners() public returns (uint) { for (uint id = 0; id < 3; id++) { Item ...
1
vote
1answer
20 views

Function selector of function that takes enum as argument

If a function takes an enum as a parameter function foo(MyEnum arg1, uint256 arg2) public returns (bool); how do I properly compute the function selector for that function?