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

Gas limit is not set REMIX

I set the gas limit to 1 000 000 for every transaction. But each transaction takes less amount of gas than 1 000 000. Could you please explain why it happens or what I need to read to get this right. ...
user avatar
0 votes
1 answer
9 views

Minting 100+ ERC721 NFTs in Constructor

I'm looking to mint around 100 NFTs (or more if possible) in the constructor of my smart-contract. • During deployment I'm passing in an array of 100 ETH addresses to the constructor, which then uses ...
user avatar
  • 815
0 votes
1 answer
6 views

To check transferred ethers with variable value

So im new to solidity, I just want to check the ethers transferred to the contract are less equal to the value of variable I have in a contract. It is actually checking in wei and not ethers. require(...
user avatar
0 votes
0 answers
5 views

Fetch Transaction Data/Block Data on Solidity

is there a method to call web3.eth.getTransaction or web3.eth.getBlock on Solidity? Or is there an oracle that allows to do so?
user avatar
  • 11
0 votes
0 answers
6 views

Swap Exact Tokens For Tokens : false Transaction mined but execution failed

I'm using Remix with a Foundry Provider. I'm trying to create a smart contract to swap between 2 or several tokens. I have no issue when I compile and deploy the contract, but when I call the swap ...
user avatar
  • 1
0 votes
1 answer
13 views

Getting error in modifier while compiling. DeclarationError: Identifier not found or not unique

When I compile the erc721 contract, the following error pops up: This is my modidier: And here is the function that the modifier calls: All my code: //SPDX-License-Identifier: MIT pragma solidity ^...
user avatar
2 votes
1 answer
19 views

Why is constant variable value changing?

I wrote a simple contract in solidity.Constant variable's value can be changed in Yul (assembly). But how and why is it changing?. //SPDX-License-Identifier: MIT pragma solidity ^0.8.7; contract ...
user avatar
0 votes
0 answers
3 views

gas usages of Uniswap-v2-periphery for each pair with swapExactTokenForToken

Currently, I'm using uniswap v2 periphery in my contract and using swapExactTokenForToken, the question is why there are a lot of differences in gas used between swap functions in multiple pairs? BOO ...
user avatar
  • 66
0 votes
1 answer
10 views

Unable to deploy smartcontract using web3j and Rinkbey infura

I'm trying to deploy a smartcontract on Rinkbey. I've followed the official documentation and some tutorials. I implemented the following code in my android studio but contract.deploy returns nothing. ...
user avatar
0 votes
1 answer
7 views

Display Value in Remix

I am a newbie in Solidity. Below is the simple Solidity source code pragma solidity ^0.4.21; contract CAT { event XYZ (uint Z ) ; uint[] x; uint a ; function f(uint[] memoryArray) ...
user avatar
0 votes
0 answers
16 views

How do I remove decimals from a uint256

I am calculating a buyPrice that has a factor of 1.2 times the normal price. To do this I get the token price and multiply it by 1200000000000000000 (18). It looks something like: uint256 buyPrice = ...
user avatar
0 votes
1 answer
9 views

Parameter function in Solidity

I am a newbie in Solidity. Below is the snippet of code I came across :- pragma solidity ^0.4.0; contract C { //1 function f(uint len) { //...
user avatar
0 votes
0 answers
5 views

Deploying to mainnet with 'hardhat test' opposed to 'hardhat run' -- is there a downside?

Both hardhat run + hardhat test deploys to the chain. I have a few blindspots and don't know how the optimizer works. Is there a downside to deploying to mainnet with hardhat test?
user avatar
  • 166
0 votes
0 answers
9 views

Error: Returned error: VM Exception while processing transaction: revert only owner can call this function

Question Open the TestGaming.sol contract in the test folder. Write a test for the function withdrawFunds . Your test should check the balance of the owner who called the withdrawFunds function. Your ...
user avatar
  • 1
0 votes
0 answers
4 views

Is it possible for a callee to DOS a function call if the caller ignores the success value?

Consider the following function: uint256 mySpecialNumber = 0; function foo(address callee, uint256 newNumber) public { mySpecialNumber = newNumber; // make a low level call to the bar() function ...
user avatar
0 votes
1 answer
24 views

How to call an undeployed contract from a solidity code that only implements a constructor

I've two contracts, and I want to call a contract from another contract. I've two ways to do it, as described here but, my case is different, the callee contract only implements the constructor inside ...
user avatar
0 votes
0 answers
3 views

Is there any way to get autocomplete for Solidity function definitions in JavaScript?

By autocomplete I mean something akin to how functions that would be declared in JavaScript get prompts/autocomplete in IDEs. (Also, I'm using VS Code)
user avatar
0 votes
1 answer
9 views

from solidity: TypeError

from solidity: TypeError: Return argument type uint256 is not implicitly convertible to expected type (type of first return variable) int256. --> sample.sol:72:24: cocontract fixedsizeArray{ ...
user avatar
0 votes
0 answers
11 views

Contract bytecode, function logic and state variable storage

I would like to get a better understanding on the separation between contract bytecode, function logic data and state variables on the storage level. Although they seem to be separated ...
user avatar
  • 459
1 vote
1 answer
12 views

Am trying to get data across multiple struts

Am new to coding and solidity. trying to build a simple contract with the use case register one company, register two employees. Get all employees for registered company. Have the following code but ...
user avatar
0 votes
0 answers
7 views

Trouble with calling "executeTransaction" function on timelock contract

The transaction was already queued but can't execute now. To use empty string as a value of signature parameter, I used '' as a parameter when call queueTransaction, used "" when call ...
user avatar
0 votes
0 answers
8 views

Parameters that can be passed in curly braces for message call and delegate call

When I use "call" in solidity I am able to pass parameters in parenthesis and in curly braces. What is the full list of parameters I can pass in curly braces? What is the main difference ...
user avatar
0 votes
0 answers
10 views

How to implement a contract for AAVE V3 "Supply, borrow, withdraw, loan etc" functsions

I am trying to write a contract imported aave-v3 which includes the some aave v3 functions such as supply, borrow, repay etc. I will then make this contract accessible only to its owner. For example: /...
user avatar
0 votes
0 answers
18 views

Solidity event returns object instead of string

I'm trying to test and learn how I can register a solidity event in front-end and get the value. everything seems to be fine except I get [object object] instead of the string I'm looking for. Here's ...
user avatar
  • 101
0 votes
0 answers
17 views

External function use cases [duplicate]

What is the main purpose / family of use-cases for the existence of external functions in solidity? Why would I want to restrict function accessibility so that it's impossible to call it from the ...
user avatar
1 vote
2 answers
35 views

How to calculate the location index (slot) in storage of a mapping key

I read the documentation and tried some other approaches but it's not working for me. I'm not sure what I'm missing. Let's say I have a contract with a mapping and I would like to know the storage ...
user avatar
0 votes
0 answers
12 views

Retrieving nounce of transaction without any other information but a random hash

The function eth.getTransactionByHash returns an object TransactionForRPC. Can I assume the parameters in this object can be parsed and read the same way as a JSON? Context: I am trying to retrieve ...
user avatar
0 votes
1 answer
13 views

storing ASCII on the blockchain

what is the best way to store ASCII characters/strings on the ethereum blockchain? scenario: there are users that want to upload ONLY ASCII strings to the blockchain. these strings don't contain ...
user avatar
0 votes
1 answer
22 views

Call child contract functions from outside

I have ERC20 controller contract which deploys ERC20 contract. contract ERC20Controller { ERC20 ercContract; constructor { ercContract = new ERC20(); } } Now I'm testing this contract in ...
user avatar
0 votes
0 answers
22 views

Solidity Dynamic Multi Swap Execution Issue || "execution reverted: TransferHelper: TRANSFER_FROM_FAILED", "data"

I have been trying to create a dynamic multi-swap function that calculates the length of the address array, and loops through to make the appropriate swap for an arbitrage trade automatically. Every ...
user avatar
  • 1
1 vote
1 answer
28 views

Efficiently fill a Solidity array with a range of numbers

does anyone know how I can fill an array with numbers 1 - 10,000 efficiently? For example, in our constructor we have the following but it doesn't work due to gas costs; too many items to push to a ...
user avatar
  • 111
0 votes
1 answer
47 views

Error uploading file to IPFS: HTTPError: project id required

Currently making a rudimentary DApp for posting chats, similar to twitter except built on a smart contract. I am using hardhat and running my app on localhost. When creating a profile I want users to ...
user avatar
1 vote
0 answers
19 views

Evaluation of a scam contract that steals token when approving

Hi everyone. I recently bought this token contract address : 0x1c16fa5806F4049003f73C3Ad9c8eD24eAF87924. On approval, the token was sent to the token creator's address. I can't seem to figure out how ...
user avatar
1 vote
1 answer
13 views

Regarding storage and memory key word

Recently I was going through https://docs.soliditylang.org/en/v0.8.13/types.html#data-location-and-assignment-behaviour which explains the data locations and its behaviour.. there in the given code ...
user avatar
1 vote
0 answers
18 views

trasnsaction not confirmed forever at polygon mumbai

since a few weeks, I tried deploy contract on polygon mumbai by hardhat. but transcaction not confirmed for a while then timed out. so I set higher gas, gasprice, and time out limit. but nothing ...
user avatar
  • 13
1 vote
1 answer
24 views

How to calculate the continuous price of a bonding curve token

I am trying to write a solidity smart contract implementing a power bonding cure like y=mxn where y=token price, m=slope parameter, n=exponential parameter, and x=token supply. Assuming m would be 0....
user avatar
1 vote
1 answer
10 views

Warning when returning no bytes data with checkUpkeep in Chainlink Keeper

From: @chainlink/contracts/src/v0.8/interfaces/KeeperCompatibleInterface.sol"; When using: checkUpkeep(..) .. override returns (bool upkeepNeeded, bytes memory /* performData */) I'm not ...
user avatar
0 votes
0 answers
7 views

Foundry Provider Close Error while connecting to the provider, provider not connected

im trying to connect foundry but remix does not detect the provider. it shows that "Not possible to connect to Foundry Provider. Make sure the provider is running, a connection is open (via IPC ...
user avatar
1 vote
1 answer
13 views

how long takes to pass erc20 token to another chain in stargate

How long takes to pass erc20 token to another chain in stargate on mainnet. example: 1 usdt from bsc to fantom(how long takes to start transaction on destination chain?)
user avatar
  • 66
2 votes
1 answer
15 views

Is the `indexed` keyword for a Solidity event no longer necessary because of subgraphs?

Context: The indexed keyword is used for Event fields when we want them to be easily searchable using the JSON-RPC method eth_newFilter. This was the best way to offchain index the interactions with ...
user avatar
  • 447
2 votes
1 answer
36 views

Does setting the deadline for a swap using `block.timestamp` inside the contract actually do anything?

I saw this in a codebase I'm working on and was wondered if this even does anything, because it doesn't seem like it does. Wouldn't block.timestamp be set when it's included in a block? Or maybe there ...
user avatar
1 vote
2 answers
18 views

Question about whitelist with mapping(solidity)

Was trying to hard code a whitelist array of addresses using mapping got this error: my code: contract IntelliContract { string public constant name = "CustomEnergyToken"; // solidity ...
user avatar
1 vote
1 answer
37 views

Chainlink Keepers not Upkeeping after i enterLottery. Can you spot issue that would be causing this?

I've spent many weeks on this project trying to figure out why "Chainlink Keepers" is not working. I can successfully deploy and verify the contract on Rinkeby. Then i do the following... 1.)...
user avatar
1 vote
2 answers
35 views

What is the right way to track a uint256 to struct mapping?

the smart contract below is a market place where users can sell items. The struct Offer, holds all the info of a specific item. To track the offers, I used a mapping with a uint256 key and created a ...
user avatar
0 votes
0 answers
11 views

Block header hash calculation in Eth2

Context: I am very curious about what kind of block information we can get from a smartcontract in Ethe2.0. In this question, I will just ask just about "blockhash". I will go directly to ...
user avatar
2 votes
1 answer
31 views

Writing a simple journal that proves who did write what and when

In order to get a better understanding I'm trying to write a simple journal tool on the Ethereum blockchain. The goal is to have a journal that for every entry does prove three things: The EOA who ...
user avatar
  • 23
0 votes
0 answers
13 views

How to test a function that has calldata parameters using Foundry?

I am trying to test out a function similar to the one shown below: function add (Complex calldata x, Complex calldata y) pure returns (Complex memory result) { result = Complex(x.a.add(y.a), x.b....
user avatar
0 votes
0 answers
17 views

Error: Transaction reverted: function call to a non-contract account (while running tests)

I've been getting this error while testing my staking contract, the earlier tests where i am calling getter functions work correctly but I am getting an error probably while calling the stake() ...
user avatar
  • 11
0 votes
1 answer
14 views

What would block.coinbase refer to after ethereum transition to POS?

What would be solidity's block.coinbase usage (and what does it refer to) after Ethereum's transition to proof of stake? (formerly known as eth 2.0)
user avatar
2 votes
3 answers
18 views

what is the input for this get latest price function call

after deploying this contract on rinkeby it uses a bit of gas to get onto the network, when i use the call function the gas denomination leaves and there is another input that is not clear to me it is ...
user avatar

1
2 3 4 5
303