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.

1
vote
1answer
150 views

Convert future date to UTC

Is there an easy way to convert a set time to UTC and stored in a smart contract? I know we can set dates relative to the current timestamp such as "now + 5 days". Though if we wanted to set a ...
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
1answer
146 views

Why does the transaction stay in queue from more than 240 second

I am running quorum nodes via the Quorum-maker script, and when trying to call functions from my already deployed smart contract, I get this error : Transaction ...
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
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
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....
1
vote
1answer
144 views

Is there a way to get vim plugin for Remix IDE?

I use vim regularly for coding. I love the way remix gives all packages to develop on the browser, but it is convenient to go arrow keys and not being able to use vim shortcuts to delete. Is there a ...
2
votes
1answer
151 views

web3.py constructor(address type)

I tried to deploy the contract on my testrpc, but I get error when my constructor using "address" type. Here is my python code: import json import web3 from solc import compile_source from web3....
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 ...
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[] ...
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
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 ...
0
votes
1answer
162 views

How to get only past 2 days events using getPastEvents everytime?

How can the following query be modified to only fetch the past two days worth of events: const events= await MyContract.getPastEvents("eventName", { fromBlock: 0, toBlock: "latest" });
1
vote
1answer
40 views

How to fetch values from double mapping?

I have a structure data with double mapping for storing and fetching details. Here is the code : struct data { uint a; uint b; } mapping(address => mapping(bytes11 => data[])) ...
0
votes
1answer
165 views

Error while calling function in smart contract using nodejs?

I have deployed a contract in private blockchain using mist wallet. When I try to call the function in the smart contract using web3 api it through the below error /home/karthikeyan/Desktop/n2/...
1
vote
1answer
172 views

Any way to have delegatecall change the delegate contract's storage state?

A delegatecall'ed function executes inside of the delegatecaller contract's own memory & storage context. But I'm wondering whether the following is in any way possible (i.e. if certain access ...
0
votes
1answer
144 views

Chain ID set to 1(provided 15) while creating private net using Geth

[{ "difficulty" : "0x20000", "extraData" : "", "gasLimit" : "0x8000000", "alloc": {}, "config": { "chainId": 15, "homesteadBlock": 0, "eip155Block": 0, "...
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 ...
2
votes
1answer
214 views

ERC-20 contract from another contract

I am trying to create contract which can access functions of any ERC-20 standard token contract. At first, I'd like to get balance of given address. I run private testnet using geth, I have deployed ...
0
votes
1answer
174 views

Custom token transfer, what am I doing wrong?

I am trying to hash an address then send tokens to a mapping of the hash in the token contract, then be able to withdraw those tokens using a hash of the address. It compiles but cannot make it work. ...
1
vote
1answer
11 views
2
votes
1answer
153 views

Encode raw transaction data for inner transaction data for transfer using erc223

How do I encode data for inner transaction call of ERC223Receiver contract after transferring erc223 tokens to it? example: Contract ERC223Receiver { function foo(uint256 a) { // some ...
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
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.
2
votes
1answer
208 views

Recommendations for setting ERC20 token totalSupply and decimals?

Looking through the Ethereum.org token tutorials.Any advice or recommendations on setting your total supply and decimals? Inline comments says: 18 decimals is the strongly suggested Any ...
0
votes
1answer
186 views

invalid argument 0: hex string without 0x prefix

In order to get a list of transactions by account address I used the following code snippet - function getTransactionsByAccount(myaccount, startBlockNumber, endBlockNumber) { if (endBlockNumber == ...
3
votes
1answer
156 views

Using other then uint256 number types as mapping keys

Working on contract optimization and found that I actually do not need use uint256 everywhere. Mostly I am using uint32 or even uint16, even payment amount could be packed into 32 bits with reasonable ...
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
2answers
195 views

web3 (then property) in ethereum node

Would you please help: When I run the below command in my nodejs console I get the below error: (I am using web3 0.20.0) on Windows 10 web3.eth.getAccounts().then(list => {accts = list}) ...
0
votes
2answers
154 views

How to call a function and to read return values from an external deployed contract address?

I am trying to call a function from deployed contract address using the below format DeployedContractAddress.call(bytes4(keccak256("get(address)")),0xfffff); But when trying to call the get(_address)...
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 ...
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 "...
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 ...
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
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
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 ...
4
votes
1answer
159 views

Contract storage not changing on calling function

contract SimpleStorage { mapping(bytes32 => string) storedData; function set(bytes32 key, string value) { storedData[key] = value; } function get(bytes32 key) constant ...
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
2answers
197 views

Parse Error before Event definition in solidity

pragma solidity ^0.4.0; import "github.com/oraclize/ethereum-api/oraclizeAPI.sol"; contract DieselPrice is usingOraclize { function DieselPrice(){ event one(string description); ...
0
votes
1answer
84 views

Error Creating a Crowdsale Contract

pragma solidity 0.4.16 contract code - Am receiving the following message: Could not compile source code No visibility specified. Defaulting to "public". function transfer (address, ...
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
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 ...
3
votes
4answers
2k views

Truffle develop (Ganache) increase block gas limit

I can deploy my contract on Remix (Javascript VM and Rinkeby), but if I try to use truffle develop and migrate, I am getting an error: Error: Exceeds block gas limit. The gas used in Remix is 3585084. ...
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
1answer
328 views

How do I call Approve() function from the contract creator's address? ERC20 token escrow

I am trying to send ERC20 token into an escrow contract so that it could transfer them to relevant stake holders. The part that I am stuck in is properly using the approve function. From my escrow ...
1
vote
1answer
78 views

ERC20 Interfaces overwriting ERC721 functions - Possible to adhere to standard?

Is it possible to have a contract that both generates and manages its own NFT according to the ERC721 Standard, and is able to make calls to outside ERC20 contracts? My contract currently inherits the ...
1
vote
1answer
806 views

Truffle: Why is my “onlyOwner” modifier not running in truffle?

I'm using a simplified version of a contract provided by Solidity website. My contract is as follows: pragma solidity ^0.4.4; import "./ConvertLib.sol"; contract MetaCoin { address owner; uint ...
0
votes
1answer
715 views

Member “mul” not found or not visible after argument

I'm a beginner trying to write a Token contract, and I have encountered an error using Solidity 0.4.19. Here is the piece of code with the problem: function createTokens () payable { require(...