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
2
votes
1answer
31 views

ILendingPool.getReserveData function gives YulException: Stack too deep when compiling inline assembly:

I am trying to call the getReserveData function of a library ILendingPool interface: interface ILendingPool { function addressesProvider () external view returns ( address ); function deposit ( ...
0
votes
1answer
22 views

Display top referrer number

I am developing an ETH game with a referral structure. Each account that exists in the game has a "Referral Count" associated with it that updates as people sign up using their referral link....
0
votes
0answers
24 views

Ether Transaction failed to crowdsale contract

I have deployed a token on ropsten. it works and i can transfer tokens. Now i deployed crowdsale contract but when i send ether to crowdsale contract the transaction fails. I am using remix and ...
1
vote
1answer
29 views

how can i transfer 5% of the contract balance?

If this was a calculation or something i'd do myNumber * 5 and out of the contract (on client side) i'd do myNumber / 100 but since solidity doesn't accept decimals i can't do this. so my question is ...
2
votes
1answer
61 views

What's mean Solidity instruction: “this;” alone?

I have this fragment of code from Ethernaut (link): pragma solidity ^0.4.18; ... function() public { if(delegate.delegatecall(msg.data)) { this; } } What's means this; ?
0
votes
1answer
62 views

Uniswap V2 smart contract keeps getting reverted in JS

I'm trying to swap tokens using Uniswap v2 interface. The code of the contract is here. I'm able to deposit Eth to the contract and but I'm not able to invoke the swapEthForTokenWithUniswap() ...
1
vote
1answer
90 views

Is there any way to avoid calling these 2 separate transactions?

We need to call 2 methods of 2 different contracts in Ethereum, and this should be batched in one transaction, either both of them be confirmed or both of them be rejected. Exactly We want user to pay ...
0
votes
0answers
17 views

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

I have another problem with my code and I don´t know how to solve it. This is a part of my code: function countUsuarios() view public returns(uint){ //here is the error return usuariosAd.length; ...
0
votes
2answers
44 views

Where can I find full ERC 721 example programs?

I am building a program with an ERC 721 token. My code runs without using the standard components provided by Open Zeppelin IERC721. Now I want to adapt it to the ERC 721 standard. Unfortunately the ...
0
votes
1answer
49 views

where to host my react fornt end and express endpoint that interact with smart contract to be fully decentralised?

where to host my react fornt end and express endpoint that interact with smart contract to be fully decentralised. Are there any option to host it decentralised any cloud provider other than ...
2
votes
2answers
46 views

Explain delete_element For loop

I'm new to solidity. Someone please explain "for loop" in solidity and the for loop in the code below. function delete_element(uint index) public returns (bool){ if(index >= prices....
0
votes
0answers
19 views

How does Oraclize work? [duplicate]

We know that an Oraclize based contract can communicate with the internet sites. We know than Oraclize source is built by Solidity language. We know that there is no command in solidity that can ...
0
votes
1answer
26 views

Array lenght and data miss match while storing data of events

Can someone help me in finding what is wrong here a why the length of task info is 0 even the taskInfo has some data. I'm using events to fill the taskinfo array. I'm stuck at this place for almost 2 ...
0
votes
1answer
29 views

What is the correct procedure to configure a minter on a USD Coin smart contract?

I have a USDC smart contract deployed and initialized on a local geth node. I want to mint some tokens with the 'mint' function but I am guessing that configuring the minter first with the '...
0
votes
0answers
20 views

Warning Message: Gas Requirement: Compiling Multiple contracts Remix IDE

I am getting following warning message while compiling the test contract on Remix IDE : Gas requirement of function Test.send(address) high: infinite. If the gas requirement of a function is higher ...
0
votes
0answers
34 views

How to Manage Bulk of transaction through web3.js?

I have following code to send a transaction: const account = web3.eth.accounts.privateKeyToAccount(process.env.PRIVATE_KEY_1) const transaction = contract.methods.submitHash(docHash); const options = ...
1
vote
0answers
28 views

how to display a struct inside mapping inside struct in solidity on react js frontend

I have a mapping of struct (mapping (address => struct)) inside another struct. I'm having issue in how to display the struct in the front end while using Reactjs.
0
votes
0answers
24 views

Type error, unit256 is not implicitly convertible to expected type struct

Using sol compiler 0.5.1 I am trying to fetch data from old smart contract's function called people, the smart contract is already deployed on the blockchain mapping(address => Person ) public ...
0
votes
0answers
17 views

Handling relations best practise

Hey guys I'm a bit new to solidity, In the offical example of ethereum they handle the relations with a map : Pizza[] public pizzas; // Mapping from owner to id of Pizza mapping(uint256 => address)...
0
votes
2answers
65 views

How do I give every user Ethereum an address and does it affect security

I have a project with Ethereum Blockchain the users send the data to the server and the server writes the data in the blockchain network My question is how do I represent the server in the smart ...
0
votes
2answers
43 views

Trying to connect front-end application with smart contract

I am creating a simple registration and login forms in React.js and connecting it with smart contract in order to use it to store the data from the front and to the blockchain is there any method or ...
0
votes
0answers
30 views

How to import a contract with lower Solidity version?

I want to import a deployed smart contract TetherToken and use its functions. Solidity version of deployed contract TetherToken is: pragma solidity ^0.4.17; ... I want to use its functions in my own ...
0
votes
0answers
26 views

ERC-20 token with identitfication

I would like to create a generic ERC-20 token with identification. The token would only be transferred to previously identified addresses. The way identification is implemented should be as decoupled ...
1
vote
1answer
41 views

blockchain oracles to communicate with external api via smart contracts?

Is there is any other oracles other than provable or oraclize to communicate with external api via smart contract.
1
vote
2answers
29 views

Inheriting from contracts of a different Solidity version

The OpenZeppelin version I'm using is Solidity 0.5.0 but I'm using 0.5.15 in my core contracts. Everything is compiling but I'm having some issues verifying the contract on Etherscan and submitting ...
0
votes
0answers
12 views

Unable to debug Mainnet transaction in Remix

I am trying to debug mainnet tx with Remix debugger and I get following error in the console after I provide the tx hash in the debugger box. Is it even possible to achieve what I'm trying to do here ...
0
votes
0answers
27 views

Truffle + Infura Mainnet deploy. Transactions never get mined, timing out after 750 seconds

The contract deploys on Rinkeby without a hitch, but when it comes to mainnet it is erroring out strangely. Infura's HTTP endpoint was giving me Invalid JSON RPC RESPONSE "", so I decided to ...
0
votes
0answers
47 views

trying to write a contract for Hotel menu in solidity, and try to map order and table number

I am new to programming, can any one help me to understand how to map the order number and the table number in a hotel contact, i tryed up to map both order and table but not able to get the proper ...
0
votes
0answers
46 views

require Statement returns Transaction Revert Error instead of provided custom error message

For example, i have this piece of code here require(keys[_address].purpose != _purpose, "Key Already Exists"); in a Smart Contract. Upon executing a function and failing a requirement, ...
0
votes
1answer
15 views

Get length of 2D Array

I have a 2D Array uint[][100] myArray. I want to access the length of the first dimension (the dynamic array). Therefore I use myArray.length, but then I get the value 100 the length of the second ...
0
votes
0answers
27 views

'VM Exception while processing transaction: revert\n' Error Processing transaction

I have read in various posts that this error occurs when there is a problem with executing function. So I'm asking about this error in regards to the code I have written. Please see below: contract ...
1
vote
1answer
23 views

Will it be possible to get a contract's balance by block number in Solidity?

Will it be possible to get address state at a given block within smart contract execution logic? Something like: block(10297202).(address('Ox...').balance) I assume it's not possible currently due to: ...
0
votes
1answer
37 views

Absolute value in solidity?

I have this inside my function and i want to get its absolute value . return (int(keccak256(abi.encodePacked(block.timestamp, block.difficulty)))%100000);
2
votes
1answer
115 views

Solidity ^0.6.0 Truffle Compile Error: Cannot read property … of undefined

I initalised a new truffle project by using truffle init. I changed the solc version to ^0.6.0 in the truffle-config.js file. I ran truffle compile and got this error: TypeError: Error parsing C:/init-...
0
votes
1answer
36 views

Mapping didn't storing unique values

I wrote this piece of code with the goal to store unique documents hash. Used mapping to accomplished that. pragma solidity ^0.5.16; contract DocumentHash{ string public documentHash; ...
1
vote
0answers
63 views

Solidity function calls from javascript work locally but fail on ropsten,kovan etc with Error: Returned values aren't valid, did it run Out of Gas?

I have a smart contract whose function calls works fine when called locally using javascript and ganache. But when I deploy to ropsten and others, the calls to its functions fail with Error: Returned ...
0
votes
2answers
36 views

what address(0) means? more specific where those token go?

I am trying to get balanceof an address but i dont know what i should input for address token. I looked at some other answers. One answer said the tokens send to address(0) is burn. What does that ...
2
votes
0answers
43 views

The gas-cost of a static-call of a pure function

A pure function doesn't cost anything when called from an off-chain script (or from some other constant function). But it does cost when called from a transaction (i.e., from a non-constant function). ...
3
votes
1answer
32 views

Can we trust Solidity's `now`?

I am going to use a timestamp for certain quite important functionality. I am going to use now. Now my question is: can I trust this? Can I trust nodes not to tamper with this? How do other nodes ...
0
votes
0answers
29 views

Remix contract balance transfers Failing (Metamask / JS VM)

There is an issue with my smart contract not transferring any funds to any other address on the connected ganache instance. Regardless if I choose "JavaScript VM" or connect to my Remix, the ...
2
votes
1answer
35 views

Get return value of a low level call

I'd like to get the return value of a low level call. (bool success, ) = address(0x1234...7890).call{value:0}(callData); This post discusses a solution that sounds like it should work, but it doesn'...
0
votes
1answer
27 views

Should Try-Catch error handling be avoided for security? [closed]

What implications can it have to the security of a function if the content of it is wrapped into try-catch statements?
0
votes
1answer
22 views

How to use truffle-assertions to verify parameters of an emit?

I have not been able to find any resources with usage instruction besides github and blog post by the author On github an example is show as such: truffleAssert.eventEmitted(result, 'TestEvent', (...
0
votes
1answer
26 views

Gas cost when calling Ethereum view functions on remote or local node

There are dozen of sources on the internet that state the view functions, which are called externally (i.e. from oustide of contract), that do not call other contracts' functions and do not change the ...
1
vote
2answers
36 views

Calling a Solidity function automatically in realtime

I have an oracle with a 'getPrice' function that returns the latest ETH/USD price. Let's say, I am implementing a stablecoin contract which requires over-collateralization with ETH. How will I ...
0
votes
0answers
19 views

Ether transaction does not reflect in ganache

Hi am developing a etherium DAPP. In that for every user registration some ether will get transfer from user to contract... Everything work perfect but the transacted ether is not reflecting in ...
0
votes
1answer
28 views

Problem loading token balances [solved]

I have a contract with the decimals hardcoded to 8 // Hardcoded to be a constant uint8 public constant decimals = 8; I think this is the reason Im having problems with wallets and explorer ...
0
votes
0answers
18 views

contract.deployed() not working when trying to submit an html form

i am using web3.js to communicate with my smart contract. how ever, when i try to submit the html form, and then use contract.deployed(), it isnt working below is the code.Html <div id ="input" ...
0
votes
1answer
31 views

Why solidity doesn't use “ Null ” and “undefined”?

Like Python or any other language why does Solidity avoid having the Null and undefined properties?
1
vote
0answers
13 views

Natspec Commenting Style for Structs

Is there specific way to explain the variables of a struct using the Natspec format? I do something like: struct XYZ{ uint x; //Explain what it does uint y; } Is it this the right way for ...