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

Gas griefing in "typed" external calls

I was wondering whether the "insufficient gas griefing attack" is possible in cases when the external call is a typed call rather than an inline call with lower level utility functions (i.e. ...
Mila A's user avatar
  • 264
1 vote
0 answers
74 views

Could not decode result data

I have an issue when trying deploy contract // SPDX-License-Identifier: ISC pragma solidity ^0.8.19; contract SimpleStorage { uint256 favoriteNumber; struct People { uint256 favoriteNumber; ...
Victor's user avatar
  • 13
1 vote
0 answers
14 views

What does this function actually do in ERC1820?

I am unable to understand these two functions from the ERC1820 contract and its use. What does it actually do under the hood? Function 1 : /// @notice Checks whether the hash is a ERC165 interface (...
Serenity's user avatar
0 votes
0 answers
14 views

How to add 5% buy and 5% sell fees to live-token?

I want to add 5% Sell and 5% Buy Fees to a token contract on Remix The Token is already live, so i just want to update it from 0% to 5%. But the numbers are all in uint256, what is the correct number ...
LoveAngel's user avatar
0 votes
0 answers
18 views

how to access to a public mapping from test script

i'm in hardhat i'v this public mapping mapping (address user => uint[] commentIds) public userComments; and i'm trying to call it inside my test Script console.log(`user1 comments: ${...
Yassine's user avatar
  • 11
0 votes
0 answers
12 views

Can I delete the Values in the mappings using delete keyword [duplicate]

mapping(IERC => contract) public testing; delete testing[IERC]; In the above code snippet I want to delete contract type (value) using the delete keyword can it be possible?
kumar's user avatar
  • 41
1 vote
2 answers
42 views

Read Solidity struct with Web3.py

I can use Python to read from contracts using functions like: tx = mySolidityContract.functions.x().call() to read a variable x on mySolidityContract Say I have a struct in my solidity contract, like ...
Eric Falkenstein's user avatar
1 vote
0 answers
28 views

How to record GPS points without exceeding int256?

I want to record GPS points in my smart contract, and what I'm currently doing is removing the decimal. The problem is that some values exceed int256. How can I resolve this?
Jérémy Combe's user avatar
0 votes
1 answer
32 views

Error deploying contracts: Error: incorrect number of arguments to constructor at ContractFactory.getDeployTransaction

const hre = require("hardhat"); // async function main(){ // const RPSLS = await hre.ethers.getContractFactory("RPSLS"); // const RPSLSF = await RPSLS.deploy(); // await ...
Indul's user avatar
  • 9
1 vote
0 answers
89 views

cannot use array as type ptr as argument

I am using Go-Ethereum and I have the following error: abi: cannot use array as type ptr as argument But it does not make any since I don't pass an array. The arguments to routerABI.Pack function ...
pigfox's user avatar
  • 125
0 votes
1 answer
23 views

Incorrect Decimals & Max Total Supply ERC20 Token

After deploying token contract on ethereum I am getting 0 decimals being shown on etherscan whilst other explorers displaying correctly. I presume because of this Max Total Supply displays as:- 3,200,...
Anicho's user avatar
  • 101
1 vote
0 answers
13 views

Will block.coinbase.call{value: _ethAmountToCoinbase}(new bytes(0)) revert if transaction fails?

A similar looking statement address.call(abi.encodeWithSignature()) will not revert if transaction fails because it is an external call. So, will block.coinbase.call{value: _ethAmountToCoinbase}(new ...
aste123's user avatar
  • 233
0 votes
1 answer
33 views

Trying to send Matic from one wallet to another on Mumbai but it is not sent

Below is my solidity code. I am trying to send MATIC to the "receiverAddress". Everything looks fine. I have 2.3875 MATIC in my wallet and I'm inserting 87500000000000000 as sending MATIC ...
nihilisama's user avatar
0 votes
1 answer
61 views

Token with whitelist function, that would only whitelisted addresses to trade the token while trading is disabled

I want to create a token and add liquidity but only whitelisted addresses would able to trade the token while trading is disabled. If trading is enabled that means everyone can trade it but if it is ...
ccurves's user avatar
  • 133
0 votes
1 answer
24 views

transferFrom fails even though allowance granted?

Please see attached Tenderly stack trace: https://dashboard.tenderly.co/shared/simulation/86e27f67-6f7e-4122-83da-d43f455fb57a I'm not sure why transferfrom is failing even through I have granted ...
Christian Papathanasiou's user avatar
0 votes
0 answers
14 views

Issues in the ERC20 token Contract burn

I was just going through this contract and that the _balances[account] is being deducted before the require statement. Is this still correct? also there was no else and seemed like it will be ...
Priyanshu Dwivedi's user avatar
0 votes
1 answer
26 views

Trying to send matic to a wallet but Can't stake MATIC

basically what I am trying to do is create a contract that different wallets can send MATIC to one single wallet and after some time withdraw with some reward as MATIC. ie. Stake 100 matic, then ...
nihilisama's user avatar
0 votes
1 answer
7 views

How to get the array index by a perticular condition

// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; contract final_year_project { struct hospital_record { address patient; string hospital; string docter; ...
Asad Arslan's user avatar
1 vote
1 answer
31 views

Weak RNG vulnerability proving

Hi guys I am auditing a smart contract and I found a WeakRNG in order to prove it I have written 2 smart contracts which simulate the work of this function( a bit ) here is the 1 a have changed block....
NeoRusI's user avatar
  • 11
0 votes
1 answer
41 views

Solidity: How to decode / trace / search custom error byte code

I ran into this Custom Error during my Foundry test: [FAIL. Reason: Custom Error cd786059:(0xF628...)] and I had no idea about what it means... then I figured out where it went wrong after tracing ...
Russo's user avatar
  • 1,764
0 votes
1 answer
35 views

Approve function called by an address in a smartcontract different from the token contract

I would like to know if an address can give approval to spend his tokens to another address or contract by calling the function approve in the same contract (not the token contract but another). Thank ...
biel Serrat's user avatar
0 votes
1 answer
22 views

Rejecting the transaction doesn't catch the error in try-catch block

I am working on a Dapp porject ,Where I have to catch the metamask error. Here is my code: import React, { createContext, useContext, useEffect, useRef, useState, } from "react"; ...
Asir Shahriar Roudra's user avatar
0 votes
1 answer
42 views

Is Making an NFT on Binance Smart Chain on Remix currently possible? (compiler versions problem)

I'm trying to make a basic imageless NFT for Binance Smart Chain using remix.ethereum.org (for NFT identity verification purposes) but I've encountered a problem. Basically solidity version 0.8.2 or ...
Adjam's user avatar
  • 137
1 vote
1 answer
19 views

How can I access the 3rd argument of _safeMint?

I am minting an ERC721 using _safeMint and I am setting the 3rd argument to a string. I want to be able to access this data argument using the transaction hash or whatever I have to access the ...
Falcon Stakepool's user avatar
1 vote
2 answers
30 views

Is it possible to validate a UUID in Solidity?

How can I check that a uuid is valid in Solidity? Is there a library or anything to do that?
Falcon Stakepool's user avatar
0 votes
1 answer
35 views

How to download and install Echidna?

I have just started learning echidna but i havent found any detailed information of how to install and setup echidna in WSL.
kumar's user avatar
  • 41
1 vote
1 answer
26 views

".send()" web3.js in the browser for a deployed contract, it doesn't work correctly

I am not a native English speaker, so my English is not very good. I apologize if my sentences are not correct. I have deployed the following contract. pragma solidity >=0.4.22 <0.9.0; pragma ...
Sichi's user avatar
  • 11
0 votes
1 answer
25 views

Psuedorandom generator sourced from onchain entropy

I'm writing a fun game as a solidity contract and looking to generate somewhat random (or unpredictable numbers). I have researched this topic and am aware using an off chain oracle is the best ...
user avatar
0 votes
0 answers
3 views

transact to VRFD20.rollDice pending

Guys whichever function i'm calling after deployment , its saying transact to be pending... what is the reason behind this , i'm not getting it
MD AZAD's user avatar
0 votes
1 answer
20 views

How to identify from where exactly the transaction got reverted while deploying and running the code in remix?

After testing a smart contract with several test cases, in some cases it reverts back and says errored: Error occured: revert. revert The transaction has been reverted to the initial state. Note: The ...
ImBatman's user avatar
0 votes
1 answer
23 views

If a function takes deposit of tokens and then calls another function in the same transaction, is the latter function "aware" of the token deposit?

I'm pretty new to solidity and I'm looking at this contract, specifically the deposit and _mintShares functions. deposit accepts a deposit of tokens and then calls _mintShares during its execution. Is ...
user127148's user avatar
0 votes
1 answer
21 views

whitelist contract's address showing undefined without showing any error message

I am following this tutorial here to learn developing whitelist contract. My node verion is 18.12.1 and testnet is sepolia. I am currently on windows11 OS. whitelist.sol: //SPDX-License-Identifier: ...
swarna islam's user avatar
1 vote
1 answer
23 views

Call or assignment expected. Getting this error while upgrading solidity version

I am not aware of the Assembly code. I copied the ERC1820 registry contract from here. This is written in 0.5.3. When I tried to compile it with 0.8.0 it gave me this error : I know it's because of ...
Serenity's user avatar
0 votes
0 answers
13 views

Need help with debugging Error: Definition of base has to precede definition of derived contract

I'm working on a social account recovery feature for smart accounts (ERC-4337) on top of Thirdweb's smart account contract. Link to the codebase I'm getting the error Base has to precede definition of ...
alfheimrShiven's user avatar
0 votes
1 answer
31 views

Vscode , wrong error messages

if some one could help me how to disable wrong warning errors in vscode ?
Louy Mahmoud's user avatar
1 vote
1 answer
76 views

I need help from Expert Dev for POS bot [duplicate]

I recently received a code and deployed it. it sent 0.2 eth which is succesful and is visible in the contract transaction. I hoped to generate some passive income with with this POS Bot. The problem ...
TXN crypto's user avatar
2 votes
1 answer
74 views

How to assign and send ether value together with deployment of contract using Foundry

This is the simple function, how do I deploy the contract and send ether along with it? function setUp() public { test = new testContract( Owner; ); }
anonauditor's user avatar
0 votes
0 answers
11 views

How to have solidity output as minimal assembler-close bytecode as possible?

While as indicated in this answer it is probably impossible to have Solidity optimize away the free memory pointer and it's initialization causing the bytecode to start with 0x6080, I was wondering if ...
Zommuter's user avatar
  • 113
0 votes
1 answer
24 views

Solidity variable for contract scope (not state variables)?

I use state variables for the interaction of calls (fallback) between contracts. But copying and clearing state variables uses a lot of gas. Perhaps there is a better practice, how to have temporary ...
Andriy's user avatar
  • 1
0 votes
1 answer
42 views

Solidity Event String parameter decoding

The value of aggregatorId in the event emitted by the below tx is not equal to value “oneInchV5FeeDynamic” in the tx? Also, I can’t decode the value emitted in the event “...
Waiz Khan's user avatar
2 votes
1 answer
20 views

Has Solidity Introduced Storage Optimization for Smaller Integer Types in Structs?

I am working on a project where storage efficiency is of utmost importance. Specifically, I have a scenario where I want to store an ID of type uint16 and a code of type uint8. The current plan is to ...
MShakeG's user avatar
  • 1,418
0 votes
1 answer
34 views

Cant make conection with my Smart Contract using web3

I cant get my contract instance using web3 . I am making todo app using web3 . I cant get my contract instance in js file . I am new to web3 development and everyday I am trying my best improve my ...
Shorna's user avatar
  • 13
2 votes
1 answer
46 views

Transaction data is not a multiple of 32 bytes

My understanding is that in a transaction's input data, the first 4 bytes, i.e. 8 characters, is reserved for a function signature. The rest of the data, after processed by the API, will be fitted to ...
Khanh's user avatar
  • 41
0 votes
1 answer
51 views

What is wrong with this code that it is not deploying on the testnet binance smart chain and giving me infinite gas error [duplicate]

// SPDX-License-Identifier: MIT pragma solidity ^0.8.21; // Import the OpenZeppelin library for security. import "@openzeppelin/contracts/access/Ownable.sol"; interface IERC20Token { ...
Jaylukmann's user avatar
1 vote
1 answer
38 views

How to customize forge formatter in vscode

I'm using Foundry toolchain and vscode for my smart contracts development. As suggested by the Foundry documentation I applied the vscode integration tweaks and I'm using forge formatter to format my ...
forhas's user avatar
  • 765
0 votes
1 answer
9 views

new release of ERC1155SupplyUpgradeale has compilation issues

The new contracts lib from OZ, specifically ERC1155UspplyUpgradeable has compilation issues before even inheriting it in any child contract (check screenshot below) any idea why? or how to fix it? ...
sasha's user avatar
  • 41
0 votes
0 answers
12 views

How are discrepancies with integer division handled in production contracts?

In my Escrow contract I have an item worth 0.1 ether and 1 wei = 100,000,000,000,000,001 wei. I need to divide this amount in half, and send it to two people. 100,000,000,000,000,001 / 2 Each person ...
DIRTY DAVE's user avatar
0 votes
0 answers
30 views

CREATE2 in UniswapV2Factory contract returns zero address on my test network

My function in a contract is responsible for creating a liquidity pair on uniswapV2. Unfortunately, the "CREATE2" opcode in the createPair function of the UniswapV2Factory contract does not ...
Aaaaaaaa's user avatar
0 votes
0 answers
33 views

Can you tell me, why addLiquidityETH is not working?

Can you tell me, why addLiquidityETH is not working? I'm trying to call her through etherscan. // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC20/...
user125862's user avatar
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