Skip to main content

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
1 vote
1 answer
21 views

Can't catch Web3.js' contract error when calling a method and cancelling the transaction

I have a very simple React app that calls a Solidity smart contract's method using Web3.js (4.3.2) with some data coming from a form. I'm trying to catch errors while calling the contract method or ...
Danziger's user avatar
  • 131
1 vote
1 answer
22 views

Modifer To Dynamically Forward Parameters with message sender

I want to create a modifier to dynamically forward parameters to a validator lets say I have a contract contract Foo { address validatorAddress; modifier validate() { assembly { ...
RitzyDevUk's user avatar
1 vote
1 answer
25 views

How to manipulate the first few digits of a Smart Contract?

I saw some devs that can pick the few digits of their choice for their smart contract, like 0xd0d0, and I saw that some even do more than 4 digits (like 5-6 digits after 0x). Does anyone know how to ...
Andrew Manggala's user avatar
0 votes
0 answers
20 views

Is this token a scam? (ABYS)

I was recently browsing the list of new pools on arbitrum and came across this coin: https://arbiscan.io/address/0xd7d39c9fa965b8b2458f2f6100f78e5ad1b318fe Without looking too much into it, I saw a ...
ChewyCorndog's user avatar
1 vote
1 answer
53 views

Deploying Contracts with Multi-Sig Wallet via Safe-Global/Safe App Wallet & Hardhat: Need Guidance

I’m looking for assistance with deploying a contract using either safe-global or the Safe App wallet. My goal is to initiate the deployment with a multi-sig wallet via Hardhat scripts. Can anyone ...
SBansal's user avatar
  • 11
1 vote
1 answer
20 views

Ownable: Inheritance vs. Modifier for Gas Efficiency

When implementing access control in Solidity contracts, OpenZeppelin's Ownable library offers a convenient solution. However, a question arises regarding gas optimization: is it more gas-efficient to ...
Awais Ahmad's user avatar
0 votes
1 answer
43 views

Getting execution reverted: ERC20: transfer amount exceeds allowance code: UNPREDICTABLE_GAS_LIMIT method

Getting this error when attempting to call an external swap function in a contract I created on the Sepolia Test Network from Hardhat TypeScript. reason: 'execution reverted: ERC20: transfer amount ...
Ian Forsyth 's user avatar
0 votes
3 answers
35 views

How do I know what method is called when swap to my ecr20 token?

I am reading ECR20 code: https://docs.openzeppelin.com/contracts/2.x/api/token/erc20 and understand how it works. What I don't know is that what the method is called when swap other tokens to my ECR20 ...
Joey Yi Zhao's user avatar
0 votes
0 answers
39 views

Can't add liquidity to my token

I created a token and now I need to add liquidity to it. Here is a code of my contract: // SPDX-License-Identifier: MIT pragma solidity 0.8.20; abstract contract Context { function _msgSender() ...
Regular User's user avatar
0 votes
1 answer
20 views

Bulk transaction on Base chain

After adding liquidity, I frequently see wallets making bulk transactions on the base chain. How can I snipe tokens early and cheaply like them? CA: 0x1234567517769aCd8519BA85184EdbBaC6062971 Tx: ...
Văn Châu Cao's user avatar
1 vote
1 answer
54 views

Bridging On-chain Data with LLM Models: Retrieving Token Information (Solidity + GPT)

I'm developing a Solidity token and exploring ways to leverage Large Language Models (LLMs) like GPT to answer user queries about the token's data directly within the application. Ideally, I'd like ...
Awais Ahmad's user avatar
0 votes
0 answers
16 views

Uncaught ReferenceError: handleRegistration is not defined at HTMLButtonElement.onclick

I have created and deployed a smart contract for IP management using truffle. I have created a frontend to interact with this deployed contract. <head> <meta charset="UTF-8"> ...
Yash R. Khandelwal's user avatar
0 votes
1 answer
14 views

How to set Pool Extension for staking function?

Now I am trying to test stake and claimReward function following existing sample codes. StakingPool.sol contract StakingPool is Context, Ownable, ReentrancyGuard { //rest codes function stake(...
Apple-Tim's user avatar
1 vote
0 answers
20 views

How to predeploy and verify a linked library?

There are 40 zeros as padding in the bytecode compiled with the library. And when deploying a contract that uses linked libraries, the contract's bytecode contains the libraries addresses. There is a ...
Sia's user avatar
  • 11
1 vote
0 answers
23 views

Implementing BLS Verification using the precompile altbn_128 contract

I am trying to implement BLS using the alt_bn128 curve. so far my code looks as follows: function verify( uint256[2] memory signature, uint256[4] memory pubkey, uint256[2] memory ...
Wheatley's user avatar
1 vote
1 answer
20 views

Solidity Contract Error: "call to SimpleStorage.people errored: invalid opcode"

I'm encountering an issue with my Solidity contract and could use some help debugging it. I have a simple contract named SimpleStorage that includes a struct People and an array people to store ...
Kuldeep Sonara's user avatar
0 votes
1 answer
34 views

Difference between Liquidity in Uniswap V2 und V3 when deploying a contract

When I deploy a contract and add liquidity to my V2 pool on Uniswap, I usually add amount of TokenA and an amount of ETH which then determines the price (amount of tokens / amount of ETH). When people ...
SolidityNewbie's user avatar
0 votes
1 answer
221 views

Deploy proxy upgrade pattern contract using hardhat ignition

I have a contract like this: // SPDX-License-Identifier: MIT pragma solidity ^0.8.24; import "@openzeppelin/contracts-upgradeable/token/ERC721/ERC721Upgradeable.sol"; import "@...
user134676's user avatar
0 votes
1 answer
39 views

TotalSupply of token not showing

Trying to practice web3, I want to show the total supply of ERC20 token by making a frontend. Please help ! import React, { useState, useEffect } from 'react'; import Web3 from 'web3'; import erc20ABI ...
Asad Arslan's user avatar
0 votes
0 answers
69 views

Solidity smart contract not compiling in python

I am trying to use the following to compile and deploy a smart contract. The last line comes with the error mentioned below. from web3 import Web3, HTTPProvider from solcx import compile_files, ...
Thierry Grandjean's user avatar
0 votes
1 answer
54 views

Foundry Solidity Error: panic: array out-of-bounds access (0x32) while testing a batch mint function

I'm writing foundry tests for a function which batch mints erc1155 tokens for the users, but I'm getting a panic revert. The function I'm testing: function mintBatch( address to_, ...
DevABDee's user avatar
  • 473
0 votes
1 answer
17 views

I'm getting an `Unreachable code` warning in my function block

I am getting an Unreachable code warning in the following function block: /** * @notice Follows CEI (checks, effects, interactions) * @param tokenCollateralAddress The address of the ...
Seyed Mahdi Hosseini's user avatar
1 vote
2 answers
16 views

Which value is picked up by a transaction stuck in mempool upon execution - one at Launch time or one at Execution time?

Could someone please confirm what happens in the following scenario: uint256 public reducer = 5; function calculateYield(uint256 lpTotal, address tokenA, address tokenB, uint256 minA, uint256 ...
H.C's user avatar
  • 11
1 vote
1 answer
27 views

I just wanted to know if there is a possibility that in solidity we can have array of string?

I have specific Requirements for a project, where i have to store multiple strings against one owner in a mapping but i noticed there is no string arrays in solidity Is there an alternative way of ...
Mahnoor Chaudhary's user avatar
0 votes
0 answers
22 views

Building dApp To Allow Users to Customize and Deploy Tokens

I have been stuck for quite awhile and cant get past it. I've found some gits of old projects with similar concepts, but none have the features platforms like some I've seen lately, such as: [...
DevJimmy's user avatar
0 votes
1 answer
19 views

how to verify minting was successful before proceeding in solidity OZ?

here is my contract details below. remix is showing me that _exists is not found and setTransfer not found. you guys got any clue on this ? I want to verify the minting of a token actually was ...
j2emanue's user avatar
  • 105
0 votes
1 answer
30 views

Multiplication of two uint256

How do I compute the multiplication of two uint256 so the result doesn't overflow? In the end, this multiplication is an intermediate step within a larger operation, in case this extra piece of info ...
dNyrM's user avatar
  • 928
0 votes
1 answer
20 views

how to know what to use for default base constructor in erc721 smart contract?

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; import "@openzeppelin/contracts/access/Ownable.sol"; ...
j2emanue's user avatar
  • 105
0 votes
1 answer
24 views

Function is callable from Thirdweb Dashboard but not from the front end

I can call the function from the Thirdweb Dashboard and I get appropriate outputs but whenever I try calling it from the frontend I get a very weird error Here is the function: function userStakeInfo(...
Mohamed Wael's user avatar
1 vote
2 answers
96 views

No Gas Consumption for Computations not changing the State of the Blockchain

From my understanding, a Solidity function running on a compatible EVM that doesn't change the state of the blockchain will not cost any gas. And this indeed appears to be the case, as I have ...
JF0001's user avatar
  • 291
1 vote
3 answers
29 views

Accessing a variable in Solidity

Suppose I have contract A and contract B. Contract A is of type contract B. I would like for B to have access to constants belonging to Contract A Contract B { //I want to access myAddr inside ...
qubitz's user avatar
  • 296
0 votes
1 answer
41 views

Transaction execution reverted on swapExactTokensForETH

I hope somebody can help I am trying to sell a token via Uniswap V2 Router02 (Token CA: 0x4ed4E862860beD51a9570b96d89aF5E1B0Efefed) (This token is a legit one, there is no scam here), I have ...
duyanhhz's user avatar
1 vote
1 answer
34 views

Contract.functions "not found" in Web3.py

Testing this python code on UBUNTU : import requests import json from eth_account import Account from web3 import Web3, HTTPProvider caller = "0xb9****f832860DBD" private_key = "...
Thierry Grandjean's user avatar
0 votes
1 answer
32 views

SwapRouter02 not working with custom ERC20 token

I am trying to programmatically swap ETH for a custom ERC 20 token (let me take a meme token as an example) Here is my code that I swapped ETH for USDC: const { ethers } = require("hardhat");...
duyanhhz's user avatar
0 votes
1 answer
15 views

Gas Estimation Error - Simple Token + ICO Project

I am a beginner in Solidity and created a simple token + ico file and am testing the code on Base Sepolia Testnet and am running into a peculiar error. I keep getting Gas Esimation Error on the ...
QuantPhdResearch's user avatar
0 votes
1 answer
21 views

Convert the following address sum function to optimized assembly via both memory and storage. Slots are dynamic

I'm looking to convert the entire function getCurrentSupply() to assembly code as the potential gas savings in this use case are significant. Note that everything should be within a single assembly{} ...
Ashraile's user avatar
  • 125
0 votes
1 answer
49 views

I get this error when i try calling the getBalance function in node.js

eth_chainId eth_accounts eth_call WARNING: Calling an account which is not a contract From: 0xf39fd6e51aad88f6f4ce6ab8827279cfffb92266 To: 0x5fbdb2315678afecb367f032d93f642f64180aa3 this is ...
Thato Bopape's user avatar
0 votes
0 answers
18 views

Getting error Error in plugin @nomiclabs/hardhat-etherscan: You set an Etherscan API token for the network

Hello Dear I need Some help Am trying all The day TO deploy nft in Base testnet in visual studio code I deployed it but when I try to verify I got This error Error in plugin @nomiclabs/hardhat-...
Shi's user avatar
  • 1
0 votes
1 answer
16 views

Debugging when catching a custom error

Example Based on this answer, I was able to write the following custom error: error ReachedInvestmentCeiling(uint256 providedVal, string errorMessage); if (hasReachedInvestmentCeiling(...
a.t.'s user avatar
  • 79
0 votes
1 answer
39 views

selfdestruct in solidity is reinitializing the contract

Hello I am trying to solve ethernaut challenge MotorBike ,code below // SPDX-License-Identifier: MIT pragma solidity <0.7.0; import "openzeppelin-contracts-06/utils/Address.sol"; import ...
Tanaka wa Kun's user avatar
0 votes
1 answer
81 views

Calls to self failing when passing structs

When a contract calls itself using the .call method and attempts to pass a struct, it results in a revert with the following error output: "error": "Failed to decode output: Error: data ...
Riley's user avatar
  • 1
1 vote
1 answer
88 views

Is the sum of hashes cryptographically secure for a set of addresses?

In a smart contract, I want to maintain a set of addresses independent of the order. Would the sum of the hashes for each of the addresses be a cryptographically secure approach? If I do: root = ...
wolf dun's user avatar
0 votes
1 answer
41 views

How to accessing Smart Contract write function from the frontend (React Js ) without any private key?

Currently, when I try to write a function on Solidity Smart Contract from ReactJS, it is not working and throws an error called "unknown account." for the below code. await contractMethods....
AIT DEV's user avatar
  • 15
1 vote
0 answers
25 views

How to foundry test a function which uses 1Inch Swapping functionality?

I'm working on a protocol's Adapter contract. The Adapter contract have a function, which let users sell their PortalEnergy (assume tokens) to get ETH. They use 1Inch Swapping functionality to get ...
DevABDee's user avatar
  • 473
1 vote
0 answers
13 views

Does `call` opcode panic if less size data is returned?

I was reading the zksync documentation and found the following in the differences section here For calls, you specify a memory slice to write the return data to, e.g. out and outsize arguments for ...
Neo's user avatar
  • 103
0 votes
1 answer
32 views

"ContractExecutionError: Error happened while trying to execute a function inside a smart contract" after calling it via mint button

Contract Code: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "@openzeppelin/contracts/token/ERC721/extensions/ERC721URIStorage.sol"; import "@openzeppelin/contracts/...
Lucky Rajput's user avatar
0 votes
1 answer
27 views

Very High gas fee in my staking contract

I am trying to implement my staking contract, for some reason calling stake() or claimRewards() costs 2MATIC ~ 4MATIC. I know my code is kind of complex since I loop and use data structures but still ...
Mohamed Wael's user avatar
0 votes
1 answer
24 views

how to verify contracts in contract (created with contract ) polygon

i have a following structure for my contracts : 1 - OpenZeppelin v 4.9 2 - safepool 3 - safepoolfactory i have a single file that this code : pragma solidity ^0.8.0; import "https://github.com/...
Hosein In jast's user avatar
0 votes
1 answer
47 views

Invalid API key sepolia network blockscout

I deployed a contract on sepolia network and I would like to verify my coin using hardhat. npx hardhat verify --network sepolia 0x44ED9AB9F4Ab72e4b1aBfEBaDf5A942617B90D18 I created an API key on ...
SolidityNewbie's user avatar
0 votes
0 answers
7 views

Scripts directory not installed

I am creating a smart contract where I have to run the script directory. But even after installing all the dependencies the directory is not getting added to the root folder.
Shravani Sawant's user avatar