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
0answers
6 views

Where should we actually need to set the token price?

I have seen a video which sets the "token price" in a contract using that token (erc20), If the same token is used in another contact for transferring in another contract with a different value of "...
0
votes
0answers
7 views

Solidity/Truffle - Suddenly getting TypeError on Migration file

Suddenly getting an error when doing a truffle compile --reset - even though I didn't make any code changes on my Migrations.sol file. TypeError: Name has to refer to a struct, enum or contract. ...
0
votes
0answers
10 views

Automatically collect Etherium on one wallet

I have a need to create a smart contract. The task is for the smart contract to perform the withdrawal of the entire balance of ETH coming to several of my wallets to one another my wallet. ...
0
votes
0answers
19 views

Transferring funds from a contract to an account using adresses

I had been trying for a long to transfer the complete fund with one of my contracts to a specific account. But nothing seems to be working. pragma solidity >= 0.4.22; contract reg{ address ...
0
votes
0answers
23 views

Transferring ether balance from contract balance to winner,not working

here is my Solidity snippet: function deliverPrizes(address payable winner) public onlyOwner{ winner.transfer(address(this).balance); } This is what I wrote on truffle console: dCoders....
0
votes
0answers
18 views

i am trying to send a signed transaction for my solidity code but i am encounting some error can anyone suggest me the fix?

pragma solidity^0.5.0; import "./TokenSale.sol"; contract Dice{ TokenSale public tokenSale; address tokensaleaddress; struct player_details{ address pAddress; string ...
1
vote
1answer
11 views

Is it allowed to used modifiers in mandatory functions of any token standards that I wish to implement?

As for example, Is it okay to add modifiers in transfer function in ERC20
0
votes
2answers
24 views

Use function return variable of smart contract in web3.py

since im new to solidity programming i have some problem with executing my Contract. My Contract looks like this: # Solidity source code contract_source_code = ''' pragma solidity ^0.4.1; contract ...
0
votes
1answer
12 views

TypeError: Return argument type bytes32 is not implicitly convertible to expected type (type of first return variable)

I have one issue while deploying the below contract.could anyone help me to find the issue as unable to find issue. pragma solidity >=0.4.22 <0.6.0; contract Lottery { address payable[] ...
1
vote
0answers
7 views

Extracting mapping structure from storage of smart contract

Is there a way to extract data stored in the mapping structure without the keys by simply reading the smart contract's storage? Also, what is the inline assembly for inserting a value in mapping using ...
0
votes
2answers
20 views

access mapping inside mapping of struct in Solidity ^0.5.0

I have a contract which looks like this: contract a { struct Str { uint256 totalTokens; mapping(address => uint256) playerTokens; } mapping(uint256 => Str) public ...
0
votes
2answers
19 views

Integration of smart contact with frontend using web3js

I had been long searching methods fro integration my smart contract with my frontend. Then I came across web3.js but couldn't find any specific method is to how this system is working.
0
votes
0answers
17 views

Working with 0.4.4 version of solidity, still got error, “Member 'transfer' not found or not visible after argument-dependent lookup in address.”

According to some resources, this well known error occur because of versions 0.4.X to 0.5.X change. Previously I compiled contract with ^0.5.1, to solve this error currently I'm using 0.4.4. But ...
0
votes
1answer
22 views

Solidity: data type conversion from bytes to address/string/uint/int [ any library available? ]

I have a method which returns bytes type data from an external contract call. I need to convert that bytes type data into my desired output type data like address/uint/bool/string/int etc. I have ...
1
vote
1answer
15 views

How do I transfer an arbitrary erc 721 asset from a smart contract?

I'm trying to work with ERC 721 tokens in such a way that my contract freezes and unfreezes them (based on some conditions) but I'm having trouble wrapping function calls to the ERC 721 token contract ...
1
vote
1answer
20 views

Simple but important question: How to get the value of contract's state when using Metamask? [on hold]

I'm designing an HTML file (or a user interface: UI) for my smart contract. let's assume that my contract has a state as follows: address public owner;// it is set to "...
1
vote
1answer
31 views

How to convert bytes32 to uint8 in solidity ^0.5.0?

I can see that conversions from bytes to uint used to be much easier in previous versions of solidity. Now, using the same syntax, I get this error: TypeError: Explicit type conversion not allowed ...
0
votes
2answers
17 views

Will 'x.send(amount)' revert if 'x' is a contract with a fallback function which reverts?

I know that x.transfer(amount) reverts if either one of the following two scenarios takes place: There is not enough ether in the calling contract, i.e., amount > address(this).balance Variable x ...
0
votes
0answers
20 views

Check if a struct is empty

I have a function where I pass a id. With that id the contract find in a mapping a struct. My idea is to check if exists that struct with the given id with a if clause. I try with 0, null, "". Is ...
0
votes
1answer
15 views

Does MultiSig wallet's function follows any Token Standard i.e ERC223?

Does MultiSig wallet may include functions like increaseSupply, decreaseSupply and functionality like blackList addresses?
0
votes
1answer
22 views

Truffle will not compile contract written in VS code. Pragma error

I'm trying to run example from https://truffleframework.com/tutorials/pet-shop, but when I run truffle compile I get error saying Error parsing C:/WINDOWS/system32/TruffleTest/pet-shop-tutorial/...
0
votes
1answer
6 views

Remix IDE : Passing array of address and array of uint

Working on the remix IDE, i cant seem to pass an array of addresses along with an array of uint as parameter to a function. It runs just fine on ethfiddle though and behaves exactly how i expected it ...
0
votes
2answers
22 views

Use private ethereum blockchain for storing data [on hold]

I am new in ethereum blockchain technologies. I have some question that Is possible to use ethereum blockchain to store data (Like MySQL)..??? If yes... (for first question) have any documentation ...
0
votes
1answer
19 views

How to cast address to address payable in solidity 0.5.0

Got address from 3rd-party library: address wallet = rlp[5].toAddress(); And wanna transfer some funds to it: wallet.transfer(amount); Got error: TypeError: Member "transfer" not found or not ...
0
votes
1answer
30 views

Upgrading to solidity version 0.5.0 getting deployment failed error with same smartcontract perfectly deployed on 0.4.24

The same smart contract is running smoothly in solidity version 0.4.24 but now when I update the solidity version and solving a lot of bugs inside my smart contract I intended to deploy that in ...
0
votes
0answers
12 views

Why the same contract has more bytecode size in solidity 0.5 in compare to 0.4.24?

My earlier contract was compatible with solc@0.4.24. Now I am upgrading my contract to make it compatible with solidity 0.5 but it leads to an increase in bytecode size. AFAICT There is no change in ...
0
votes
1answer
14 views

Error in external function parameter defination for an interface

Dear community members, I have come across an error while defining an interface (just using the standard one interface ERC721TokenReceiver) this interface is mentioned in this link https://github....
2
votes
3answers
45 views

accepting ether in a smart contract

I want to create a simple smart contract for registration of users to a competition where when users can pay to contract and 2 ethers will deduct from his account. But when I'm trying to do so on my ...
0
votes
0answers
18 views

ERC721 Default Implementation

I’m working on a card game. Right now it is really simple. There are orcs and cards. Both should be implemented as ERC 721. What would be the most natural way to make the orc an ERC-721 token? ...
0
votes
0answers
21 views

Matching inside my contract fails with multiple participants

my contract (can be found on my gist: https://gist.github.com/fabs993/e13fa6ecd9526d30c8a6d85c10180075) fails at more than 5+ participants. So in my use-case I have two kind of participants Producer ...
0
votes
1answer
11 views

Stress test DApps on rinkeby test network

Is there any way of stress testing a dapp? I developed dapp, now I want to see how much stress it can handle? I can't test it on Main Ethereum Network. At least I can do it on Rinkeby test Network. ...
0
votes
0answers
19 views

How to get the return value of call methods in web3 v1? [on hold]

As explained here, when we use web3 v1, we need to use a different way of calling functions (either to read the staet by call() or execute a function by sending transaction). It is not clear how we ...
0
votes
2answers
23 views

Call of contracts function reverted

Sorry for posting a block of code, but I just can't get this to work. I am using ganache for testing my contracts with mocha and NodeJS. Every time I call doTransfer, it fails. The call is reverted....
0
votes
1answer
14 views

Associate event struct to user addresses

I have two contracts. One called User and other called Event pragma solidity ^0.4.24; contract User { mapping(uint=>address) addresses; uint addressRegistryCount; } pragma solidity ^...
2
votes
1answer
22 views

How to burn the token without burn method in contract

while time of contract development, management decided to don't burn any token and we will use our token as utility token for apps but now they have decided to burn unsold tokens after ICO. our ...
1
vote
1answer
30 views

Return a mapping in a getAll function

pragma solidity ^0.4.24; contract User { mapping(uint=>address) addresses; uint addressRegistryCount; function set(address userAddress) public { addresses[...
1
vote
1answer
16 views

How to ERC721 token using external contract to msg.sender?

I have Caller and ERC721 contract just like this : contract SampleToken is ERC721MetadataMintable { string private name; string private symbol; constructor (address _creator, string _name,...
0
votes
0answers
10 views

Using Private Blockchains/DLT (E.g., Quorum) for Cybersecurity purposes to forestall data exfiltration/data leakage through consensus mechanism [on hold]

I am keen to use Private Blockchains/DLT such as Quorum for cybersecurity intent namely to deter and forestall data exfiltration through consensus mechanisms, i.e., securing read operations on smart ...
0
votes
2answers
26 views

Can smart contract send tokens/eth if it doesn't have a send function?

Let's assume you just created 1,000 tokens at address 0x012345. You, the owner of 0x012345 sent by mistake all tokens and 1ETH to a smart contract with address 0x987654. This smart contract doesn't ...
0
votes
0answers
13 views

Array Compare function returns opcode error [on hold]

VMerror:invalid opcode Solidity code pragma solidity ^0.4.25; contract addition{ uint consensus=0; uint[] x; uint[] y; uint sum =0; uint sum1; uint sum2; uint length1; ...
2
votes
1answer
22 views

Burn the rest of the token after airdrop is complete

I have started to develop blockchain and learn solidity. I tried making a smart contract with the 200M supply, the creator only held 50M of the total supply and the rest was in the smart contract for ...
2
votes
1answer
13 views

Trying to understand why my test.js fails

I have a function that is not passing my tests in JS but the function works as expected in Remix. Can you help me contract.sol function test1 () public view returns(bool){ return(true); } ...
0
votes
0answers
21 views

ERC-20 decimals issue

I'm using a simple crowdsale contract: pragma solidity >=0.4.22 <0.6.0; contract owned { address public owner; constructor() public { owner = msg.sender; } ...
0
votes
1answer
17 views

Wich version of solidity do I have to use in Quorum

If I want to use Quorum, in which Solidity version do I have to write my contracts?
2
votes
2answers
28 views

Which version of solidity works web3js [on hold]

In what version of solidity do I have to write my smart contracts if I want to interact with Web3.js
0
votes
1answer
15 views

approve() and sendFrom()

Im trying to run the code below in a smart contract to use as an escrow. calling approve first and calling send from later does nothing to get the tokens into the smart contract, what am I missing ...
0
votes
1answer
22 views

Fallback function calls get reverted

I created a contract which mints tokens when the msg.value is higher or equal to the token(ticket) price. Unfortunately when I send a transaction to the contract fallback it gets reverted. It's my ...
0
votes
1answer
20 views

How to instantiate an array of struct inside a struct

Collection[] public collections; struct Book { string name; address writer; bytes32 proof; } struct Collection { Book[] books; address collectionCreator; } // Question: how to ...
0
votes
1answer
30 views

Could somebody explain me what is the difference of msg.sender, spender, from, to, owner in ERC20?

I read ERC20 solidity code below. https://github.com/OpenZeppelin/openzeppelin-solidity/blob/master/contracts/token/ERC20/ERC20.sol Then, I couldn't understand what the terms of msg.sender, spender, ...
0
votes
2answers
25 views

Saving the actual data vs. hash of the data - which one is better?

I am new to etheruem, I would like to create a smart contract for keeping document data. From 2 designs below, can I know the pro and con of each one, please? put the array of raw JSON data to the ...