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

Recover funds from a smart contract wrote a mistake by developers

Our developer has deployed a errored smart contract for a autopool plan, but the plan was expired 3 years ago. Users transfered funds to this contract. I am wondering if I can get back these funds ...
Nagalingeswaran C's user avatar
0 votes
0 answers
28 views

Generating input data with Ethers for low level call to Uniswap Router

I'm trying to generate the input data necessary to execute a low level contract call to the Uniswap SwapRouter.exactInput method. I've done the same for the exactInputSingle successfully but can't get ...
TommyF's user avatar
  • 152
0 votes
0 answers
7 views

Construction of OpenZeppelin voting contract with ٍERC777 token

I managed to easily create governor and implement voting with erc20 token, but now I have erc777 token that I need to do this with, please guide me how I can I have to do this because when I introduce ...
Mehran Ra's user avatar
  • 481
0 votes
0 answers
14 views

Error when calling when calling `increaseLiquidity ` in nonFungiblePositionManager

I have failing tests when calling increaseLiquidity in nonFungiblePositionManager. decreaseLiquidity works as expected but increaseLiquidity is failing. This is the code: underlyingPositionManager....
OddKral's user avatar
0 votes
0 answers
10 views

How to use chainlink automation to call a function with onlyAdmin modifier?

I have a smart contract that has a function with an onlyAdmin modifier. I want to use chainlink automation to trigger this function based on certain conditions. However, I don’t know which address to ...
CheeseMcBurger's user avatar
0 votes
0 answers
18 views

Right wat to execute sendSignedTransaction with web3 v4.2.0

I am using [email protected]. I am trying to implement the sendSignedTransaction method, but it keeps on giving me below error. reason: 'err: insufficient funds for gas * price + value: I am sure I do have ...
anish samant's user avatar
1 vote
1 answer
34 views

Confusion with layout of string variables in storage

From solidity docs, in section Layout of State Variables in Storage > bytes and strings There is this explanation (v: v0.8.21): In particular: if the data is at most 31 bytes long, the elements ...
SKA's user avatar
  • 47
1 vote
2 answers
21 views

How much gas does defining an error consume

I have written a contract with minimal declaration of errors; Hopping to achieve more readable and concise code. However, if I define more errors, would it cost more gas, if so how much per error? ...
Ibra's user avatar
  • 137
0 votes
0 answers
19 views

Coinbase pool smart contract code

What is this contract and where can I find its code? https://etherscan.io/address/0xa9d1e08c7793af67e9d92fe308d5697fb81d3e43#code It looks like it was deployed by Coinbase. However, I don't see any ...
Mila A's user avatar
  • 264
2 votes
0 answers
17 views

How ERC1155 can behave like ERC20?

As we say that ERC1155 can define both fungible and NFTs, how exactly is that implemented? The ERC has all the functions like an ERC721, and also it attaches a URI with all of the tokens, but ERC20 ...
Serenity's user avatar
1 vote
1 answer
11 views

Do custom errors and events take up storage in Solidity?

For example, is slot 0 in this contract the uint256 x or does the custom error take up this slot? Same thing for events. contract Foo { error CustomError(); uint256 x; }
Rohan Nero's user avatar
  • 1,408
0 votes
0 answers
5 views

Pool Prices Not Updating in Forked Hardhat Mainnet

Why do pool prices remain static in my forked Hardhat mainnet environment during swaps? What steps can I take to troubleshoot and ensure that pool prices accurately reflect the expected changes in ...
Asim Hayat's user avatar
0 votes
1 answer
28 views

local initialization

