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
2 answers
30 views

How to pass blockNumber to viem call?

I'm trying to view the owner of a certain NFT at a specific blockNumber, when I make the viem call without the blockNumber parameter it works perfectly, however, once I try to pass a blockNumber with ...
Rohan Nero's user avatar
  • 1,443
0 votes
1 answer
31 views

I want to call a contract method using my safe wallet address

I made a safe wallet in my panel safe wallet which is 2/3 signers. I want to use it in my access control for an admin role and use it for calling a transfer method with it only. The problem is when I ...
Helia Marami's user avatar
0 votes
2 answers
22 views

Object has no member 'call' when reading smart contract in geth console

I'm following the Storage contract example from the Geth site (https://geth.ethereum.org/docs/interacting-with-geth/javascript-console-contracts) I am unable to call a 'retrieve' function on the ...
Chris's user avatar
  • 101
0 votes
1 answer
25 views

How to exchange one nft for another from a different contract?

I have 2 ERC1155 contracts, and am looking to transfer nft2 into nft1's wallet upon checking wallet holds nft1, but not sure what I'm doing wrong. This is my nft1 contract: import "./NFT2.sol&...
katslair's user avatar
0 votes
1 answer
24 views

Ethers is not decoding the indexed parameters

I want to get the value from the first indexed parameter of the TokensTransferred event from the transaction logs which can look like this. You can see that the TokensTransferred event has the first ...
Rishabh Raghwendra's user avatar
0 votes
1 answer
12 views

importing other contract in remix gone wrong despite write file name or path [closed]

import "./filename.sol" output Error: not found SimpleStorage.sol
Robi prem's user avatar
0 votes
0 answers
21 views

Malicious ERC20 blocking batch withdrawals of tokens (e.g. ERC777)

I was wondering whether the following attack vector is possible in practice. There's a batch transfer function that is intended to batch transfer the tokens owned by the contract. That function ...
Mila A's user avatar
  • 264
0 votes
1 answer
39 views

Error (9322): No matching declaration found after argument-dependent lookup

Here is the file which i try to run test through foundry. //Imports import "forge-std/Test.sol"; import {Portal} from "../src/Portal.sol"; import {IERC20} from "@openzeppelin/...
Internet and Computer Probe's user avatar
1 vote
1 answer
78 views

Byte32 Array is not emitted as array from events

I have created this demo contract. It has a function called convertText which converts a string text into bytes32 and stores it into bytes32[] public storedData. You can see when you call convertText()...
Rishabh Raghwendra's user avatar
0 votes
1 answer
36 views

reading and writing to a packed nested struct using inline assembly

I've been racking my brain with this for some time, and have been unable to increment and decrement specific fields inside nested structs as per the example below. // SPDX-License-Identifier: ...
jlbl's user avatar
  • 1
0 votes
0 answers
15 views

Question about foundry testing

I'm trying to create an on chain nft with Foundry. I'm basing my project on the Cyfrin course repo. Here https://github.com/Cyfrin/foundry-nft-f23. Except that I'm not doing the Moodnft. I decided to ...
uh_yeah's user avatar
1 vote
1 answer
19 views

Do dynamic arrays in memory require a pointer to where the length and elements are stored in the memory?

At 29:07 of the video here: Devcon it is mentioned and written in the slide that dynamic arrays have pointer slot, length slot and elements after the length slot However, when I debug the following on ...
Xirexor's user avatar
  • 127
1 vote
0 answers
20 views

How to update a bug-fix UUPS implementation through a DAO vote without revealing the bug(s) it fixes?

Let's say we have a ContractProxy and ContractV1 its implementation, using the UUPS pattern. Along that, there is a DAO that has the rights to perform an update on the implementation contract. Only ...
Pacdac's user avatar
  • 70
2 votes
1 answer
35 views

Is there a way to stop wallet homomorph attacks without ditching the create2 opcode?

Losses from create2 wallets that look similar to recently active wallets has surpassed $60m: https://gbhackers.com/create2-bypass-wallet-security-alerts/ Even today I made a transaction, and noticed ...
rook's user avatar
  • 141
1 vote
0 answers
15 views

Why the mentioned assembly block is skipped?

A very simple function: function test(uint256 i) public { uint256 j; uint256 k = 4; assembly { pop(4) } uint256 l = 5; } I checked debugging it in Remix but the assembly block ...
Xirexor's user avatar
  • 127
1 vote
1 answer
50 views

What does the tilde symbol mean in Solidity integer type casting in the example below?

