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
4 views

how to catch an event fired by __callback of Provable?

My smart contract should return the ETH rate from Coinbase api .. So i'm using Provable engine and i'm testing my smart contract locally using ganache and ethereum-bridge . It's expected that result ...
0
votes
0answers
8 views

Cannot install web3 on nodejs

When I try to install web3 using 'npm install ethereum/web3.js --save' command, I get the following error messages- npm ERR! path git npm ERR! code ENOENT npm ERR! errno ENOENT npm ERR! syscall spawn ...
0
votes
1answer
27 views

Empty array is being returned

Am trying to add few hashes into an array and retrieve those but the getHash() is returning an empty array. My smart contract is : pragma solidity ^0.5.0; contract simpleexample{ bytes32 public ...
1
vote
0answers
19 views

Is there an API to Download source code of verified smart contracts from etherscan?

There is same question on stackexchange but the answer to that question does not include the new api on etherscan which, given an address as input, allows you to download source code of that verified ...
1
vote
2answers
27 views

invalid bytes32 value - Maker Contract Call

I am trying to call the Maker CDP Contract manager smart contract. I want to get the information from this public mapping in the contract. mapping (bytes32 => Cup) public cups and should ...
1
vote
1answer
27 views

Can I deploy smart contract written in an older version of solidity ? If yes how to recognize it in EVM?

If I can compile a smart-contract written in an older version say 0.1.3, can I still deploy it? If I can, is there a way to look at EVM bytecode and tell that this smart contract is written with an ...
0
votes
0answers
31 views

web3.js version is 1.2.1 , Error: Returned values aren't valid, did it run Out of Gas?

my web3.js version is 1.2.1 let testAddr = "0x0c1A5F4556B09C89D29c1F4C4b2497EEd81aF31D"; let contract = new web3.eth.Contract(abi, contractAddress, {gasPrice: '3000000', from: userAddr}); ...
0
votes
0answers
40 views

How to get the result from another contract's Optional method while return empty if it does not exist or throws? [duplicate]

For example I want to write a contract where when one passes the address of another contract to it, it will check whether this other contract has the name() function, and if the name() function ...
0
votes
1answer
14 views

Get array of structs by giving address as parameter

Here's my code: contract company { struct contractDetails { string contractId; string companyA; string companyB; address A; address B; uint256 ...
0
votes
0answers
13 views

Error: IPFSInbox has not been deployed to detected network

It's my first time writing smart contract in solidity and using IPFS to develop my dapp. I don't know how to solve it and why it pops up this errorNo web3 instance injected, using Local web3. Error: ...
0
votes
1answer
32 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; ...
0
votes
1answer
28 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 ...
0
votes
0answers
14 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
17 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 ...
0
votes
1answer
21 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
65 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 ...
1
vote
0answers
25 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
22 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
12 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
15 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 ...
0
votes
1answer
23 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
25 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 ...
-1
votes
2answers
57 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
20 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 ...
0
votes
1answer
27 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 ...
1
vote
1answer
14 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 ...
0
votes
0answers
11 views

How to filter by string parameter , web3 2.0.0-alpha.1 Solidity events?

I'm trying to filter some events , and I noticed since I updated the web3 to version 2.0.0-alpha 1 the event catch is a little bit different. I have a Smart Contract with this event : event ...
1
vote
1answer
33 views

VM error: revert. revert The transaction has been reverted to the initial state. Note: The called function should be payable if

Hi Guys 👋 I have two contacts first one is SubToken and second one is MainContract. First I deploy MainContract after that I use createNewContract function and I create new SubToken. and then I ...
0
votes
2answers
26 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 ...
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; ...
2
votes
1answer
29 views

TypeError: Indexed expression has to be a type, mapping or array (is function (address) view external returns (string memory,string memory…)

I have 2 contracts first one is sub second one is main . First i deploy main and create a new subtoken. Then I want to access my maincontract in subToken contract but I cant :( When I compile this ...
0
votes
0answers
18 views

What does mean $(sai tub) and $(sai tap) in SAI readme.md

I try to deploy and use https://github.com/makerdao/sai/( SAI ) on my private blockchain. I deployed SAI with scripts (bin/deploy-fab && bin/deploy) without any mistake. In https://github....
0
votes
0answers
38 views

Transactions go to an older contract address rather than the present deployed one

Though I have deployed a new contract but the transactions go to a previously deployed contract in my application. I'm attaching the screenshot of my Remix-ide code and the code for the front end ...
0
votes
1answer
18 views

Why am I getting a Parse Error in my smart contract after the constructor?

I'm writing a token sale smart contract & my original error was my function had the same name as the contract and I changed it to a constructor because the contract cant have the same name as the ...
0
votes
0answers
23 views

VS code Expected identifier, got 'LParen'solc

I keep getting this error/warning on my vscode when I emit events and build constructors. or After a bit of googling I understand it is something about my compiler, since solc <0.4.18 does not ...
0
votes
0answers
20 views

No Events After Deploying Another Contract in Remix

I am trying to write an upgradable smart contract in Remix. This involves a Proxy contract, a Logic_0_1_0 contract, and a Logic_0_2_0 contract. I uploaded Proxy and Logic_0_1_0 only, and the ...
1
vote
2answers
33 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
23 views

Getting an error when (attempting to) using Web3js

I'm trying to connect a smart contract to a very simply front end that has html/css/js. I keep getting an error when trying to use web3 to connect - I have the code below but the terminal is giving ...
1
vote
1answer
10 views

ganache test returns characters instead of numbers

mapping(uint256 => uint256) public amount; function saveAmount(uint256 _id, uint256 _amount) public { amount[_id] = _amount; } I have a function that saves amount in mapping. When I test ...
0
votes
1answer
15 views

How do I check If a map entry doesn't exist for a given sender?

I have a map such as: mapping (address => bytes32) private myMap; Later in the code, in a function, I want to ensure my sender already has an entry in that given map. Can I do this? require(!...
1
vote
1answer
17 views

VS Code and Solidity files have a lot of warnings

Every time I use VS Code to develop Solidity, files I have a lot of this weird warnings saying: no-trailing-whitespace: Line contains trailing whitespace I googled a bit and I understand why they ...
1
vote
1answer
22 views

Is it possible to manipulate maximum callstack size in solidity?

I'm a student learning about solidity language. According to solidity's official docs, the maximum callstack size is 1024. But, I am wondering, can a developer change the maximum callstack size in ...
1
vote
1answer
29 views

How to construct deployable bytecode from runtime bytecode?

For example I want to redeploy/clone a contract to another address but don't have the original source code, so I only have the runtime bytecode stored on the blockchain. If I try to deploy the runtime ...
1
vote
1answer
28 views

Are memory variables initialized by solidity?

I've the following struct struct Vote { uint amount; uint count; } Is it initialized when allocated in memory? function boofar(uint val) public { Vote memory result; result.amount += val; } ...
0
votes
3answers
33 views

Is it possible to find out dynamic array size looking at a smart contract?

This question already answers that in order to get the size of an array programmaticaly, a getter should be defined. However, assuming that there isn't a getter, is there a way to find out size of a ...
0
votes
0answers
17 views

Ethereum Name Service implementation

I would like to create a Smart Contract that implements a name service. It will allow anyone to register a name. Once a name is registered and associated with an address, it belongs to that address. ...
0
votes
0answers
19 views

Solidity Error: Cannot destructure property `interface` of 'undefined' or 'null'

I've got his error in Solidity when compiling my test file: TypeError: Cannot destructure property interface of 'undefined' or 'null'. I know it is related to my compile.js file, but what is ...
1
vote
2answers
32 views

Web3 - Access return value of events

I want to get the value that my smart contract returns in javascript. Here is the contract. (version 0.4.25 - web3 version 1.2) pragma solidity ^0.4.25; contract SimpleStorage { uint public ...
0
votes
1answer
9 views

How does the named return variables in solidity work

I have below solidity contract from Truffle quick start guide. pragma solidity >=0.4.0 <0.6.0; contract TaskMaster { mapping (address=>uint) public balances; ...
0
votes
1answer
23 views

Can't log struct member in truffle test

Contract : mapping (bytes32 => MyStruct) public myMapping; struct MyStruct { uint256 myMember; uint256 someOtherMember; } Test (Truffle) This works: let ...