New answers tagged

0 votes

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

The trick is the using A for B directive at line 59: using MerkleProof for bytes32[]; With that operation, you ask Solidity to consider all the methods it finds in the MerkleProof library, having a ...
Giuseppe Bertone's user avatar
0 votes

Custom V3 router (Is it a Universal router)

I am newby in all of this but maybe this can help you. I am identifying some params using etherscan and the trx data, and making a mapping of the methods used. For example in this one you shared the ...
cryptowyckoffian's user avatar
1 vote

abi-decoder's decodeMethod returns undefined

The problem seems related to how abi-decoder computes the function identifier (the hash of the function signature); in particular, it associates swap function to the 0x899a73f4 ID and not to the ...
Giuseppe Bertone's user avatar
0 votes

Rebasing tokenomics

The reason I asked for the value of n is because it is the only part affecting your code. I tried implementing the same logic and guess what, I found out that when I gave undervalue a value of 1 ether ...
Zartaj Afser's user avatar
  • 2,150
0 votes

Reliably disassamble bytecode to opcodes across various evm versions

For anyone interested. I found an existing package, that allows you to select evm version to use during disassembling: https://github.com/crytic/pyevmasm
Stas Buzuluk's user avatar
0 votes

Create a new Erc20 contract through Ether.js

@Mehran Ra's code doesn't seem to work in my case. Specifically you the provider line didn't work for me. Adjusted the code would look like this: const { ethers } = require('ethers'); const ...
ThinkBonobo's user avatar
0 votes

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

to check if the transaction is initiated by a smart contract, you can use this: require(msg.sender == tx.origin) which makes sure no contract is calling your function. Mintink a token will only ...
Yann's user avatar
  • 11
0 votes

chainlink oracle http get request not returning value - taken from example but still is not working

Did you find the solution? because i am facing the same issue with sepolia testnet i am following this docs but still it returns 0 after i call requestVolumeData() the volume is not updated. https://...
saad ahmed siddiqui's user avatar
0 votes

How to Import OpenZeppelin Contracts with Node.js Environment

What is your folder organisation, and what's your package.json file? Using hardhat is indeed very much recommended.
Yann's user avatar
  • 11
0 votes
Accepted

How to Import OpenZeppelin Contracts with Node.js Environment

That's weird. That's how a million other projects do it successfully. Maybe check your Node version? I also wonder what your compile.js does. Are you using something like Hardhat? If not, I recommend ...
Lauri Peltonen's user avatar
0 votes

Convert String to address in solidity

this is working perfectly for me. How to convert string into address. // SPDX-License-Identifier: MIT pragma solidity ^0.8.7; contract Check { address public pick; function toAddress(string calldata ...
Hashim khan's user avatar
0 votes

How works refund ReentrancyGuard library for solidity

There are certain cases when you get refunds for your gas usage. The exact rules have changed quite many times, but here's an article which is at least decently up-to-date. When writing a smart ...
Lauri Peltonen's user avatar
0 votes

Creating a token for my personal dapp use only

You could use a stablecoin pegged on the Dollar value to do that. Those coins are supposed to have a "fixed" value of 1 Dollar (which actually slightly value around 1 Dollar). You can then ...
Pacdac's user avatar
  • 70
0 votes

I am trying to display image on frontend using pinata and ipfs but facing this error

From the error it sounds like its more related to display(address) but let us know if you need more assistance with the upload part! We have some React examples here as well as an Next.js Template you ...
Steve Simkins's user avatar
0 votes

Staking pool for native coins

Since we're talking about the blockchain's native asset, you can't mint those. So if the staking reward is in the native asset, somebody (probably you) have to be inserting those into the contract. ...
Lauri Peltonen's user avatar
2 votes

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

The problem is that when you want to set/update all these data at once, it will cost a lot of gas to loop through the mapping and update them all. You need to design your smart contract logic in a ...
Mikko Ohtamaa's user avatar
0 votes

Is there a way to getting Remix to run offline?

Hello guys I'm a beginner and trying to learn solidity. However, I'm getting remix compiler issues. The solidity compiler do not compile unless I connect to the internet and I sometimes do not get ...
Etabebe's user avatar
0 votes

Error: factory runner does not support sending transactions DEPLOYMENT

