Stack Exchange Network

Stack Exchange network consists of 175 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
38 views

How to compare two bytes32?

I was using strings before I read that using bytes is gas cheaper. Now I changed my strings to bytes32 but I don't know how to compare them. I need to check if two bytes32 are equal in the require ...
1
vote
1answer
75 views

I can't get ERC20 token sweep from a contract to work

I wrote this contract below that would create a factory contract which generates user deposit addresses. the user addresses would forward any deposit to the authorized caller on the factory contract, ...
0
votes
1answer
20 views

How to run a contract in specific time? [duplicate]

I am developing a simple application that should work only in a specific time, lets say between 0800 hrs and 1600 hours. How can I do it. That means. The contract should start by itself at 0800 and ...
0
votes
2answers
10 views

Making a data Registry - does reading from other contract view function cost gas?

As known, reading view functions is free, but is it also free if I use it between two contract? Let's say I have a contract Registry which has mapping that stores string => uint, nextly I pay some ...
0
votes
1answer
23 views

web3 reading memory string gives error

i have declared a string variable in struct like struct test{ string testString; } I have written a function to access the variable like function getteststring(uint256 index)public ...
0
votes
1answer
45 views

how to call function in proxy contract

https://github.com/rayonprotocol-research/solidity-upgradable-contracts/blob/master/contracts/Proxy.sol I'm practicing proxy pattern but i dont know how to call function at logic contract from proxy ...
0
votes
1answer
15 views

Can be fix our token price to a stock?

For example can we create a pepsi token which is fix to pepsi stocks? Do you think that is useful?
0
votes
0answers
42 views

Infinite gas cost when trying to use transfer()

I tested the contract using Remix Javascript VM, Injected Web3(Ropsten) and in-built Ganache client from Embark Framework(4.0). Always getting infinite gas usage. Can someone please help me? This is ...
1
vote
0answers
31 views

Function call always returns 0

Working with a simple contract to get the hang of this. I can't seem to get the correct value back from my contract function. It always outputs 0. Truffle version: 4.1.15 Contract: pragma solidity ...
0
votes
0answers
23 views

Web3 vs. web3.js

Experienced iOS developer here - but very new to Ethereum Smart Contract development. I'm trying to figure out why the web3 version that gets loaded by MetaMask into my browsers when I run my app (...
0
votes
0answers
24 views

Errors when trying to Compile & Deploy Election Smart Contract

Cloned a project from a tutorial from here which is a voting dapp on etherum https://github.com/dappuniversity/election. When i try to compile the contract i get the following error project/...
0
votes
1answer
23 views

Pushing constructor result to contract member array

I'm trying to do the following operation in Solidity: BetCampaign memory newCampaign = BetCampaign(id, new Bet[](0), betEndTime, false); betCampaigns.push(newCampaign); With the following member ...
0
votes
2answers
34 views

Uncaught Error: Invalid number of arguments to Solidity function

