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.

48
votes
5answers
12k views

How can you decompile a smart contract?

On the blockchain I can inspect the code of a contract, and see the EVM opcodes. Is there a way to decompile this and convert it back to (Solidity) source code?
1
vote
1answer
19 views

HDWalletProvider & truffleconfig: 'truffle migrate' will compile but not do anything else

I am trying to build a React app with Truffle. Firstly, my file structure is like so, with root_dir being the project root directory: root_dir/node_modules/src/libs/truffle All of truffle's files, ...
0
votes
1answer
36 views

Modifier condition always false

I am passing an array of addresses into a contract from a parent contract. Using that I am generating a mapping with those address to quickly verify the msg.sender is part of the set mappings. To ...
0
votes
2answers
11 views

Calling an address array in web3 returns an error that the method needs arguments

I'm declaring a public address array in my contract, but when I call it, I get an error saying it's expecting an argument. Can someone shine a light on what is happening here? Contract.sol uint ...
2
votes
1answer
243 views

How to calculate the merkle proof for quering the balance of a token holder?

I know this can be done through accessing the full node of Ethereum, but I want to know, how could I do it technically? Suppose I have an ERC20 token contract having address 0xabc.. and Alice is the ...
0
votes
2answers
37 views

Code Example from “Mastering Ethereum: Building Smart Contracts and DApps” doesn't work

I'm reading the Ethereum book of Gavin Wood right know and the following code example gives an error message when I try to compile it with truffle: pragma solidity ^0.4.22; contract calledContract { ...
0
votes
0answers
6 views

TypeError: Member “equal” not found or not visible after argument-dependent lookup in type(library Assert)

Truffle v5.0.8 (core: 5.0.8) Solidity v0.5.0 (solc-js) Node v10.13.0 Web3.js v1.0.0-beta.37 Assert.equal worked in Truffle 4.x. pragma solidity >=0.4.21 <0.6.0; import "truffle/Assert.sol"; ...
1
vote
0answers
11 views

Adding additional info for initial state of Drizzle

How do I add extra content to the initial state of drizzle? I want to keep some local information that is not dependant on the blockchain. Should I keep a seperate redux store for that or is there a ...
0
votes
0answers
16 views

How to flush token to another contract from token holder's token balance from ERC-20 contract?

I have to implement the following scenario: - One ERC-20 token contract. - Another contract which will flush tokens of ERC-20 tokens. - Add these tokens to one, defined Admin address. Note: All ...
0
votes
1answer
41 views

what type of encoding is used by the abi specification in solidity

