Skip to main content
Share Your Experience: Take the 2024 Developer Survey

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
1 answer
316 views

How do I get Wagmi useWaitForTransaction to wait for Metamask (running on Hardhat)?

I am using Wagmi's useWaitForTransaction together with Metamask, running on local Hardhat node. When I sign a transaction it almost immediately returns successful on the front end, but on Metamask it ...
0 votes
1 answer
566 views

truffle migrate does not return anything

I am following the tutorial from Truffle to create a "pet shop" contract. I can follow everything until he tells me to truffle migrate. Here is the contract: pragma solidity ^0.5.0; contract ...
1 vote
1 answer
317 views

ECDSA (ecrecover) - How an attacker can construct a hash and signature that look valid

I found information, that it is possible to construct a hash and signature that look valid if the hash is not computed within the contract itself (we are talking about ECDSA/ecrecover here). So, the ...
3 votes
5 answers
3k views

Convert String to address in solidity

Im calling a smart contract function that requires addresses, I only have these addresses as strings. How do I convert string to address in solidity?
0 votes
1 answer
10 views

Is it possible to recover non-reserve tokens accidentally sent to a Uniswap V2 Pair contract?

I'm trying to understand the operation and potential pitfalls of interacting with UniswapV2Pair contracts. I'm aware that if excess token0 or token1 are sent to a Pair contract, it may be possible to ...
0 votes
1 answer
317 views

How to give allowance to a contract and send erc20 between accounts

I wrote the following contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/IERC20.sol"; contract enviaToken { address public ...
0 votes
1 answer
21 views

Trying to deposit ETH to my contract with Chainlink Functions. Getting gas estimation errors

We were not able to estimate gas. There might be an error in the contract and this transaction may fail Keep getting this error when I am trying to deposit to my contract that is using Chainlink ...
1 vote
1 answer
2k views

Using memory vs storage for arrays in structs in Solidity - Q&A

Wanted to share what I learned to help someone in the future running into a similar issue: I have this struct, which includes two arrays. In createNewEvent, I initialize two arrays, confirmedRSVPs and ...
0 votes
0 answers
5 views

Has anyone managed to succesfully use uniswap routers(with solidity) on base chain?

I am currently trying to implement a contract to swap from Brett Token to WETH but have been really struggling. I tried using ISwapRouter but base chain does not have a ISwapRouter only a SwapRouter02 ...
2 votes
1 answer
423 views

How can I use solc solidity compiler on truffle webpack?

When I try to import solc, it raises an error which says: ERROR in ./~/require-from-string/index.js Module not found: Error: Can't resolve 'module' in 'C:\users\bisrat\Desktop\webpacksample\...
0 votes
1 answer
427 views

EthersJS JSON to sha256: Error string too long

what I'm trying to accomplish is creating a hash of a JSON object. This will then be used as a bytes32 parameter when minting a token. I thought the best way to go about this is to first stringify a ...
0 votes
2 answers
937 views

How do I count the elements of an array in solidity?

In my project, I want to count the elements of an array as follows: struct Server{ uint sernum; uint num; uint data; } Server [] public datta; function ...
4 votes
3 answers
1k views

Importing a contract from another contract in NodeJS app

I'm using a function in my NodeJS app to deploy contracts. The user inputs the contract he wishes to deploy and the app deploys it. The structure of the app is . ├── app │   ├── models │   │   └── ...
0 votes
0 answers
7 views

`ethers.getContractAt()` returns an overload error

