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
3answers
25 views

Why are contacts from Remix editor and explorer different after deploying?

I try to deploy my ERC20 token. My steps are: 1) I created a contact with Remix (by some manual) https://gist.github.com/pistol88/a934da7fcaa93a92f4c4de60df56a0cf contract TestToken is ERC20Standard ...
1
vote
2answers
61 views

ecrecover() always returns 0x0000000000000000000000000000000000000000

I'm aware of these posts How do you sign an verify a message in javascript proving you own an Ethereum address? How does one properly use ecrecover to verify Ethereum signatures? I'd like to sign a ...
0
votes
2answers
62 views

Solidity - How do I generate a random address

EDIT: there is currently no good answer to this question. Solidity is not able to generate anything random, not at this moment at least. I would like to generate a random 0X address using solidity. ...
0
votes
1answer
23 views

Is it possible to create a trigger when a state variable contract is i.e. 10?

Let's supose this is my contract: Contract MyContract{ uint a = 0; function myFunction(){ a = 0; } } I want "myFunction" to fire up when "a" value is 10. Thanks.
0
votes
0answers
19 views

I can see my ethereum but its not going to my wallet

My ethereum has been confirmed delivered but not in my wallet,fairly new but I have made successful transactions before,I can see my ethereum in etherscan.io 0x2ecc74c6e9c42eea14863fbc1e1d9656b339a6ec ...
0
votes
1answer
51 views

Custom token showing balance of 0 in MyEtherWallet

I made a new token on the Ropsten test network. Here's the contract address: 0x801fd9c17087ec868dc8540055b7ea3cb6dbbe34. When I followed the instructions to add this custom token to MyEtherWallet (by ...
0
votes
1answer
101 views

error: VM Exception while processing transaction: revert SafeMath: subtraction overflow on migrating crowdsale conract

I am developing the token sale Dapp using openzepplin-solidity version 2.3. While migrating, I got the following error. Returned error: VM Exception while processing transaction: revert SafeMath:...
0
votes
1answer
17 views

Tallying Majority Consensus From Nested Struct

How do I tally the votes of a nested struct to find out majority consensus? as an example, if we have following scenario below; I want to create a function which allows me to calculate whether ...
1
vote
1answer
21 views

Upgradability Proxy ADMIN_SLOT assembly sstore does not update

I'm currently playing around with Proxy Upgradability, and noticed the use of assembly in terms of the new upgraded contract and the slot assigned. Real implementation can be seen here. I have ...
4
votes
2answers
143 views

Inline assembly, good or bad practice

I often see inline assembly in Solidity contracts. I consider this a bad practice because of the poor readability, however this is my opinion only and there must be valid reasons to use it. There are ...
0
votes
1answer
25 views

Initialising Empty Arrays & Structs In Struct-based Storage Graph Structures?