the abi specification of solidity which provides functions like abi.encodePacked() using a certain type of encoding (eg: for functions, a 4 byte function signature hash followed by encoding of ...
3
votes
1answer
24 views

Embedding ETH Wallet Address into Webpage

Hey is there a quick way to embed an Ethereum wallet address and a button into my existing website so as to allow people to send in their ETH donations to me? Or do I need to go through the whole npm ...
0
votes
0answers
11 views

Smart contract migration through Proxy delegate pattern in solidity 0.5

I am trying to do smart contract migration in solidity 0.5 using the proxy delegate pattern. When I write the integration test in javascript how should i make a delegate call using the proxy contract ...
0
votes
0answers
18 views

How should I pass a nested struct as a function argument in Remix IDE?

Example contract: pragma solidity ^0.4.24; pragma experimental ABIEncoderV2; contract someContract { struct structOne { uint a; } struct structTwo { uint b; ...
0
votes
1answer
13 views

How to get parameters of an object from array using loop

I am using a loop to retrieve an object from array. Then get its details and compare it with other string. But it gives error Type bytes32 is not implicitly convertible to expected type struct ...
0
votes
1answer
38 views

ERC 20- Tokens missing

I am not a Core developer, however, I tried to write a code for someone. Everything went fine but I am unable however after that am unable to transfer or get to know where are the tokens which got ...
0
votes
1answer
20 views

How to set up Quorum Blockchain?

I have read a lot about Quorum blockchain. My goal is to run and test it. I have found many articles. Could anyone suggest me good start-up articles for setting-up the Quorum on a number of nodes and ...
0
votes
1answer
17 views

Delay a transaction

Is it possible to delay a transaction in one contract? let's say Alice wants to send a product to Bob and Bob has to transfer, for example, 2 Ethers to Alice for buying that product. How can I do ...
0
votes
2answers
40 views

promise chaining in test.js file

it("should throw an exception if you try to buy an article that does not exist", function() { return ChainList.deployed().then(function(instance) { chainListInstance = instance; ...
1
vote
1answer
15 views

Create Contract Solidity 0.5

My code works with compiler 0.4.25 but not with the latest version. I want to keep track of every "Contract 2" that "Contract 1" create. Contract 1 uint public countContract; address[] public ...
1
vote
1answer
14 views

Encoded input params

I created a simple test contract with a single method: pragma solidity ^0.4.24; contract SimpleTest { function testFunc(string name, bool isFirst) public { //do stuff } } I'm ...
1
vote
1answer
35 views

Contract NOT created when using “new” on testnet

I've got a contract which one of his functions creates a new contract in the following manner: (Solidity) function createCarrier() public { P2Carrier newCarrier = new P2Carrier(msg.sender); ...
0
votes
1answer
24 views

Is there any Reentrancy attack in given code snippet? If yes then how can I fix it?

function withdrawForeignTokens(address _tokenContract) onlyOwner IsAuthenticate public returns (bool) { ERC223Interface token = ERC223Interface(_tokenContract); return token.transfer(...
0
votes
1answer
21 views

Cannot read property 'sendEth' of undefined, 'sendEth' is function in smart contract

Hi I'm trying to interact with an Ethereum smart contract but it is always showing "TypeError : Cannot read property 'sendEth' of undefined" where 'sendEth' is a function in my smart contract Here is ...
0
votes
0answers
19 views

address.replace is not a function

I'm not really sure why this web3 method is being called in my code and why it's not a function apparently. Can anyone help me understand what the issue is here? Unhandled Rejection (TypeError): ...
1
vote
1answer
38 views

How to process Smart Contracts payable functions in batch?

I am aware that metamask will enable effective security for processing via the web browser a payable function action to a smart contract. What happens in batch? I have an API service which then ...
0
votes
0answers
7 views

Getting value for Event watch in solidity and react

I'm trying to listen for an event in my smart contract when I call another function. Smart contract event event documentAdded( uint id ); Smart contract method function sendDocument( ...
0
votes
2answers
147 views

Remix IDE error: send transaction failed : invalid address. if you use injected provider, please check it is properly unlocked

I've got the error message in the title when I'm trying to deploy my contract: pragma solidity ^0.4.22; contract University { address public owner; address public student; address ...
0
votes
1answer
39 views

More expensive token everyday

I'm using a very simple crowdsale it just sells tokens in ratio 1ETH=10000 tokens I would like to change this so every day token would be more expensive for example Day1: 1ETH = 10 000 Tokens Day2: ...
0
votes
0answers
25 views

How dapp owners pay for their clients transcaction fees in the Ethereum Blockchain?

I am currently dealing with a problem in Ethereum Blockchain. I wrote a smart contract in Solidity Language, about a site that someone can make his Registration and after the transaction is completed ...
0
votes
1answer
35 views

I want to withdraw amount from Receiver Contract's tokenFallback() function in ERC223 how to implement this scenario?

I am using ERC223 standard token transfer contract and receiver contract which includes tokenFallback(). I've transferred tokens from my ERC223 contract to receiver's contract address, now I want to ...
0
votes
1answer
98 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
19 views

Solidity modifiers in library?

Isn't it possible to define modifiers in libraries? I'm really asking myself why, because thats some functionality you would need over and over again. If I would like to hypothetically implement some ...
0
votes
1answer
43 views

The funds sent to the contract do not show the correct value on the side of the contributor.?

The question is not answered that's why I ask again. Can someone tell me and point out ( correct me) where the problem lies. Eth has been sent to the crowdsale contract successfully. BalanceOf and ...
1
vote
1answer
35 views

Initiate transaction from server to smart contract

In my case, i have an API written in PHP which periodically checks the database. If certain condition was met, i need to send an alert message from the API to an account/node in the Ethereum ...
1
vote
2answers
24 views

On-chain settlement based on off-chain activity

I'm build a DApp where the end-user should be able to attach a proof (could be information, data, attachment, whatever). Now, if the DApp accepts this proof as being legit off-chain, then I want the ...
0
votes
1answer
12 views

Creating a new contract specifying a sender and value with factory pattern

I am using a factory pattern to deploy its children contracts here. The child contract has a constructor as followed: constructor ( string memory _potName, uint _duration, uint ...
0
votes
1answer
21 views

How to test kill function including selfdestruct()?

there. I'm coding kill function below: function kill() public onlyOwner returns (bool) { selfdestruct(msg.sender); return true; } and my unit test code: function testOwnerCanKillContract()...
0
votes
1answer
37 views

Impossible to transfer my token via Token.transfer or Token.transferFrom

Everytime I’m trying to make a transfer I’m having an error, every other methods seems to work except transfer & transferFrom. I’m having an issue with my “token.transfer” (token is my ERC20), ...
1
vote
1answer
42 views

What size value does the EVM use for intermediate results of an expression?

I've found this code in a Solidity contract, and had seen a presentation where this sort of code was used as well. In the work I've done in compilers the intermediate results of expressions are stored ...
1
vote
1answer
34 views

Numerical Value of Bools in Solidity

What is the numerical value of true and false? Presumably one is 0x0000000000000000 and one is 0x0000000000000001
0
votes
1answer
41 views

Restricting payment from one account only

I am a beginner in ethereum DApp development and I am testing my Contracts in Remix IDE. My question is that can I restrict only one account to pay for all the transactions happening on my application ...
2
votes
2answers
45 views

Is it possible to implement the essence of smart-contract into another one before deploying the first one?

My question means for example that the primary contract stores names of secondary contracts, for example like this: mapping (address => string) secondaryContractNames; I know we can in the ...
1
vote
0answers
7 views

What happens when some files use the ABIEncoderV2 and some don't

The version 2 of the ABIEncoder used by solidity can be enabled with: pragma experimental ABIEncoderV2; What happens if I compile with truffe a project that has some files with that pragma and some ...
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 ...
0
votes
1answer
20 views

How to integrate Drizzle with react

I have currently set up a truffle project with react, redux and react-router. I just finished writing my first implementation of the smart contract, and now want redux to connect with the smart ...
0
votes
1answer
19 views

How to return values from dynamic array push function?

How to fetch value from dynamic array push function? Below is the code of pushing function, but how will I fetching that array values? contract PushStruct { struct MyStruct { uint field1; ...
0
votes
0answers
15 views

From Truffle Ganache and localhost to Web Server

i created a contract that run easy on my localhost with npm run dev after truffle migrate --reset and i can use my GUI on localhost:3000. Now i tried to deploy it on infura Ropsten using my Metamask ...
0
votes
0answers
17 views

Purchase of ICO token in Fiat currency/ Bitcoin [on hold]

I want to launch my ICO, where you can buy tokens with fiat currency, ethereum and bitcoins. Suggest any help, How I can integrate it within a minimal time? Any Free API's Are available for the same?
1
vote
3answers
859 views

How to see events in Remix - Solidity

I am new to solidity and trying to deploy a contract to see whether the address is EOA or Smart Contract. The code is listed below. I am not able to see the boolean value when I executed the contract ...
0
votes
0answers
16 views

Deployment of smart contract

How to deploy a smart contract on my own blokchain network? I have created using python and running on postman client server interface. I have already tested on ganache , solidity IDE and ethfiddle.