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

Solidity query works in dev environment but not in production build (nextJS)

I am calling a function that queries the token balance of a user. The query works on a dev environment but not in production build. I am using metamask and ethers to interact with my contract on the ...
Ciirno's user avatar
  • 1
0 votes
0 answers
9 views

Has the way to access public member variables in solidity through deployed contracts changed?

I have a public contract member defined like this, which is later assigned a value in the constructor AggregatorV3Interface public priceFeed; I want to access this variable's value and I am trying ...
Pankaj Sehrawat's user avatar
0 votes
0 answers
12 views

Missing transaction details in MetaMask (only showing gas fees) dApp testing

I'm building a presale dApp as an experiment, and when I hit the buyButton, MetaMask successfully opens for me to approve spending my USDT (labelled a contract interaction). However the transaction is ...
HAT0ken's user avatar
0 votes
2 answers
20 views

Can we override the private variable in base contract?

Background: I'm using an opezeppellin Erc20 contract. but i want to use it for minimal proxy pattern(eip-1167). so for that reason i cannot use constructor and have to use the initialize method. Now I'...
Saad Suri's user avatar
0 votes
0 answers
26 views

Cannot recover signer

I am facing a problem where recoveredAddress is not restored correctly. We assume that the address of the owner who originally deployed the smart contract is returned. Am I making some big mistake? ...
tgf8faf's user avatar
0 votes
1 answer
17 views

Use offchain date time

in my contract, I need to do something based on time, and this is quite sensitive, and as we know, you cannot rely on the block.timestamp because it can be changed, I want to know if there is a way ...
Mehran Ra's user avatar
  • 373
0 votes
0 answers
13 views

I want to check seller balance before trancsaction and after tracsaction and check them if they are equal or not

I created an auction exchange smart contract using solidity programming language and this is a test file written in JavaScript. seller is the creator of auction and buyer1 and buyer2 are the persons ...
Huzaifa Ahmed's user avatar
0 votes
1 answer
13 views

How to use anvil accounts in the Foundry Test

How can i use anvil accounts into the foundry tests? Like in hardhat node i can getNamedAccounts() but how can I use the anvil accounts into my forge Tests?
Saad Suri's user avatar
1 vote
2 answers
148 views

Remove the element from array where order matters?

I am presenting my use case here. Let's think of a dating app where each candidate enters their preferences and we store their data and add them to an array. when someone enters that matches with any ...
Rashid Ul Haq's user avatar
0 votes
1 answer
12 views

How to import external files?

I'm trying to create a fund function that allows users to fund their wallet after signing. I had my contract address & ABI stored in an external file and tried to export and import, but that didn'...
SABER's user avatar
  • 1
0 votes
1 answer
11 views

How can I verify & publish source code on bscscan?

Can someone please help me verify & publish the source code for this token? I keep getting error message saying invalid constructor arguments (please make sure they are in ABI encoded format). ...
Toya Brown's user avatar
0 votes
1 answer
15 views

How to find a variable declaration in an AST object

I'm using Javascript, and I have a Solidity AST object. Is there a library or an example out there to easily find if a text string (variable/function/mapping/struct etc declaration) exists and return ...
Salman Fazal's user avatar
1 vote
2 answers
46 views

How can I fix a problem with transferring ERC721 by approved contract?

Hey everyone I'm new to NFT development and developing an ERC721 token for property ownership and marketplace. I implemented two functions to enable a user to put their token on sale for another user ...
emtothed's user avatar
0 votes
1 answer
21 views

How do you use the Diamond Pattern for escrow upgrades?

I am creating a contract with the diamond pattern so I can evolve and add new features to my contract. Contract facets: Contract A: an ERC721 that takes care of minting its own NFTs Contract B: ...
Piyush Chittara's user avatar
0 votes
0 answers
12 views

Why or where should one use Twos Compliment in Solidity?

I was reading through Solidity Docs and came across Bit Operations section https://docs.soliditylang.org/en/v0.8.21/types.html#bit-operations Couldn't figure out why one would use this. However, I do ...
Ishan's user avatar
  • 51
0 votes
1 answer
10 views

Do you have to explicitly state in the body of a function that it should return something?

I'm looking at the following function which is supposed to return (uint8 id, uint8 nextId). I see that in the body of the function, the return statement is within an "else" statement - see ...
auditor_chick's user avatar
0 votes
1 answer
13 views

ERC721 token image not showing in wallet

Hey everyone I'm new to NFT development. I developed an ERC-721 token used for property ownership and I deployed and minted a token both on Anvil and sepolia. I can import the token on metamask but ...
emtothed's user avatar
1 vote
1 answer
33 views