In hardhat.config.js, you should use accounts instead of account require("@nomicfoundation/hardhat-toolbox"); require("dotenv").config(); const { INFURA_API_KEY, ...
flokapi's user avatar
1 vote
Accepted

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

As you mention in your comment, it's likely failing when the router tries to transfer the LP tokens from your contract to the pair contract. In order for this to work, the user must set their own ...
natewelch_'s user avatar
  • 11.9k
0 votes

What is the reason for this assembly code?

The code is incomplete but the revert is returning Reentrant() (0xed3ba6a6). It could be some kind of reentrancy protection.
Ismael's user avatar
  • 31k
1 vote

What is the purpose of the import statement in Solidity?

import allows you to practically include the specified file content in the current file, acting as if all the code is in the same page. It's often used for inheritance or to have access to interfaces ...
Pacdac's user avatar
  • 70
2 votes
Accepted

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

"0x4" is interpreted as a string, so the two salts are different. bytes32("0x4") != 4
0xSanson's user avatar
  • 2,744
0 votes

Chainlink fulfillRequest is not able to call another contract

Chainlink puts a maximum amount of gas that can be spent in the fulfill request function. This link shows its 300000 gas. So I believe your function fails because of that. You should use the fulfill ...
0xSanson's user avatar
  • 2,744
0 votes

Multiple TokenURI URL in one smart contract

It's absolutely possible. My contract does exactly this. 100% Allows the owner to - after deployment - add volumes, and correspond tokens to those volumes, that are then minted cleanly on our dApp (...
Crono1000's user avatar
1 vote
Accepted

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

dev advocate at Chainstack here. The Ethereum mempool, or transaction pool, contains all transactions broadcast to the network but not yet included in a block. Anyone can view the contents of the ...
Dave Dev Advocate Chainstack's user avatar
1 vote

gas estimation error because of reverted

You need to add the necessary gas at the time you create the transaction. It appears that you know in advance how much gas will be needed: 266_087. So you put this value when creating the transaction. ...
Xavier Leprêtre B9lab's user avatar
4 votes

Byte32 Array is not emitted as array from events

You cannot emit an array automatically in an indexed topic unless you manually loop through its values. This is because an array is a reference type, not a value. From the Solidity documentation about ...
Giuseppe Bertone's user avatar
0 votes

How to convert an bytes to address in Solidity?

Here is how I would do this: // Convert 32 hexadecimal digits into 16 bytes. function hexToBytes16 (bytes32 h) internal pure returns (bytes16 b) { unchecked { // Ensure all chars below 128 ...
Mikhail Vladimirov's user avatar
1 vote
Accepted

Are multiplications after division UNSAFE?

Slither has documentation for its detectors that explains the reasoning behind them. For this detector ("Divide before multiply"), the explanation is: Solidity's integer division truncates. ...
ardislu's user avatar
  • 187
1 vote

How can I get a defi site source code?

While it's possible to view transactions and addresses on the Tron blockchain using a block explorer like Tronscan, obtaining the source code or the contract ABI from a transaction address alone is ...
Ari Setiawan's user avatar
0 votes
Accepted

When declaring a variable inside a function, why EVM always pushes 0 before any primitive value onto stack?

ChatGPT: In Solidity, when a variable is declared and initialized inside a function, the EVM initializes it to the assigned value during runtime. The initialization process might involve pushing the ...
Xirexor's user avatar
  • 127
0 votes
Accepted

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

ChatGPT answered my question: Absolutely, your understanding is correct. Solidity's handling of data, especially strings, within calldata and memory follows an optimization strategy to minimize gas ...
Xirexor's user avatar
  • 127
0 votes

What is WETH and why can't we just use ETH?

WETH or wrapped ether is usually used in defi protocols where specific features of ERC-20 standard are needed (such as transfer approval, permit, limit orders, etc). ETH, on the other hand, is the ...
Ehsan Khodarahmi's user avatar
0 votes

Inline assembly loop doesn't update memory

While i was editing my question i realized: I just need to set the offset for calldata's reading point first to 34 outside the loop, then in every loop i must add 32 to it. outside: let loffset:= 34 ...
Igor József Vass's user avatar
0 votes

Trying to create a soulbound token. Keep getting two errors

If OpenZeppelin Version V4. // SPDX-License-Identifier: MIT pragma solidity >=0.4.17 <0.9.0; import "@openzeppelin/contracts/token/ERC721/ERC721.sol"; contract SoulboundToken is ...
EthanOK's user avatar
  • 391
1 vote

Trying to create a soulbound token. Keep getting two errors

Seems like you are using version 5 of OZ contracts. In version 5 they have removed the _beforeTokenTransfer and _afterTokenTransfer functions. And introduced a new single function, _update. Now you ...
Zartaj Afser's user avatar
  • 2,150
0 votes
Accepted

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

Chainlink Data Feeds provide a secure, reliable, and decentralized source of off-chain data to power unique smart contract use cases for DeFi and beyond. Use Chainlink: https://data.chain.link/bsc/...
EthanOK's user avatar
  • 391
0 votes

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

This turned out to be unrelated to the relative imports. The issue was that the first import in my list (openzeppelin) was using the wrong compiler version. I changed this: import "@openzeppelin/...
Code on the Rocks's user avatar
0 votes
Accepted

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

As per the docs currently whilst in beta only certain data types can be returned and they must be encoded into bytes before being sent on chain. In general it is not advisable to try and send a JSON ...
ZeusLawyer's user avatar
0 votes

ImportError: cannot import name 'MockV3Aggregator' from 'brownie'

This section of the Solidity course from FreeCodeCamp explains how to add the Mock contract to a test folder inside your contracts folder. Steps: Create test folder in contracts folder Create a new ...
Code on the Rocks's user avatar
0 votes

Use cases of UUPS proxies over Transparent?

Pros and Cons of both solutions UUPS deployment is cheaper. Upgradeability mechanism logic (code) is written in the implementation/logic contract, so less code on the Proxy side. Valuable when ...
Rosen Santev's user avatar
0 votes

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

The code of every ERC20 token looks almost the same. You can not determine fake tokens with code. Anyone can make token and pools. pools are used to put some value of ERC20 tokens. If peoples trust ...
aakash4dev's user avatar
0 votes

why imported link is error although link is already exist in vs code editor?

Brownie Solution You need to update your brownie-config.yaml file to include the dependency you need (in this case, the chainlink contracts). dependencies: # - <organization/repo>@<version&...
Code on the Rocks's user avatar
0 votes

Trying to issue ERC 3475 tokens

You need square brackets for the array and for the Transaction struct. See image.
0xSanson's user avatar
  • 2,744
2 votes
Accepted

Invalid implicit conversion from enum to enum

Yes I have encountered this before.The enum CoinType is defined in Interface.sol, but is Interface.sol being imported in any of ZRC20.sol or SystemContractMock.sol? . Becuase if it is then compiler ...
Siddharth Bhoite's user avatar
0 votes

"Failed to decode output: Error: hex data is odd-length (argument=\"value\", value=\"0x0\", code=INVALID_ARGUMENT, version=bytes/5.7.0)"

I was seeing this error when testing out the Chainlink VRF demo contract (specifically when calling the rollDice method). My issue was that I had not added the contract address as an approved consumer ...
Code on the Rocks's user avatar
0 votes

Solidity - How do I generate a random address

goodvibration's code snippet doesn't work as of v0.8.13. Here is code that will compile. Note: This address is NOT random address addr = address(bytes20(keccak256(abi.encode(block.timestamp))));
NNNComplex's user avatar
2 votes

How do old smart contracts that contain certain opcodes behave when those opcodes get deprecated/removed in hard fork upgrades?

A contract that uses an opcode that is subsequently removed would no longer be working (its behavior would be unspecifiable). However, to my knowledge, no opcode has ever been removed from Ethereum. ...
Paul Razvan Berg's user avatar
1 vote
Accepted

How to pass blockNumber to viem call?

dev advocate at Chainstack here. You are on the right track. The missing trie node error you are getting means that you are trying to request the state from blocks that have been pruned; in simpler ...
Dave Dev Advocate Chainstack's user avatar
0 votes

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

fxed it. was copy-n-pasting from the example. it was the () instance.retrieve().call(); should be instance.retrieve.call();
Chris's user avatar
  • 101

Top 50 recent answers are included