function _approveTokenIfNeeded(address token, address spender) private { if (IERC20(token).allowance(address(this), spender) == 0) { IERC20(token).safeApprove(spender, uint256(~0));...
Mila A's user avatar
  • 264
0 votes
0 answers
23 views

Signature verification using ecsign and ecrecover

I am using web3.js library to sign a transaction and then verify it from the smart contract. The Signature generated on FrontEnd and as well as from the smart contract are not same.. This is the ...
hammad ali's user avatar
0 votes
0 answers
11 views

Multiple Solidity Versions in flattened file

I have deployed a contract to Mumbai Polygon testnet. While verifying and publishing source code, the flattened file has multiple solidity versions. I got the error below. The OpenZeppelin contracts ...
Valli Nayaki's user avatar
0 votes
1 answer
31 views

Signature verification using web3js

I am using web3 library to sign a transaction and then verify it from the smart contract. The signature is not verifying. This is the frontend code const DomainSeparator = ethers.keccak256( ...
Abdul Samad's user avatar
0 votes
1 answer
27 views

Unknown key "viaIR"

Unknown key "viaIR" Error HH600: Compilation failed I'm encountering the above error when I try to compile. Here is my hardhat.config.ts import { HardhatUserConfig } from "hardhat/...
Ruwaifa Tahir's user avatar
0 votes
1 answer
14 views

Can require() be used to revert low level call() that were made before it?

CODE: (success, ) = contract.call(); // low level call if (success) { // do something } // instead of below check, can I just use require(condition)? if (!condition) { revert(); } Instead of ...
aste123's user avatar
  • 233
0 votes
0 answers
26 views

Getting error when I trying to test my contract

I started coding project and I got error when trying to test him. When I trying to call some contract function from js tester i got error: Error: call revert exception [ See: https://links.ethers.org/...
Victor's user avatar
  • 13
0 votes
0 answers
22 views

Can't call open trading function

So I try to call the open trading function in my code which is as follows: function openTrading() external onlyOwner() { require(!tradingOpen,"Trading is open"); ...
JumpingRoofs's user avatar
0 votes
1 answer
41 views

How to Specify an Acceptable Range or Ignore a Field When Testing Event Emissions in Foundry?

In a foundry project I encountered a scenario where I need to test the emission of an event with specific conditions. My requirement is either to check if a field in the emitted event falls within a ...
MShakeG's user avatar
  • 1,443
0 votes
1 answer
16 views

How signature verification works?

I have read that to sign a message we need the private key but in the below code snippet hasing is done in the 'getMessageHash' function and 'signing' is done in the 'getEthSignedMessageHash' function....
kumar's user avatar
  • 41
0 votes
1 answer
12 views

Which contract should execute the approveAndTransferFrom function under one transaction?

I'm trying to perform approve and transfer under one tx but I don't understand which contract should be calling the approveAndTransferFrom function? Say contract A is trying to transfer tokens to ...
ratib90486's user avatar
0 votes
1 answer
16 views

Which function to use for swapping eth against token on uniswap?

I use the following code to create the swap_transaction: swap_transaction = router_contract.functions.swapETHForExactTokens( 0, [weth_address ,token_address], account_address, int(time.time())...
Bice65's user avatar
  • 1
0 votes
1 answer
16 views

require message is not coming?

Im calling storage contract from logic contract, but when i change the owner to new logic contract, Line 27 : require(owner==msg.sender,"only owner can call"); This is not properly ...
sachin murali's user avatar
0 votes
1 answer
47 views

Find slot of private variable

How do I find the slot of a private variable? I know that Foundry has the method stdstorage.sig(), but that only works for variables with public getters, so private ones are out of scope. Thanks!
dNyrM's user avatar
  • 713
0 votes
1 answer
37 views

How can this contract buy and sell a token multiple times in one transaction?

I have discovered a contract that can buy and sell multiple times within the same transaction. How does that contract work, and where can I find this contract? Thank you. https://etherscan.io/tx/...
The Fat Cat's user avatar
1 vote
1 answer
137 views

Grab first 20 bytes of 32-bytes input

In solidity casting or assembly, how do I grab the first 20 bytes of this 32-bytes input: 0x00010000c900c90062fceaad00000000000000000002af416812f9bb6f2fdff5? Thanks!
dNyrM's user avatar
  • 713
1 vote
1 answer
40 views

Is there a shortcut for "greater than or equals to" in Solidity assembly?

I have some code where I was experimenting with the Math library, namely the logarithm functions, and I figured these would be the perfect functions to optimize with assembly, after slightly improving ...
Ashraile's user avatar
0 votes
1 answer
34 views

quoteExactInputSingle is returning error

I'm working on solidity code that uses pancakeswapV3 quoter contract to call quoteExactInputSingle. Here is the code snippet function AnalyseTnx(address tokenPath0,address tokenPath1,uint256 amtIn)...
Biruk Damte's user avatar
0 votes
1 answer
58 views

Extracting input data when writing Forge tests/POCs

I would like to write a test in Foundry but I need to be able to first read data from a previous transaction that was submitted in some point in the past. For example, the transaction I'm interested ...
SKA's user avatar
  • 47
0 votes
2 answers
37 views

Gas estimation errored with the following message (see below). The transaction execution will likely fail. Returned error: invalid opcode

Unable to deploy this code on any chain. I have done all i could, cleared my browser and restarted my pc and still could not deploy. what could be the issue please. // SPDX-License-Identifier: MIT ...
Bamu Gift's user avatar
0 votes
2 answers
47 views

ApproveUSDT function not working internally, how do I fix this?

I’m experimenting with a presale contract based on the BSC testnet, and in the contract I’m attempting to achieve the purchase of my token with USDT. Using my own code within the contract itself, I ...
HAT0ken's user avatar
0 votes
0 answers
21 views

I deployed the launchpad contract, but the result is 0x00000. What could be the cause?

Deployer // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./launchpad.sol"; contract Deployer is Ownable { uint256 public launchpadCount; uint256 public deployCost = ...
Moushy Dev's user avatar
2 votes
1 answer
65 views

Call external contract with arguments in Huff

I am trying to make an external function call, with arguments, to a contract written in Solidity from a contract written in Huff. I am able to successfully call an external contract when the function ...
JSON_Derulo's user avatar
0 votes
3 answers
35 views

How to encode param of type address

I have this function in my contract: function removeRes(address _res) public onlyOwner { . . . } I'm encoding ABI like: const contractAddress = "...
stuckoverflow's user avatar
0 votes
1 answer
62 views

How to fix `Expected 0 arguments, but got 1` error on web3.eth.contract method?

I'm trying to make a simple function call to a view function that takes a single uint256 as input, however when I try to pass the variable, next type check gives me this error: Expected 0 arguments, ...
Rohan Nero's user avatar
  • 1,443
0 votes
1 answer
21 views

Is it possible Randomly generate and privately store data using Chainlink?

I'm working on a social coordination game for the Chainlink Constellation Hackathon. Game mechanics are similar to Mafia, Bang! or AmongUs where roles are assigned at the onset of the game. Roles ...
0xOmen's user avatar
  • 1
1 vote
1 answer
30 views

Are block.timestamp and block.number still problematic under Proof of Stake?

As stated in the SWC116 (https://swcregistry.io/docs/SWC-116/) using block.timestamp and block.number in Smart Contracts under Proof of Work was problematic. Block.timestamp could be influenced by ...
Yleisnero's user avatar
0 votes
1 answer
54 views

Unable to deploy on Eth mainnet

i done all the steps and when im connecting to "Injected provider" its still asking to be on EVM version: shanghai. i want to deploy the CA on the mainnet.
TryingToDeploy's user avatar
2 votes
2 answers
44 views

Solidity automatically generated getter function returning tuple instead of struct

// SPDX-License-Identifier: MIT pragma solidity =0.8.22; contract A { struct User { string name; uint age; } mapping(uint => User) public users; function getUser(...
zzh1996's user avatar
  • 141
2 votes
1 answer
264 views

What is a returnbomb attack?

I've read that when making an external call to an unknown contract, if the contract returns a large amount of random or junk byte it will cause some type of bug. But I dont know exact what it is and ...
kumar's user avatar
  • 41
0 votes
0 answers
10 views

Who is the msg.sender in the context when calling the "super.{....}" contract method on the inherited parent contract?

The child contract's method is: (1) function redeem( uint256 shares, address receiver, address owner ) public override andSync returns (uint256 assets) { return ...
Mila A's user avatar
  • 264
0 votes
2 answers
26 views

Solidity - Trouble Installing Foundry: SSL Connection Timeout"

I'm encountering an issue while trying to install Foundry using the command curl -L https://foundry.paradigm.xyz | bash. The process times out with the error message: % Total % Received % Xferd ...
Temisan Momodu's user avatar
1 vote
1 answer
27 views

How to interact with contract methods with more complicated data structures with Nethereum?

I'm trying to interact with the smart contract that I have created. At the moment I deploy the contract on GANACHE. Adding new items into contract works. This is the part that doesn't work, and it ...
michal's user avatar
  • 13
1 vote
1 answer
87 views

Huff language gas optimization

I am testing out using Huff language for smart contract development. It is my understanding that the benefit of Huff language is the improved gas efficiency. However, in my small test, the contract ...
JSON_Derulo's user avatar
1 vote
1 answer
5 views

Can anyone help me to solve this error (TypeError: contractInstance.isComplete is not a function)?

My Solidity code: // SPDX-License-Identifier: MIT pragma solidity^0.8.17; contract Lottery { address public manager; address payable[] public players; address payable winner; bool ...
balamurugan kesavan's user avatar