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

Deploying contract using web3js but failed

I am a beginner for solidity 👶 My question about deploy using with web3js. I have two smart contract and in main contract I have a createContract function which is create a new subtoken contract ...
0
votes
1answer
24 views

Web3.js is taking lot of time to return a promise

Web3 is taking time near about 5 minutes even after the transaction got 3 confirmations to return a promise from a smart contract which is deployed on kovan testnet. Please give some suggestion how to ...
0
votes
0answers
15 views

Migrate Database

I want to migrate my no-SQL dB on-chain. There are two options as far as I know: Store the objects in the form of string using a simple smart contract. Create a structure to implement the dB schema. ...
0
votes
2answers
36 views

Can we pass string values to the contract which holds bytes 32 only in solidity?

My contract can hold only array of type bytes32 only. How can we store string values as well?
0
votes
1answer
23 views

What is the meaning of “memory is erased between (external) function calls”?

From the official documentation on the memory keyword: The second is “memory”, this is used to hold temporary values. It is erased between (external) function calls and is cheaper to use. Can ...
0
votes
0answers
28 views

Undefined Contract

I am finally able to come up with a compilable code. As I attempt to verify the contract, the Remix - Ethereum output is "undefined". Someone advice me on what to do. My ABI is as follows: [ { "...
0
votes
1answer
17 views

How can i `ecrecover` in solidity to verify the digest produced by `web3.utils.soliditySha3` in JS side?

Javascript side: id = 128 uri = "xxx://xxx" hash = web3.utils.soliditySha3(id,uri) sign = web3.eth.accounts.sign(hash1, privateKey) Solidity side: function(uint256 id, string memory uri,bytes v, ...
0
votes
1answer
48 views

__callback was called after the specified delay

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 ...
1
vote
2answers
48 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 ...
0
votes
1answer
90 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
1answer
40 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
55 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
38 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
80 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
54 views

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

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
17 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
18 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
44 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
36 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
1answer
24 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
24 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
28 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
76 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
29 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
32 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
14 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
17 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
28 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
33 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
105 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
2answers
33 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
53 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
30 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
17 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
59 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
43 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
19 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; ...
3
votes
1answer
109 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
23 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
40 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
21 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
1answer
43 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
26 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
43 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
25 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
16 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
44 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
25 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
38 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 ...