How do I initialise empty arrays and structs in nested structs data structures? contract NewBook { struct ReviewerData { string name, uint industryXP // ...
0
votes
2answers
15 views

it'll give me a parser error

pragma solidity ^0.5.0; contract fisrtCoin { address deployer; mapping(address=>uint) balances; public function fisrtcoin() { deployer = msg.sender; } public ...
1
vote
1answer
38 views

Updating an instance of an already stored struct?

How can I update/change the values of a stored struct instance? as an example: Let's say I've already deployed a chapter with the content written in a particular color. Later it turns out that I ...
0
votes
1answer
17 views

Returning an array of inner structs of a struct

How can I return an array of child structs of a parent struct? as an example: After pushing multiple chapters into the parent struct, how can I retrieve all the child structs as an array (or ...
0
votes
1answer
27 views

How does a transaction verified with Truffle test?

I'm a new to Ethereum and Solidity, and I don't understand how Truffle executes transaction calls. From what I learned and understood, if I try to use a contract method which changes the contract's ...
0
votes
1answer
31 views

contract reading array from other contract

There are two contracts in my project: admin groups voting Admin groups contain mapping(uint => address[]) internal m_Admins For example [1][0] = admin #1 with level 1 [9][0] = admin #2 with ...
0
votes
0answers
18 views

Smart-contracts referencing each other [duplicate]

How would one retrieve these three addresses in the "Knot" smart-contract? I am very new to this, and would like to know whether this is even possible. The "Knot" contract should be able to reference ...
0
votes
1answer
60 views

Failed to load events from Block 0 on page refresh in Vue app

I'm trying to get event data from the web3 API using events method. In my Vue app methods, I have a method, newDsoValue, that will watch for the events from the beginning and also for every newly ...
-2
votes
1answer
25 views

TypeError: No matching declaration found after argument-dependent lookup

ERROR:TypeError: No matching declaration found after argument-dependent lookup.require (positionIsInBounds(xpos,ypos)); ^-----^ pragma solidity ^0.5.1; contract TicTacToe { //addresses of ...
0
votes
1answer
29 views

Pushing A Struct Instance Into An Struct Array Of A Different Struct Mapping

How can I push a struct instance into a mapping which contains a distinct struct which contains a struct array of the attempted struct instance type? Example: contract NewBook { struct ...
0
votes
1answer
43 views

Mapping Multiple Struct Instances To One Address

How can I map multiple struct instances to one user without overriding the previous instance? I want to retrieve both instances through one mapping query. Should I use a multi-dimensional array here ...
1
vote
1answer
44 views

Solidity: Raise events via Assembly using log3

I want to raise events from inside a piece of assembly code. I've extended the answer here with the function AssemblyEvent() which currently causes a runtime error. Working example: pragma ...
0
votes
0answers
18 views

Contract cannot create new Contract in Quorum

My main contract called SurveyFactory creates new Survey forms: pragma solidity = 0.5.9; import './Survey.sol'; contract SurveyFactory { address[] public surveyList; address public Owner; ...
1
vote
1answer
26 views

What is the benefit of leaving data in the stroage area instead of the log?

I did not write English well and used a translator. sorry :3 I would like to know the benefit of leaving data in the storage area rather than using the event log. I know gas consumption has less log....
1
vote
1answer
34 views

Random Group Generation From Array

How can I form a random group of 5 people from an array of 100 people?
1
vote
1answer
20 views

Does the 10,000 refund apply to booleans too?

I understand from this thread that you're refunded up to 10,000 gas when setting a value to 0. Does this also apply to boolean values? That is, going from true to false?
0
votes
2answers
23 views

Smart Contract Interfacing - Best Practices

what is a general rule of thumb for creating interfaces? Why would I want an interface i.e. IAugur.sol instead of the entire Augur.sol file? Can someone shed light on interface best practices and pros/...
0
votes
1answer
13 views

What would web3.js respond with in this case?

I have a mapping to a struct in my contract mapping (uint=> Student) students; struct Student { bool passed; } Now I want to call a particular student with a particular ID to see if he has ...
0
votes
1answer
26 views

others accessing setApprovalForAll ERC721

While I was skimming through open zeppelin's ERC721BasicToken.sol I came across a problem. When setting the approval of a given operator function setApprovalForAll(address _to, bool _approved) ...
1
vote
1answer
44 views

No matching declaration found after argument-dependent lookup in remix IDE

I'm getting this error in remix: "TypeError: No matching declaration found after argument-dependent lookup. require(_spender.call.value(msg.value)(_data)); ^-----^ " function approveAndCall(...
0
votes
1answer
36 views

Question about inline assembly in Solidity

I've got this line of inline assembly code in a Solidity file and I'm trying to understand what some parameters do. assembly { success := call(sub(gas, 2000), 8, 0, add(input, 0x20), mul(...
0
votes
0answers
56 views

How to send transactions to smart contract in batch?

I have this smart contract function: function addOneUser (User memory _user) public { bytes32 hash = keccak256(abi.encode(_user.name)); users[hash] = _user; } Using ...
0
votes
1answer
47 views

ERC721Enumeration: DeclarationError for tokenOfOwnerByIndex(address owner, uint256 index)

I am new to the smart contract and please let me know why I have the error shown below. I compiled with the command, "truffle compile". I did not make any particular edits to the original contract ...
0
votes
1answer
20 views

Commit-Reveal Sequence Design

Let's cook up a scenario to ease understanding: We have a group of 5 people (addresses) who must vote on a question. The people can only vote True or False i.e. a boolean. The result of the vote ...
0
votes
1answer
23 views

How to send a transaction with large data ethereum?

I am trying to send an array of object (tuple) to smart contract. function addManyUsers (User [] memory _users) public { for (uint i = 0; i < _users.length; i++) { bytes32 ...
0
votes
1answer
21 views

Get return data from sendSignedTransaction

I need access to data returned by function that also changes state. Example: I have a contract live on testnet with a function that creates and then returns a new ERC20 token. contract MyContract { ...
0
votes
1answer
27 views

How do you pause a Proxy-Logic pattern?

Suppose we have a Proxy contract that forwards to call to a Logic contract by using delegatecall. If we pause the Proxy, users will still be able to directly interact with the Logic contract. While ...
0
votes
1answer
43 views

explanation of appending .selector in solidity smart contracts

I'm trying to understand what .selector means when appended to logic wrapped up inside of functions definitions. I've tried to read the section in soliditydocs, but it doesn't seem to answer my ...
2
votes
1answer
43 views

Convert address to string after solidity 0.5.x

After solidity 0.5.x release none of conversions from address to string appear to be working. I've tested all of them on remix and got errors like converting bytes to uint or something like this. ...
0
votes
2answers
29 views

ERC721 exchange logic

I'm trying to allow NFT holders to sell their tokens by listing prices (ETH) and allow others to buy those listed tokens. I used openzeppelin and succesfully implemented and tested my token creation. ...
2
votes
2answers
78 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.
0
votes
1answer
17 views

Why the function needs payable() in solidity?

In my solidity code, I am not using the global variable msg.* but still I get the error message in the function. Please explain why this function needs to be a Payable function The below snippet is ...
0
votes
2answers
58 views

Calling function with one parameter in Solidity

I am trying to call a function with one parameter I have used these methods all didn't work: //z=addmul(total); //this.addmul(total); This is the function created: function addmul(uint256 a, uint256 ...
-1
votes
1answer
25 views

operation between uint256 and 1/100 [duplicate]

contrast take{ if ((address(this).balance)/100>=1/100){ } } The code above throws type error: incompatible type between uint256 and rational_const 1/100.does anyone know how to solve that?...
1
vote
3answers
217 views

Pattern to deploy a smart contract from another one without spending twice the gas

It seems that if we want to deploy a smart contract (let's call it Target) from another one (let's call it Deployer) in Solidity via new, we spend a gas amount linear in the size of the deployed ...
2
votes
1answer
45 views

Cannot deploy contract in new Remix layout

I cannot get a contract to deploy in the new layout but when I go back to the old format it works fine. The deployment parameters are as follows: and here is the error that I get: However, when I go ...
-1
votes
1answer
32 views

Logical OR operator is not working in IF condition, solidity 0.5.0

I wanted to ask if is it available to use OR operator in IF conditions, because its giving me awkward results, like this: contract test { if(player1Points > Player2Points || player1Points >= ...
1
vote
2answers
29 views

Which erc token to use?

I wonder someone could give me some advice. I am planning to work on a Ethereum project with a Solidity smart contract. The smart contract should contain tokens which can be earned by a person by ...
0
votes
1answer
24 views

Anyone some have “ERC20 Deposit Contract” sample code?

I'm looking for an example contract that works like this: There is a person A, a person B, an ERC20 token named abc, and a smart contract C, Person A sends 20abc to contract C, and 30 ...
0
votes
1answer
32 views

Solidity returns “ParserError: Expected primary expression” on my code below, can anyone help?

pragma solidity ^0.5.8; //Change the contract name to your token name contract JONJonnywon { // Name your custom token string public constant name = "JONNYWON"; // Name your custom token ...