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

Safely converting 1 WEI to the current ETH/USD Chainlink price

Let c be the current floating point price of ETH/USD precise to 8 decimal places. Since Solidity cannot store floating points, getting the current price of ETH/USD from Chainlink's data feed returns c ...
nostonksafrica's user avatar
0 votes
0 answers
3 views

SignTypedData in ethers version 6.9.0

Does anyone know how to perform signTypedData in ethers version 6.9.0 . I am tryin to do this but it reverts with this function doesnt exist . I am trying to create a signer usin g JavaScript ...
Jaskaran Singh's user avatar
0 votes
1 answer
22 views

How to decode storage value of a struct

On Uniswap V3 Pool contract, we have slot0 struct which is located on slot 0 of the storage struct Slot0 { // the current price uint160 sqrtPriceX96; // the current tick ...
Billy Adelphia's user avatar
0 votes
2 answers
16 views

Solidity array not updating correctly

My contract has structs for products, companies etc. The product struct has a 'quant' var to store quantity of the product ordered, and an array of quant size called clicks, that's supposed to track ...
Anushka.N12's user avatar
0 votes
0 answers
5 views

Foundry Test for a function with array of structs

I have this foundry function and I don't have any idea how to pass an array of structs to batchList function function test_ListMockERC721() public { vm.prank(add1); erc721Mock.mint(msg.sender);...
Catalin's user avatar
  • 389
0 votes
1 answer
8 views

What does decimals/fungible token normalization mean? I need help with mitigating precision loss

What is the code to convert them to correct decimals without precision loss?Does it mean that you should make all the token decimals to a certain standard of the protocol? Let say 18? If Token A is 16 ...
anonauditor's user avatar
0 votes
0 answers
14 views

Geth still stucking at synchronizing

I trying to run my eth mainnet node using Geth and prysm but synchronizing process still stucking. Error: INFO [12-05|02:29:14.015] Syncing: state download in progress synced=0.36% state=961....
Xardesso's user avatar
0 votes
1 answer
9 views

Can Chainlink time-based upkeep register multiple cron jobs in a single contract?

I have been trying to make a raffle platform with the Chainlink automation. I can see the time-based upkeep can have only one cron job, But when the raffles are created in the platform, each of them ...
DHC's user avatar
  • 313
1 vote
0 answers
18 views

Is NFT swap possible on cross chains?

I have done a bit of research on this, and I have found only the same chain NFT swap but I want to know the different chain swapping b/w two users, Please provide some links or guidance to achieve NFT ...
Vinit_2311's user avatar
0 votes
1 answer
8 views

Im trying to build a cryptocurrency(USD tether just like USD) that works with ethereum and polygon,

I happen to be relatively new to block chain, have an understanding of PoW and PoS, I'm learning Solidity at the moment, I'm supposed to design thi cryptocurrency that is compatible with ethereum and ...
Irum 's user avatar
0 votes
0 answers
4 views

Not able to fetch correct APY in aave mumbai

I am following this doc - APY and APR - Developers to fetch lending and borrowing rates in mumbai for usdc but they doesn’t seem to be correct and are different from aave staging UI, how can I solve ...
Varun Sharma's user avatar
0 votes
1 answer
22 views

Solidity - Function Selector Loading onto the stack: why DIV instead of SHR?

I'm currently learning about how the function selector is loaded from calldata. The algorithm is like so: PUSH4 ffffffff PUSH29 0100000000000000000000000000000000000000000000000000000000000000 PUSH1 ...
riordant's user avatar
0 votes
1 answer
10 views

Foundry console.log and emit logs not working!

Running forge test -vv does not show the logs, but only test passed. Only forge test -vvvv `shows the traces, which shows the logs. pragma solidity 0.8.20; contract Testing is Test { function ...
anonauditor's user avatar
0 votes
1 answer
9 views

Calling Uniswap Multihop Function returns Error

Deployed on Polygon Mumbai. Code compiles fine on REMIX and is meant to perform multihop swaps on Polygon Mumbai, but it returns error after function is called. Deployed Contract always funded with ...
Samuel Aniss's user avatar
0 votes
1 answer
17 views

Adding Uniswap interface to a ERC20 token smart contract

I just started learning Solidity, as browse through various smart contracts for tokens listen on Uniswap, I notice that most of them use IUniswapV2Factory and IUniswapV2Router02 and a small amount don'...
dbykv234's user avatar
0 votes
0 answers
10 views

Cannot import correctly uniswap's permit2

Hello i am trying to import the permit2 following the official uniswap's guide but i cannot manage to import it correctly since it lacks of the structs and more things even if i don't get any error ...
user19288852's user avatar
0 votes
0 answers
11 views

USdt ERC20 1006

I am confused about this "Usdt erc20 1006" . In a website for withdrawal it is written "your Usdt Erc20 1006".. This is certainly address but which type of address is this.
Malik's user avatar
  • 1
0 votes
0 answers
12 views

ERC20 Multisend works on Sepolia Testnet but Fails on Mainnet

I've got a smart contract function that takes an erc20 contract address, an array of addresses and an array of amounts and then sends the each amount to each address of the specified token. I've got ...
nultinator's user avatar
0 votes
1 answer
20 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 ...
solidity-dev's user avatar
0 votes
0 answers
14 views

Brownie Request for Random number (Mock VRF) reverts

Using chainlink tutorial and concept for testing a random request locally, Request Randomness fails to execute in brownie for VRFCoordinatorV2Mock, however, I tested the same code in remix IDE and it ...
Obanla Andrew's user avatar
0 votes
0 answers
9 views

Solidity assembly: `target_slot`. Is it an opcode or other stuff?

I found this strange variable or opcode in inline assembly, but I'm not sure: target_ slot. I couldn't find its definition in the contract. I prefer it to be an opcode, but I didn't seem to find it ...
LEVI_104's user avatar
0 votes
2 answers
39 views

How to Import OpenZeppelin Contracts with Node.js Environment

I'm having an issue. I'm attempting to compile my contract with Node.js inside of a VSCode terminal, but my openzeppelin imports aren't being seen, and I'm not sure how to handle them with Node.js. ...
user185543's user avatar
0 votes
1 answer
33 views

Rebasing tokenomics

I have the following variables where all values are multiplied by 1e18 to represent fixed-point numbers on the EVM: uint totalShares = 100; uint sharesAlice = 20; uint sharesBob = 30; uint ...
dNyrM's user avatar
  • 713
1 vote
1 answer
14 views

How works refund ReentrancyGuard library for solidity

When I was reading the library code, I came across the following comment: "the values being non-zero value makes deployment a bit more expensive, but in exchange the refund on every call to ...
TabFoxOne's user avatar
0 votes
1 answer
16 views

Creating a token for my personal dapp use only

I want to store the money in a smart contract from my user as long the user wants and pay back the user once he asks i will not charge for this service if I store ether in it and the value of Ethereum ...
Nishant Dhamija's user avatar
0 votes
1 answer
17 views

GoFundMe Contract: Minting "Thanks" over time vs all at once & "Thanks" token value

I was assigned to write a smart contract for class (to be deployed on a test-net), which, upon receiving ETH, returns to the sender some amount of tokens with symbol "Thanks". I want this ...
Alex Byard's user avatar
0 votes
1 answer
40 views

What's the cheapest way to store a large amount of data into a smart contract?

I'm working on a smart contract in which we need to store some addresses along with their pending rewards periodically, so the most first approach is to have a mapping of addresses to an int, like ...
S Arv's user avatar
  • 11
1 vote
0 answers
25 views

Foundry or Hardhat: I'm really confused about which one should I use?

Hello everyone I'm new in the smart contract and Dapp development and I'm so confused about choosing a framework. my questions are dumb but I couldn't find the answers by myself. Here is my problem: I ...
emtothed's user avatar
0 votes
1 answer
10 views

Staking pool for native coins

I wanna build a staking pool for native coins like trx to test my skills as an engineer and yet due to my limited knowledge I don't know how to make a staking platform without creating a new token. Is ...
Sina Blank's user avatar
0 votes
0 answers
14 views

Verify signature from dApp on contract

I am creating a signed message using a user address, nonce and number (amount of eth to send) like this: const ammount = 1; const userAddr = await otherAccount.address const nonce = ...
Jesse Jacob's user avatar
1 vote
1 answer
26 views

How can a bytes32[] variable have a custom method (i.e., verifyCalldata)?

Code: https://www.contractreader.io/contract/mainnet/0x0C7D4bdA40CF78F9F1BAf6e3D5774f1E22c9CC4B My question is about this verifyCalldata() call: function verifyAddress( uint256 _projectId, ...
Donn Lee's user avatar
  • 113
0 votes
1 answer
30 views

removeLiquidity function in a smart contract, getting execution reverted due to ds-math-sub-underflow

i'm trying to create a smart contract which removes user's lp share from the pool doing these steps: calculates the current user's balance of LP tokens for a particular pair removes their liquidity ...
Ivan's user avatar
  • 129
0 votes
1 answer
12 views

What is the reason for this assembly code?

I am looking at the following contract, specifically the following assembly code....I think I decoded that it means make sure that if the contents of slot 0 equals 2, then store 3980109478 (which is ...
user127148's user avatar
0 votes
1 answer
15 views

What is the purpose of the import statement in Solidity?

Could someone explain to me what the pupose of the import statement is, in Solidity? Is it the similar to inheriting from another contract where you have access to the state variables and function of ...
davidastro's user avatar
0 votes
1 answer
11 views

Chainlink fulfillRequest is not able to call another contract

I am working on a project that includes Chainlink Functions (for off-chain API calls) and CCIP (to transfer tokens cross-chain). My project includes 3 main contracts: FunctionConsumer.sol: Chainlink ...
Rishabh Raghwendra's user avatar
0 votes
1 answer
18 views

gas estimation error because of reverted

here is a situation I have: a user came to my platform to buy mytoken and he paid 44 matic for it and 266,087 | 263,663 (99.09%) which reverted because of the gas out. is there any solution to add gas ...
Helia Marami's user avatar
0 votes
1 answer
18 views

Are multiplications after division UNSAFE?

I have a smart contract which essentially does this: uint256 tokenRate = _pair.a2 * PRECISION_FACTOR / _pair.a1; uint256 toSend = _amount * tokenRate / PRECISION_FACTOR; uint256 feeToOwner2 = toSend ...
Iulian's user avatar
  • 640
0 votes
1 answer
14 views

How can I get a defi site source code?

I'm trying to expose a defi scam website which copycats a famous platform on TRX blockchain. I have their transaction address, but no source code or website's contract address. I was wondering if ...
Sina Blank's user avatar
2 votes
1 answer
28 views

Assembly 'create2' and 'new' with salt not determining the same address

Since solidity 0.8.0, we can now specify the salt for contract creation using new keyword Using 'new' bytes32 _salt = bytes32("0x4"); address addr = address(new DummyContract{salt: _salt}());...
Xirexor's user avatar
  • 127
0 votes
0 answers
12 views

Why are you able to swap eth to token lesser than specified amount in amountOutMinimum?

I am using Dai as an example for token address in constructor so when you call this function it should swap ether to Dai. My question is why sending ether lesser than amountOutMinimum. It still able ...
anonauditor's user avatar
0 votes
0 answers
29 views

Swap functions seems to not swap?

I have deployed a smart contract on a local network and I am trying to do swaps from a metamask account. I have allocated a quantity of tokens to the smart contract so it can use it using the approve ...
guiflam's user avatar
0 votes
1 answer
20 views

Whats in the mempool? Was wondering if there are listed properties that anyone can view it

If you send a transaction and it is in the mempool, what are the properties in the transaction of the memool? I was wondering if you can get the address of the sender in the mempool. What else can be ...
anonauditor's user avatar
0 votes
1 answer
14 views

Inline assembly loop doesn't update memory

I want to copy in inline assembly from calldata the last two bytes of every 32 byte slices to the lower half of the first free memory slot(32 bytes). free = free memory pointer + 14 (bytes) moffset = ...
Igor József Vass's user avatar
1 vote
2 answers
75 views

Trying to create a soulbound token. Keep getting two errors

I'm trying to create a soulbound (non-transferable NFT) token on Solidity. Here is my code so far. // SPDX-License-Identifier: MIT pragma solidity >=0.4.17 <0.9.0; import "@openzeppelin/...
NFTSamurai's user avatar
0 votes
1 answer
16 views

How can I fetch the current dollar price of BNB in a Solidity smart contract?

How can I fetch the current dollar price of BNB in a Solidity smart contract? Are there any recommended APIs or secure, decentralized methodologies for this?Is there a way to fetch the dollar price ...
Nishant Patil's user avatar
0 votes
1 answer
10 views

How do you deal with relative imports in a contract you depend on?

Goal I am attempting to create a smart contract that uses contracts from the iden3 library. I am using the Remix IDE. Problem My issue is that the contract I need (IdentityBase.sol) has several ...
Code on the Rocks's user avatar
1 vote
0 answers
22 views

How to I solve fetch has been blocked by CORS policy when fetch data from contract

I'm trying to fetch campaign data and display it to the user. I'm using Nextjs in the front-end and solidity & hardhat in the back-end. The contract data seems to be fetched but when being ...
Kihiu's user avatar
  • 11
0 votes
1 answer
23 views

Bought a scam token, trying to understand what part of the code should I check next time to prevent that

Contract code - https://etherscan.io/token/0x67bcd18a484a88f073097a18b0462eb7c44d3178#code Ownership renounce at 08:17 UTC https://etherscan.io/tx/...
Dan's user avatar
  • 1
0 votes
1 answer
29 views

Decoding Chainlink Function Response in Solidity Contract and Handling Nested JSON Objects

I'm dealing with a problem regarding the decoding of data obtained from a Chainlink function in my Solidity code. Specifically, I'm using a Chainlink custom function that sends an HTTP GET request to ...
Blaž Perić's user avatar
0 votes
1 answer
16 views

Trying to issue ERC 3475 tokens

I'm trying to issue ERC 3475 tokens from a relatively simple contract using Remix. The contract compiles and deploys when gas is optimized, but when I try to issue the tokens I get an error of "...
Xavier83's user avatar

1
2 3 4 5
349