function TriggerContract() { var account = getAccounts(); var test = web3.eth.defaultAccount; console.log(account); var q = document.getElementById("Quantity").value; var ...
1
vote
0answers
35 views

Web3 Version refuses to update

The official documentation of web3.js has this little commented statement saying: // in node.js use: const Web3 = require('web3'); (you can find it here: https://web3js.readthedocs.io/en/1.0/getting-...
1
vote
2answers
29 views

Realistically how often can I iterate a loop?

I realise looping is an anti-pattern, but I can't see a way round it. I'm maintaining an ordered list of addresses in a mapping. Separately there is a mapping of addresses to struct where I keep the ...
3
votes
3answers
38 views

Why creating a private variable and a getter instead of just creating a public variable in solidity?

I want to implement a contract like the ERC20Detailed.sol example from open Zeppelin: My question: why setting a private variable and then, creating a getter for the same variable when the solidity ...
0
votes
1answer
77 views

Initial ERC20 Token supply split into 2 or more hardcoded addresses

don't know if someone can help me, but let me explain my problem. For more transparency in my ERC20 token generation smart contract, I want to hardcode the Team Pool (0xA) and Crowdfunding Pool (0xB) ...
0
votes
1answer
101 views

Specify different solc compiler for different files in truffle?

I am using truffle, and have a number of x.sol files in the contracts directory, different files require different versions of the compiler - how do i deal with that? I think i SHOULD be able to do ...
0
votes
1answer
38 views

Pass structures between contracts with Solidity 0.5

I'm trying to pass an instance of the Storage structure from StorageController.sol to Publisher.sol. No matter what I do, I get VM Exception while processing transaction: revert in my Truffle test. ...
1
vote
2answers
42 views

Check if a variable exists in external contract

kinda new to the development side of Ethereum. Been searching around for days but can't seem to find an answer for my specific case. I'm trying this challenge here. The problem is that I can't seem ...
0
votes
1answer
29 views

Etherscan “Write Contract” Tab - what is it for?

What is the purpose of the Write Contract Tab in Etherscan? For example, if you look up the QTUM Token Contract on Etherscan (https://bit.ly/2IsddkT) and then tap on the Write Contract TAB, you have ...
3
votes
2answers
103 views

How to use bignumbers in truffle tests?

I am testing a smartcontract with Truffle V5. All works well if I do not use all decimals. If I set 18 decimals all explodes. The test code is this (from truffle docs): const MetaCoin = artifacts....
0
votes
1answer
36 views

Transaction pending

If I call this function the transaction get pending and never finish. Any idea? pragma solidity ^0.4.24; contract test { uint[] values = [1,2,3,4,5,6]; function removeValueFromArray(uint _num) ...
0
votes
1answer
25 views

ParsedContract.sol:1:17: ParserError: Token incompatible with Solidity parser as part of pragma directive

Code : git clone https://github.com/dappuniversity/election https://github.com/dappuniversity/election/tree/2019_update Errors faced : Commands: Compile: truffle compile Migrate: ...
0
votes
2answers
28 views

What are differences between bitcoin and etherum trancactions?

I have read about how transactions work and how they can be redeemed in bitcoin. In a very abstract way, the sender defines the output script that should redeem the transaction. But I am new to ...
0
votes
1answer
46 views

Smart Contract function keep return Null value?

Hey I am new with Solidity. And I just tried to link my front end view with the smart contract. With the simplest possible approach. My contract:- My JS code:- Console keep printing 'null' I don't ...
1
vote
1answer
18 views

How does ENS (Ethereum Name System) work?

The reason of the ENS (Ethereum Name System): Making an address 0x123f681646d4a755815f9cb19e1acc8565a0dddd reachable under a rememberable string like abcdef.ghi.eth. But what I don't understand: How ...
0
votes
1answer
27 views

Revert Assert best option

I have a contract(A) function with the standard onlyOwner access. If I call directly from the deployed account the function works fine. But when I import this contract(A) into another contract(B) and ...
0
votes
1answer
23 views

Can we freeze amount of token, amount of time with smart contract code?

Is there a smart contract code to freeze amount of token amount of time. For example i have 20 ether, with a smart contract code can i freeze it 1 year, even i can not touch it? With that code our ...
0
votes
0answers
29 views

How to pass the whole array from one contract to another when working with different solidity files?

For example, I am taking one function function transferAddresses() in my contract contract one{} from where I am taking number of addresses in array. Now I want to transfer the whole data of the array ...
0
votes
1answer
19 views

Interface overriding

I have two contracts. One of them inherits another. Inside the parent contract I have the interface interface Token { function transfer(address to, uint256 value) external returns (bool); } I ...
0
votes
1answer
18 views

How to set token holder's address without duplication?

In following code I've implemented two functions to set and get Token holders. function setTokenHolders(address _to)internal returns(bool){ for(uint i = 0; i<= tokenHolders.length; i++){ ...
0
votes
1answer
24 views

Remove array specific value

In a array that the values are never repeated. Is there a function/library or something similar that you give the value to remove. And the function the empty space in the array?? function remove(uint ...
0
votes
1answer
79 views

Solidity ,Member“transfer”Not found or not visible after argument dependent lookup in address

pragma solidity ^0.4.11; /** * @title Ownable * @dev The Ownable contract has an owner address, and provides basic authorization control * functions, this simplifies the implementation of "user ...
1
vote
1answer
40 views

Warning: Functions in interfaces should be declared external

I have a following interface function: pragma solidity ^0.4.24; interface myInterface { function registerUser(string memory email) public return (bool success); } contract myContract is ...
0
votes
1answer
82 views

truffle migrate does not return anything

I am following the tutorial from Truffle to create a "pet shop" contract. I can follow everything until he tells me to truffle migrate. Here is the contract: pragma solidity ^0.5.0; contract ...
0
votes
2answers
38 views

sending signed transactions from contract

Is it possible to send private key signed transactions directly from the contract? The thing I want to do is to create a similar function function sendTransactionForUser(_signedData, contractAddress)...
1
vote
0answers
38 views

Can solidity bytecode has unreachable code

I've compiled contract from https://theethereum.wiki/w/index.php/ERC20_Token_Standard (Sample Fixed Supply Token Contract: contract FixedSupplyToken version:0.5.1+commit.c8a2cb62) I try to make ...
0
votes
1answer
29 views

Interfaces in solidity

I have one interface like the following: pragma solidity ^0.4.11; interface TokenInterface { function transfer(address recipient, uint amount) external returns(bool); } And the implementation in ...
0
votes
0answers
33 views

VM error in Truffle

Running the code below returns a vm error: Error: Returned error: VM Exception while processing transaction: revert at Object.ErrorResponse (node_modules/truffle/build/webpack:/~/web3-eth/~/web3-...
0
votes
1answer
56 views

ERC20 is an abstract contract or an interface and cannot be deployed

i am trying to deploy a test erc20 token with truffle on ganache-cli My migration file name 2_deploy_contracts.js here is the code for it: var erc20 = artifacts.require('./ERC20.sol'); module....
0
votes
1answer
25 views

Can't create child contract in mainnet?

address[] child; function createChildContract() onlyOwner public{ address newChild = new Child(msg.sender); child.push(newChild); emit ChildCreated(newChild); } contract Child { ...
1
vote
0answers
25 views

Why does ecrecover() take signature parameters (v,r,s) instead of the full signature?

Is there any reason ecrecover() takes the (v, r, s) signature parameters instead of the full signature, given that these can be easily computed inside the function itself? I am asking because ...
0
votes
0answers
19 views

Which invocation of 'call' would invoke the fallback function?

Can somebody please guide me which 'if statement' would result in invoking the fallback function? if (msg.sender.call.value(balance)()) { totalBountyAmount -= balance; OR if (msg.sender.call....
0
votes
0answers
30 views

Subscribe to changes in contract balance (Web3j)

Using web3j I would like to subscribe to changes in a contract balance i.e deposits and withdraws. I would like to base this subscription over transactions (and not events) since the contract does ...
2
votes
2answers
30 views

Does a string message increase the gas usage of a `require` statement?

In solc 0.4.22 onward, it is possible to provide a string message containing details about the error that will be passed back to the caller (in require, assert and revert statements). Does the gas ...
0
votes
1answer
16 views

Read storage struct from a modifier

If i read a struct(storage) Human storage human = humans[2]; in my modifier is there a possibility that the function that uses this modifier can use the "human"? Otherwise i have to scope the storage ...
1
vote
0answers
28 views

Parsing Error while compiling pet-shop tutorial

I am just getting started with smart contract programming and was trying to implement the pet-shop example as per this tutorial https://medium.com/tomochain/how-to-build-a-dapp-on-tomochain-...
0
votes
1answer
37 views

why several Draw event logs when there is actually one?

I'm looking into the event logs of makerdao's CDP operation, and I'm confused why there are several event logs for 1 cdp operation, like this tx: https://etherscan.io/tx/...
0
votes
1answer
26 views

how to deal with large numbers in Ethereum?

I am confused with the use of large numbers in solidity, ethereum. I have some doubts please help me with them. 1) I am not able to represent the value of p using p.toNumber() but can represent it ...