how come loading the funcSig from data isn't enough, you have to shift it also to use it in the rest of the code/function

basically we have this function function FlaggedMethods( bytes memory data ) public returns (address) { bytes4 funcSig; assembly { // Shift right by 224 bits ...
owl's user avatar
  • 13
0 votes
1 answer
22 views

Instantiation of Solidity Interfaces

There is an interface called IiZiSwapFactory (source), which declares a method named swapX2YModule() (source). IiZiSwapFactory.sol interface IiZiSwapFactory { /// @notice emit when successfuly ...
Jim's user avatar
  • 103
0 votes
0 answers
12 views

approve spender to swap

i'm trying to swap using 1inch aggregator api and when i try to swap, it says "Not enough allowance. Amount: 4600000000000000. Allowance: 0. Spender: 0x1111111254eeb25477b68fb85ed929f73a960582&...
Biruk Damte's user avatar
0 votes
1 answer
9 views

Creating a local variable in an if statement?

I'm looking at a function that creates a local variable in an if statement. If someone called that function and the condition to the if statement was not triggered, that local variable wouldn't exist, ...
auditor_chick's user avatar
0 votes
2 answers
15 views

Explain this constructor inheritance solidity

Is BranchBridgeAgentFactory the parent contract? Will there be two different address? Or just one? pragma solidity ^0.8.0; contract TestBranchBridgeAgentFactory is BranchBridgeAgentFactory { /*////...
anonauditor's user avatar
0 votes
1 answer
54 views

NFT metadata for property ownership ERC721 token

Hey everyone I'm new to NFT development and I'm trying to develop a simple property ownership and marketplace using the ERC721 token standard. since I'm so unfamiliar with json I have some problems ...
emtothed's user avatar
0 votes
2 answers
48 views

provide steps to deploy this contract from solidity by example

When i tried deploying this contract using 10 ethers, and then providing : claimPayment() -> amount - 9000000000000000000 i.e 9 ethers -> nonce - 123 -> signature - ...
ImBatman's user avatar
1 vote
0 answers
13 views

Is there any way to read block attestation from inside a solidity smart contract?

Are there any precompiles, or any other native ways to get block attestation data from ETH2 POS inside a solidity contract?
Bruce's user avatar
  • 867
1 vote
1 answer
50 views

How do I hide or mask the sending address when sending tokens or eth

I am trying to build a crypto payment gateway. But when users initiate a withdrawal to credit their customers, the transaction can be tracked up to the point that shows the system address where the ...
Starbody's user avatar
0 votes
2 answers
27 views

Failing deposit transaction

The following deposit transaction on Mumbai test net is failing as opposed to this transaction on Polygon main net which had succeeded years ago. There are no fundamental differences from code or ...
Pulsares's user avatar
0 votes
1 answer
17 views

How to extract the custom reverted message inside the transaction object when we're using solidity error keyword?

// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.4; error Unauthorized(); contract VendingMachine { address payable owner = payable(msg.sender); function withdraw() public { ...
0xbeny's user avatar
  • 153
0 votes
2 answers
50 views

eth_call vs eth_sendTransaction

During my development process, I've spotted differences between calling function in my contract from script and from dApp. Whole thing is done on hardhat local network. Script call: eth_call ...
Lidjan's user avatar
  • 11
0 votes
1 answer
19 views

are there other ways to send bundle of transactions without using flashbot?

I am wondering if there are some ways to send bundle of transactions without using flashbot? I am not sure how this area works, would you please give me practical sources to learn ?
DHC's user avatar
  • 199
0 votes
0 answers
9 views

org.web3j.protocol.exceptions.TransactionException: Transaction receipt was not generated after 600 seconds

Yesterday I could deploy the code successfully, but today onwards I am facing the below error. I tried to reduce/increase the gas fees yet the error is still not resolved. If anyone is willing to ...
Selva Kumar's user avatar
0 votes
0 answers
24 views

Sending data to the contract from the react frontend is not working

I've made an twitter contract, where we can send and get tweets from the frontend React. While sending the data to the contract, The metamask popup is opening, But it shows warning like this. I don't ...
Santhosh's user avatar
0 votes
1 answer
17 views

Tick range of negative tick - Uniswap v3

I am looking for a formula to calculate the tick range for a negative tick. Ex1: tick: -15 tickSpacing: 10 range: [-20, -10) Ex2: tick: -20 tickSpacing: 10 range: [-20, -10) I was ...
KunLun's user avatar
  • 197
0 votes
1 answer
21 views

Getting Error in the code ParserError: Function, variable, struct or modifier declaration expected

pragma solidity >= 0.8.2 <0.9.0; contract Types {  // Declaring a dynamic array uint[] data;  uint8 j = 0; function loop() public returns(uint[] memory){ while(j < 5) { j++; data.push(j); } ...
Moody's user avatar
  • 111
0 votes
1 answer
22 views

Signing message using web3 and using ethers gives different result. Why?

I'm encoding a message using ethers' solidityPackedKeccak256() const encodedMessage = ethers.solidityPackedKeccak256( ["address", "uint256", "uint256"], ...
ujjwalvinze's user avatar
0 votes
1 answer
28 views

UniswapV3 Quoter throws error: contract runner does not support sending transactions (operation="sendTransaction", code=UNSUPPORTED_OPERATION)

I am working with the Quoter from Uniswap V3, here is the part of the function that challenges me: ... // Reformat Amount In if (!isNaN(amtIn)) {amtIn = amtIn.toString()} let amountIn = ethers....
Christopherus's user avatar
0 votes
1 answer
35 views

ERC721: invalid token ID"

I'm minting an NFT and listed it on my NFTMarketplace, after minting I keep getting ERC721: invalid token ID, whenever I try to create the sale on the market place. this is my nft code // SPDX-...
Santos's user avatar
  • 17
1 vote
1 answer
101 views

Where to place special functions receive() & fallback()?

receive() external payable { fund(); } fallback() external payable { fund(); I want to find out where exactly should these special functions be wrriten; should they come before the contract ...
progress Ibrahim's user avatar
0 votes
0 answers
12 views

Is it possible to import foundry anvil in rust?

I successfully installed and used anvil from the wsl shell. I have some rust code, where i want to import foundry anvil instead of running from shell, cause i want to be able to control it from the ...
Sherlock zaguero's user avatar
2 votes
1 answer
69 views

Where in the code of this unstake function is ETH actually transferred?

I am looking at this repo, which is contracts for a decentralized pegged asset issuance system backed by liquid staking tokens like rETH. Specifically, I have a question about the functions unstake in ...
auditor_chick's user avatar
0 votes
1 answer
23 views

I need to use ‘selfdestruct’,How to prevent the implementation of eip-4758?

I found a very useful idea compared to the traditional deposit method on exchanges. Using this method, not only does it not need to manage secret keys, any account can perform token collection, but it ...
詹文杰's user avatar
0 votes
1 answer
15 views

Unable to change the storage using Delegate call

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Preservation { // public library contracts address public timeZone1Library; address public timeZone2Library; address public ...
kumar's user avatar
  • 3
0 votes
1 answer
12 views

How to change the storage using Delegate call

// SPDX-License-Identifier: MIT pragma solidity ^0.8.0; contract Preservation { // public library contracts address public timeZone1Library; address public timeZone2Library; address public ...
kumar's user avatar
  • 3
0 votes
0 answers
17 views

Treating two assets as equal in a smart contract that aren't equal

I am auditing a protocol that creates a token yETH representing a basket of liquid staking tokens such as rETH and stETH. I noticed that the protocol treats yETH as if it is 1:1 with ETH when it's ...
auditor_chick's user avatar
0 votes
1 answer
20 views

Batch NFT mining

I am trying to create a project where users can specify a total supply on a minted NFT, will the NFT all have the same address but with different tokenId's or they will have different addresses
Santos's user avatar
  • 17
0 votes
1 answer
17 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 ...
CaioBonani's user avatar
0 votes
1 answer
9 views

How the uint changes to address type in solidity when using delegatecall?

pragma solidity ^0.8.18; contract One{ address public first; address public second; address public third; function setaddress(address _address)public { third = _address; }...
kumar's user avatar
  • 3
0 votes
1 answer
12 views

Create a new Erc20 contract through Ether.js

I've a functionality in my nextJs application to create an ERC20 token on a fly. Like user can input a contract name and symbol, and behind the scene through the Ether.js a new contract gets created ...
Saad Suri's user avatar
0 votes
1 answer
18 views

Can you refer to a contract inside itself?

Sorry this is a very minor question but the following is part of a contract called LibOrders.sol. The function below calls LibOrders.cancelOrder....normally I think you would just put "...
auditor_chick's user avatar
0 votes
1 answer
20 views

Can I edit in the msg.sender value for the called contract?

let's assume following solidity contracts: contract EntryPointContract { address one = '0x...'; address two = '0x...'; address delegateContract; constructor(address ...
Jaroslaw Piatek's user avatar

1
2 3 4 5
346