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

How can you know the length of array of dyanmic strcutures?

pragma solidity ^0.4.24; contract online_shopping{ struct item { uint price; string name; //string seller; } struct soldItems{ address customer; uint tprice; } mapping (address=...
0
votes
1answer
12 views

Factory for ERC1400, deployed contract not working

Hey I have written a factory for the ERC1400 Token by https://github.com/ConsenSys/ERC1400. When I run the test for issueByPartition I get a revert Error. Other tests like isIssuable works. If I ...
7
votes
5answers
5k views

How to keccak256 multiple types in web3js to match Solidity keccak256?

if I keccak256(string1, address1) in Solidity, and then use web3.sha3(string1, address1) in web3.js, I get different results, even though when I do both with only string1 as a single argument, they ...
0
votes
0answers
7 views

How to signTransaction of a smart contract methods?

I have a smart contract contains this method: function addOneUser (User memory _user) public { bytes32 hash = keccak256(abi.encode(_user.name)); users[hash] = _user; } I want ...
0
votes
0answers
9 views

Payable function not working properly

Hi everyone hope I will be clear enough with the explanation because I couldn't find a proper solution. I am just trying to checkout an item with my buy function but it seems like I am stuck.Here is ...
1
vote
0answers
127 views

Solidity and Web3js codes are not working inside the private Ethereum(geth) network but same codes are working in public ethereum

geth version : 1.9.0-stable-52f24617, node version : v10.16.3, npm version : 6.9.0, web3 version : -- web3@1.0.0-beta.36. genesis.json: { "config": { "chainId": 9663080, "homesteadBlock": 0, "...
1
vote
0answers
22 views

I am newbie here,I need some help in retrieving one particular use using a userid, how do we do that as per below code?

struct Rider{ //address riderAddr; uint rider_Id; bytes32 Rname; bool set; } mapping(address => Rider) public riders; function registerRider(address _riderAddr, uint _riderId, ...
0
votes
2answers
46 views

How to get response from Solidity Smart contract by Web3 client?

Here is the Smart contract code. I want to get the result of function of UserRegister by using web3. function UserRegister(string memory userName,uint feiyong ) public payable returns(string ...
0
votes
1answer
18 views

how to correct this code with pragma solidity^ 0.5.8? thx

pragma solidity ^0.5.8; contract HelloWorld { function test() pure returns (string) { return "HelloWorld"; } }
0
votes
1answer
15 views

I would like to 3 mappings

I am a beginner. I would like to 3 mappings I know 2 mapping looks like this: mapping (address => mapping (address => uint256)) public allowed; and my question is: is 3 mappings look like ...
2
votes
1answer
530 views

Fail to “buy” from Crowdsale contract wrapping an already deployed contract

Hi I am a newbie to the Ethereum development. I have successfully deployed a burnable, pausable, capped token contract (TC) on rinkeby test network, and was able to interact with it - minted and ...
0
votes
2answers
37 views

call to reverseString.reverseStr errored : VM exception while processing transaction Invalid opcode

I am writing simple program to reverse string using solidity ,everything looks ok but while executing the program am getting the error "call to reverseString.reverseStr errored : VM exception while ...
2
votes
2answers
623 views

Gas Estimation Failed in Remix

Found my own problem. Can't really use the transfer function as it is written. It assumes the owner uses it. So made a new function for the "minting" function for the faucet to use. Not sure why the ...
2
votes
1answer
508 views

Truffle Bytecode Different from Etherscan Bytecode

I am having difficulty verifying my contract code on Etherscan using the code generated by Truffle. Using Etherscan VerifyContract V1: https://rinkeby.etherscan.io/verifyContract Truffle produced ...
0
votes
0answers
10 views

ParserError: Expected pragma

Hi guys. I have got one big problem. When i try to compile my code i'm getting some kind of unusuall error. I think everything is ok but when i try to "node compile.js" my main file ("inbox.sol") ...
0
votes
0answers
9 views

How can I distribute funds to present stakers efficiently?

I am building a smart contract which keep the token holder's eths for a while and give them rewards when they withdraw. The reward is given from the ethers collected by early withdraw of people. If ...
0
votes
2answers
11 views

Why am I getting TypeError: Member “balanceOf” not found or not visible after argument?

On line 22 my code is -- require(tokenContract.balanceOf(this) >= _numberOfTokens); This gives the error message TypeError: Member "balanceOf" not found or not visible after argument-dependent ...
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 ...
3
votes
2answers
6k views

How can I get my address via web3?

I'm using web3, truffle and testrpc. In my smart contract, some of the functions can only be called by the owner (or creator) of the contract (i.e. onlyOwner functions). So, I've defined some ...
0
votes
2answers
275 views

ERC20 How to transfer the balance to a new address

I want to call the ERC20 contract with other contracts and transfer the corresponding balance to the contract caller. What should I do?
2
votes
4answers
599 views

Tracking tokenholders of a token with web3

If I have a token address how can I navigate and find certain things like: tokenholder addresses transactions for the token holders including when they made the transaction I'm new to smart ...
0
votes
1answer
20 views

“onlyOwner” Function restrict the call from child contract

I have a basic knowledge of solidity. I am trying to create an upgradable ERC20 Token. For that, I create TokenStorage contract and Logic contract and trying to write the Proxy contract. In the Logic ...
0
votes
1answer
24 views

Function should return all objects stored in the mapping array

Here's my solidity code. And I want all the objects to be returned stored in mapping array contracts in the getContract method by giving address as a parameter to the getContract function. pragma ...
22
votes
4answers
7k views

How to store IPFS hash using bytes?

Following Q/A (What datatype should I use for an IPFS address hash?) recommend us to use bytes to store IPFS hash. I was using following example(https://github.com/AdrianClv/ethereum-ipfs/blob/master/...
0
votes
1answer
23 views

TypeError: Cannot read property 'nodes' of undefined

I'm new to ethereum, and I'm trying to test the depositToken function of etherdelta on linux, which version is 0.4.9, and the token I use is vixcore which version is 0.4.24, and I got this error when ...
2
votes
1answer
75 views

Using 'call' from a constant function

I am trying to determine the behavior of call when executed from a constant function. Of course, the compiler issues a warning on that: Warning: Function declared as view, but this expression (...
1
vote
1answer
299 views

How to print transaction details like block number and other input parameters on front end?

My problem : I want to show transaction details like block hash , block no and input parameters. but it was showing that metamask does not support callback. our function is not waiting till ...
1
vote
2answers
711 views

How to fix “No events were emitted”

I have been following the instructions in the Dapp university tutorial. But I am using Windows 10, Dapp University is Mac. I downloaded this truffle with smart contract ERC20 from Dapp university. ...
0
votes
1answer
96 views

I need help to understand why a function call reverted without any reason

I have a Registry contract, which holds addresses of different smart contracts. The registry has getter for every contract address it holds. In other contract at some point I need to retrieve one of ...
0
votes
1answer
19 views

Decentralized database for ethereum?

I'm looking for a way to store data in a decentralized way such that I can access any record from within the smart contract, probably through oracles I guess? I've been looking into gundb but not ...
5
votes
2answers
575 views

Error: Member “assertNotEqual” not found or not visible after argument-dependent lookup in uint256

I am trying to run test cases in sol-unit for Solidity, but when I compile my code with solc compiler I get an error. I don't think the error is critical, but there is very little material on net ...
46
votes
3answers
30k views

<address>.send vs <address>.transfer best practice usage?

I noticed that address's offer two member functions that perform the transfer of ether to the specified address. send returns false upon failure and transfer raises an exception. In the Solidity ...
0
votes
2answers
25 views

ParserError: Expected pragma, import directive or contract /interface/library definition

In an attempt to compile my ABI and verify my contract, I am getting the following warning: "ParserError: Expected pragma, import directive or contract /interface/library definition" on the first line ...
2
votes
2answers
353 views

Pass arguments to constructor

I got a constructor like this: contract Test{ constructor(uint256 _num) public { num = _num ;} } Now I want to use this contract in another contract. Like this: contract Call{ Test test;...
2
votes
1answer
490 views

How to call the functions of Ethereum Smart Contract from Android/iOS application?

I've been learning solidity & viper for some time now but i am wondering if it's possible to call the functions/methods of a smart contract (already deployed on Ethereum Network) from an Android/...
0
votes
1answer
286 views

I need help; the Solidity Code yields a warning you will see below

pragma solidity ^0.4.4; contract token { function mintToken(address receiver, uint amount){if (msg.value < amount) throw; if (msg.value > amount) throw; } } ...
1
vote
1answer
17 views

Trouble accessing an array inside a struct inside a mapping via web3

Here are a few relevant code snippets from my smart contract struct Constituency{ uint16 id; string name; uint64[] cans; } mapping(uint => Constituency) public constituencies; ...
0
votes
1answer
535 views

Error in Ethereum Wallet:“Couldn't estimate gas, resorting to default parameters. Transaction is likely cheaper than the estimate”

I am using ethereum wallet for deploying contracts in my private blockchain. But whenever I try to send a transaction in my ethereum wallet it shows an error that says, "Couldn't estimate gas, ...
1
vote
2answers
53 views

Analize gas usage and contract design

Suppose that I've the following contract code: pragma solidity ^0.4.23; contract pensCollection{ struct Pen{ uint productCode; address ownerAddress; } address public ...
0
votes
1answer
17 views

How/when to use the system-level variables in building contracts

I am a newbie to this field and currently learning to write some smart contract programs. I am writing to inquire the best practice to use those system-level variables, such as BLOCKHASH, TIMESTAMP, ...
1
vote
1answer
11 views

Uncaught (in promise) Error: Contract has not been deployed to detected network (network/artifact mismatch)

The client side application always throws the above error. I have connected the ganache account(by copying the private key)also with the correct port number in Metamask extension as well as in the ...
2
votes
1answer
47 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); } ...
1
vote
2answers
32 views

“Gas estimation failed” on Ropsten with Invalid RPC JSON

I'm running into an issue going through a basic example in "Mastering Ethereum"... I have a Faucet contract (on Ropsten) per the book that looks like... pragma solidity ^0.5.1; //mastering ethereum ...
1
vote
1answer
29 views

Is there a need to check for null after casting?

Example: MyReceiver my = MyReceiver(_to); // To is an arbitrary address user provided my.someFunction(); // Do I need to check for my == null before calling? Strange enough I do ...
0
votes
1answer
53 views

is there any way to save data from sensor on smart contract automatically?

I want to take the temperature value from one sensor on save it on the contract of manually , i tried to use node-red , or raspberry pi but i didn't get a good result. the second question is it ...
0
votes
1answer
2k views

Airdropping ERC20 Tokens to multiple addresses in a single transaction

done , wrong question. better to use this contract ERC20 { function transfer(address _recipient, uint256 _value) public returns (bool success); } contract Airdrop { function drop(ERC20 token, ...
0
votes
2answers
93 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
316 views

“Error: VM Exception while executing eth_call: invalid opcode” when accessing array

I'm trying to incorporate storage in a smart contract where participants of the contract will have their address stored in a address[] look up table participationAddressLUT. The contract initializes ...
1
vote
2answers
2k views

Out of gas when executing contract via web3 js

I am having a trouble invoking contract via web 3 js in browser. I am using truffle develop and have migrated and run tests successfully. I am also getting the info when I console.log the contract....
3
votes
2answers
1k views

How to debug solidity contracts with truffle?

I've been having a very hard time with Solidity development due to not being able to easily console log as well as the truffle debugger causing problems. How do you console log in Solidity? Truffle ...