I am trying to use the following function as shown below: const { deployer } = await getNamedAccounts() const iWeth = await ethers.getContractAt( "IWeth", ...
0 votes
2 answers
95 views

Redeploy safe with same address on OP

I deployed the Safe on Ethereum using this factory: 0xa6B71E26C5e0845f74c812102Ca7114b6a896AB2. Now, I'd like to deploy the same Safe address on Optimism. Could you please provide guidance on the ...
0 votes
0 answers
8 views

How to implement a reentrancy attack in the English Auction in Solidity?

I implemented a solidity code for an English Auction where different accounts can bid during the specific period of time to win the nft. // SPDX-License-Identifier: MIT pragma solidity ^0.8.25; ...
2 votes
3 answers
372 views

How can i watch multiple smart contracts on server

I would like to create a sever that continuously watch the events of multiple smart contract at once. Sending me an alert via email when an event is detected. I understand that there is a web3.js ...
2 votes
2 answers
1k views

Solidity Event logs

I have a JS code which is connected to ganache. I am trying to call a solidity function which in tern emit the event. In JS i am watching the event. Now when i call the function first time it sets ...
2 votes
2 answers
1k views

On mainnet Gas required exceeds allowance or always failing transaction

When I try to deploy contract, the error comes up: gas required exceeds allowance or always failing transaction on mainnet. contract Crowdsale { using SafeMath for uint256; // The token ...
0 votes
1 answer
428 views

Event filter not returning correct events web3js

I am trying to filter certain events emitted in the past based on the value of a certain field. The code I have used corresponds to the method specified on the web3js documentation page. However, the ...
0 votes
1 answer
2k views

Get error `Error: cannot estimate gas; transaction may fail or may require manual gas limit` when send method to contract

I deployed a smart contract to Ganache as below code: // SPDX-License-Identifier: MIT // Tells the Solidity compiler to compile only from v0.8.13 to v0.9.0 pragma solidity ^0.8.13; import "@...
0 votes
1 answer
377 views

How to generate the correct hash for signatures?

I want to create a hash in JavaScript for a signature. The hash needs to have the same output as this in solidity: keccak256(abi.encodePacked(address, bytes32)) My solution in JavaScript so far ...
0 votes
2 answers
571 views

Non transparent (forward) Proxy in Solidity

For testing/mocking purposes, I need to call a contract (A) from another contract (B) that just forwards the calls to (A). The calls need to be forwarded, not delegated. And I don't want to rewrite ...
0 votes
0 answers
16 views

Problem with connecting smart contract function to frontend/metamask

As an exercise to learn Solidity and Nextjs, I started developing a presale smartcontract. It has gotten rather large but I am proud of how far I have come in two months. The contract mints a token, ...
0 votes
1 answer
1k views

Error: invalid contract address or ENS name (argument="addressOrName", value=undefined, code=INVALID_ARGUMENT, version=contracts/5.7.0)

I am trying to test the contract but getting error: Basic NFT Unit Tests Constructor 1) "before each" hook for "Initializes the NFT Correctly." 0 passing (2s) 1 ...
0 votes
1 answer
1k views

EnumerableSet vs Access Control in Openzeppelin

Openzeppelin offers RBAC whereby an address may be granted a specific set of responsibilities. I would like to know which might be considered a better practice - using Access Control Or using an ...
0 votes
1 answer
850 views

How can I get transactions from a specified wallet, ethers.js, Alchemy websockets

I can't get the transactions from a specific wallet provided, it's weird because I can get transactions filtering with the to argument and other arguments but when using from it doesn't. I don't ...
5 votes
4 answers
6k views

How to get network name and chain Id to which metamask wallet is connected using Ether.js library?

I am looking for a solution that I would use in my Dapp to get the network name and the chain Id of the network to which the wallet is connected using Ether.js library For example, if my wallet is ...
1 vote
1 answer
16 views

Slither: .. uses dangerous strict equality

Context After having written the following rough draft for an eject button in some contract: function triggerReturnAll() public override onlyAfterDelayAndUnderTarget { require(msg.sender == ...
0 votes
0 answers
18 views

bought a token that is unsellable, but I can see that on Etherscan that few accounts are selling the same. Is there a way I can sell this token [duplicate]

I bought this token 'Monad' on uniswap. It seems to be all fine but than later realized that this token is unsellable. I can see that the team are able to sell the token, and so did someone else who I ...
0 votes
1 answer
15 views

TypeError: Cannot read properties of undefined (reading 'getSigner')

get this mistake by running the following: const signer = hardhat.provider.getSigner(); what could be the problem?
0 votes
1 answer
18 views

Issue with msg.sender. Calling contract B from contract A

There is currently a published contract (contract A), I must use another(contract B) to call withdraw() from contract A. But the function withdraw() already uses msg.sender as a security check. In ...
1 vote
0 answers
8 views

Catch internal revert

Is it possible to catch a revert in like an internal decoding? For example: function mint( bytes memory data_, address owner_ ) returns(uint) { ... (AmountsIn memory amts, ...
1 vote
1 answer
451 views

How does Truffle Deployer translate arguments from JavaScript to Solidity?

I have a Truffle migration that looks something like this; var MyContract = artifacts.require("./MyContract.sol"); module.exports = function(deployer) { deployer.deploy(MyContract,[ { "...
0 votes
0 answers
22 views

Need help with smart contract audit (private key guessing game)

The game is that you need to brute force the private key. The one who first finds the private key from 0x1a642f0E3c3aF545E7AcBD38b07251B3990914F1 receives all the ether. As for the math of ecrecover, ...
0 votes
0 answers
18 views

2d arrays in etherscan

How to Pass 2D Arrays in Etherscan Contract Interaction? I am encountering difficulties when trying to pass 2D arrays to a smart contract through Etherscan's interface. While the function executes as ...
1 vote
4 answers
3k views

Provider error hardhat

When i want to deploy my contract with this command: npx hardhat run --network goerli scripts/deploy.js I get this error: ProviderError: HttpProviderError at HttpProvider.request (/Users/alirezamac/...
0 votes
1 answer
2k views

How can i create an array that contains multiple tuples in solidity?

I am trying to create a smart contract that will store an array containing GPS coordinates such as: X=[(31.332,54.213),(32.013,54.312), (33.124,56.2134),(34.123, 57.789), (34.789,59.654),(31.332,54....
1 vote
1 answer
189 views

How to alter the gas stipend with high-level delegate call?

When using the DELEGATECALL opcode via assembly, we can pass a specific amount of gas: let result := delegatecall(gas(), implementation, 0, calldatasize(), 0, 0) But the high-level DELEGATECALL does ...
2 votes
1 answer
342 views

why does it not work if I don't handle the return value of call/callcode/delegatecall?

This is my Contract code : pragma solidity ^0.4.15; contract D { uint public n; address public sender; event CallStatus(bool); function callSetN(address _e, uint _n) { if (!_e.call.gas(...
0 votes
2 answers
25 views

Contract verify [duplicate]

I get such error of compilation in Optimism Sepolia testnet network.The contract succesfully compiles using hardhat with needed configuration.What should I do to get verified the contract ?
0 votes
2 answers
26 views

Can I Recover a Smart Contract Written On Remix

I wrote a smart contract earlier today using Remix. I was away for a few hours, and when I came back my computer was out of battery. I've configured my browser to never save cookies, so even when I go ...
0 votes
1 answer
3k views

Ropsten contract execution [Reverted]

Can someone help me and tell me where in my code is the problem. How to fix this ? https://ropsten.etherscan.io/tx/0xbd2079c12f90bb9396d79e7aeb5b5914472dd25c9e62ce36ffa85f6e88d7b594 Is there any ...
4 votes
3 answers
1k views

ERC-20 token approval fails if amount is close to maximum balance

So I am using Wagmi, which uses Ethers.js under the hood. I have to approve the router address first in order to buy the other token. It works when I use the exact or slightly greater amount than what ...
1 vote
1 answer
609 views

Untitleded.sol:5:77: ParserError: Expected type name function sendmessage(string message) view public returns(string message, memory) { ^----^(i need)

I've seen the other StackExchange errors but it didn't help me. Untitleded.sol:5:77: ParserError: Expected type name function sendmessage(string message) view public returns(string message, memory) { ...
0 votes
0 answers
5 views

Getting a collection back from ExactInputSingleParams in Uniswap V3, not the swap amount value

I'm using ethers.js and typescript to call a contract's swap function: ExactInputSingleParams in Uniswap V3,and getting a collection returned with many different elements in it, rather than the output ...
0 votes
2 answers
330 views

Error: network does not support ENS (operation=“ENS”, network=“maticmum”, code=UNSUPPORTED_OPERATION, version=providers/5.5.3 Network doesnot support

Hello I wrote a smart contract for crowd funding Actually I have two contracts One is create a campaign for donate funds and second is created campigns for crowd-funding and store all the campaigns ...
0 votes
2 answers
317 views

Function selector collision in ERC165

Like we know that the receiver contract can provide the confirmation of the implemented interfaces by comparing the interface indentifier and function selector of implemented interfaces. What could go ...
2 votes
1 answer
391 views

Error: VM Exception while processing transaction: invalid opcode at transfer function

I try test function transfer in my contract. I following by tutorial. Full project locate on my git. It is my test.js code: var SPT = artifacts.require("StepanToken2"); contract("Testing ERC20 ...
0 votes
1 answer
317 views

Solidity Acces public varialbles ethers.js

I am trying to fetch data on public variables from the blockchain using ethers.js. but other declared functions will work properly. This is the way I am using it. My solidity: contract NLTNFT is ...

1
2 3 4 5
357