I was working in this solidity code. here is the code sample from my project interface customeInterface { function token0() external view returns (address); function token1() external view ...
Biruk Damte's user avatar
1 vote
1 answer
66 views

What is msg.sender the Solidity smart contract sees if the caller has an ENS domain bought?

My goal is to be able to get an account at a particular arbitrary Ethereum address (unused as of now). I was wondering whether I can do that by buying an ENS resolve domain. If I buy an ENS domain ...
Mila A's user avatar
  • 264
0 votes
1 answer
35 views

can eth_call simulate approve and transfer?

I have a solidity contract that contains a logic to approve and transfer balance, swap and flashloan. But when i use eth_call to call my function that perform swap, it reverts. I tried by ...
Biruk Damte's user avatar
3 votes
2 answers
85 views

assertEq() fails on seemingly same strings

I have a simple contract that just sets a string private state variable in contract's slot 1. Below, I write a test that is supposed to set that private string variable to a new value and then I go in ...
SKA's user avatar
  • 47
0 votes
1 answer
26 views

Send Function is not working in test file using ethers.js

I write a wallet smart contract in which one address can send ethers to other addresses. I'm using the HardHat framework and this package. when i use await addr1.sendTransaction( {to: addr2, value: ...
Huzaifa Ahmed's user avatar
0 votes
0 answers
47 views

Transaction reverts when using custom router contract while swapping tokens to ETH on Uniswap

I am in the process of setting up my own smart contract on the Ethereum network for executing transactions through Uniswap v2. I've come across an issue where all transactions get reverted when the ...
MikeMik's user avatar
0 votes
0 answers
12 views

Bytecode from online version of remix at https://remix.ethereum.org/ on Firefox is a string of chars

I am running solidity 0.8 contract on remix online in Firefox browser/MacOS. After compiling the contract, the byte code returned is just a huge chunk of random chars string which is completely ...
user938363's user avatar
0 votes
0 answers
15 views

Exploring blockchain use cases for real world problems

Wassup Guys, I hope you are well! I'm new into blockchain development. I have a few ideas but a lot of doubts, one of the doubts is if ethereum (solidity) or solana (rust) written contracts are a good ...
Filipi Melo's user avatar
1 vote
1 answer
48 views

Metatransaction EIP-712 compliant reverted on Tether USDT Polygon contract

I have a problem with the execution of a metatransaction EIP-712 compliant, I show you the backend code with ethers.js and the link of the contract on mainnet :slight_smile: Contract : https://...
Giovanni Maria Mazza's user avatar
1 vote
1 answer
60 views

Calculating the price of a token in a Uniswap V3 pool gives different results depending on the pool

Based on the formula on this page i wrote this Solidity contract with a function to get the price of a Token in term of USDC(6 digits) inside a Uniswap V3 pool: // SPDX-License-Identifier: MIT pragma ...
MattC's user avatar
  • 113
0 votes
1 answer
24 views

Why is my Solidity for loop if statement code is not giving the right result?

The if statement in my for loop code is not filtering as intended, I want to believe I am missing something here but I can not seem to figure it out. Here is the code, I hid the unnecessary code: ...
Osemu Aimiosior's user avatar
0 votes
1 answer
55 views

How to read a variables in deployed contract via cast command?

contract testContract { address private test1; string publictest2; } How do I use foundry framework test cases to read the storage slots? https://book.getfoundry.sh/cheatcodes/load // This ...
anonauditor's user avatar
0 votes
1 answer
29 views

Gas estimation failed while trying to deploy a smart contract on remix

I tried to deploy this solidity code on Remix // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; // Import ChainlinkClient from the Chainlink library import "@chainlink/contracts/src/v0.8/...
Paschal's user avatar
0 votes
0 answers
17 views

Which consensus algorithm PoW or POS is used for mining a block in latest ganache ethereum client?

Which consensus algorithm have been used in the latest version of ganache for ethereum blockchain simulation.
Narayan Khatri's user avatar
0 votes
0 answers
29 views

Guys i. Am getting this error while trying to install slither Can anybody tell me the reason of this error and how can i fix this

error: command 'C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.37.32822\bin\HostX86\x64\cl.exe' failed with exit code 2 [end of output] note: This error originates ...
Saptarshi Mitra's user avatar
0 votes
1 answer
29 views

transaction fails when i use address[] memory

i was practicing on BSC testnet and my solidity code is // SPDX-License-Identifier: MIT pragma solidity 0.8.0; interface IUniswapV2Pair { function factory() external view returns (address); ...
Biruk Damte's user avatar
0 votes
2 answers
45 views

Call a function from another contract, entirely determined by initial contract's function arguments

I would like to have a contract MainContract that can call any other contract functions depending on arguments given a MainContract function. It would look like this: pragma solidity 0.8.16; contract ...
Pacdac's user avatar
  • 70
0 votes
0 answers
23 views

how to get a function's signature that have a structre as parametter

function createClone( uint256 dbId, launchpadLib.IDOInfo memory _idoInfo, launchpadLib.IDOInfoTwo memory _IDOInfoTwo ) external{} I have this funtion how can i make signature of this function with ...
VIKASH VASHISHAT's user avatar
0 votes
1 answer
42 views

Calling approve function of an erc-20 contract not working

I'm dealing with a problem, I hope someone can help me. token: 0x9216e1BbC58Ba2bD90c5b49524659209ccaB32Da contract: 0x8ca112e2fdFF220217609D391eec0B95d5E505a2 alumne: ...
biel Serrat's user avatar
0 votes
0 answers
23 views

Securing Access to User Balances in Ethereum Smart Contract

I'm working on a Mobile app where users sign up, and they are assigned public and private keys. However, these keys are never actually shared with the users but are stored in the database. I want to ...
Giovanni Cassanelli's user avatar
0 votes
0 answers
13 views

Please help me with my project [duplicate]

I have been given the final year project of fake brand detection using blockchain. I am a complete beginner in anything related to blockchain or ethereum. Can anyone help me any way where to start. I ...
Rivaa Vadher UCOE- 3892 's user avatar
0 votes
0 answers
12 views

Is there any way to fake the signature selector in Solidity for abi.encodeWithSelector?

Is there any way to fake the selector pointer for an arbitrary contract address call with abi.encodeWithSelector? For example, I want to call a particular contract's deposit(...) method, but the ...
Mila A's user avatar
  • 264
0 votes
2 answers
37 views

Questioning about the _safeTransfer in the swap function of the UniswapV2 pair contract

I have a question about the _safeTransfer function in the swap function down below. if (amount0Out > 0) _safeTransfer(_token0, to, amount0Out); // optimistically transfer tokens if (amount1Out &...
DHC's user avatar
  • 313
0 votes
0 answers
16 views

before each" hook for "sets the aggregator addresses correctly": TypeError: (0 , ethers_1.getAddress) is not a function

I am getting TypeError: (0 , ethers_1.getAddress) is not a function when i run yarn hardhat test on the first part of unit testing here is FundMe.tets.js const { deployments, ethers, getNamedAccounts ...
kartik's user avatar
  • 1
1 vote
0 answers
24 views

How to fix `Invalid callback object specfied` error when deploying a smart contract?

My smart contract: // SPDX-License-Identifier: MIT pragma solidity 0.8.19; contract Inbox { string public message; constructor (string memory initiialMessage) { message = ...
Jyobala's user avatar
  • 11
0 votes
1 answer
50 views

Error when deploying my contract and interact with him

Here is the error message : Deploying, please wait... BaseContract { target: '0x80f4D1df2Da11Ca9437A01519d3972d07E54A43E', interface: Interface { fragments: [ [ConstructorFragment], ...
Marsattak's user avatar
0 votes
1 answer
29 views

How to work with nested array

Please how do i map addresses to each array I have parameters of an array inside an array, and i want to map each array to each address, please how do I go about this? thanks contract SolahParchiThap {...
Osemudiamhen Aimiosior's user avatar
0 votes
1 answer
23 views

How do I test for two conditions at the same time in Foundry while running a fuzz test?

Let us say I am trying to fuzz simple addition b/w two 'uint' variables in Solidity using foundry, I expect one of two conditions to happen: The test passes without overflow error. The test fails ...
Priyank Gupta's user avatar
0 votes
1 answer
74 views

Error: missing revert data when deploying Solidity contract with ethers.js and Ganache

I'm having an issue deploying a Solidity smart contract using ethers.js and Ganache. I have a simple contract called SimpleStorage.sol: // SPDX-License-Identifier: MIT pragma solidity 0.8.21; ...
Shuvo's user avatar
  • 1
0 votes
2 answers
36 views

TypeError: Cannot read properties of undefined (reading 'address') when i try deploying contracts in Hardhat

so i'v 2 smart contracts token.sol contract Token is IERC20, ReentrancyGuard { string private Name; string private Sympol; uint private Decimal; uint private TotalSupply; address ...
Yassine's user avatar
  • 11
0 votes
0 answers
9 views

I am getting this error and I cant solve it error:-( _this.state.tokenFarm.methods.stakeTokens is not a function)and whole code is given below ASAP

// ALL CODE WITH INITIALIZATION OF CONTRACTS ARE GIVEN HERE PLAESE HELP ME ASAP import Web3 from 'web3'; import React, { Component } from 'react' import DaiToken from '../abis/DaiToken.json' import ...
Devang Thaker's user avatar
0 votes
2 answers
18 views

Trying to deploy simple smart contract in a local nodejs, mocha environment but receiving error from: 'npm run test'

I am trying to deploy a simple smart contract for testing. Attached are the output of: 'npm run test' as well as my test.js file and my package.json file I hope its something obvious sorry if this is ...
bakayaro's user avatar
0 votes
0 answers
24 views

hardhat simple storage. Getting ProviderError: Must be authenticated!

**I am going through freecodecamp's course on fullstack web3 development. Can anyone help me with this error. Am not able to resolve this issue. ** Deploy.js code : // imports const { ethers, run, ...
shyam sharma's user avatar
0 votes
0 answers
14 views

I am getting this error and my I cant solve it the error is :-( _this.state.tokenFarm.methods.stakeTokens is not a function ) please help me ASAP

stakeTokens = (amount) => { this.setState({ loading: true }) this.state.daiToken.methods.approve(this.state.tokenFarm.options.address, amount).send({ from: this.state.account }) .on('...
Devang Thaker's user avatar
0 votes
0 answers
18 views

Is this the correct way to add string extra string data to a solidity contract

This is my first solidity contract, it was working until I wanted to add extra data to the transaction. I'm not sure if I'm calling it wrong with webjs3 or the contract itself is flawed in some way. ...
Brian's user avatar
  • 101
0 votes
0 answers
18 views

eth_estimateGas calling random function

I'm testing my Ethereum smart contract with Hardhat and Metamask. In Metamask if I try to send zero tokens it reverts, as expected (the transfer function reverts if token amount is zero). If I look at ...
Rick's user avatar
  • 91
0 votes
0 answers
14 views

why block.number gives underflow error on line no 101 while i am excluding the previous from the lastest so it shouldn't behave like this

below is a function snippet the line responsible for error is below uint256 currentBlocks = block.number; p.endedAt = currentBlocks; uint256 blocks = (p.endedAt -= p.startedAt); console....
Anwar's user avatar
  • 51
3 votes
1 answer
80 views

How to convert a uint256 array to a bytes32 array in Solidity?

Suppose I have a uint256[] array in Solidity. What's the easiest way to convert it to a bytes32 array?
Paul Razvan Berg's user avatar