Questions tagged [solidity-0.8.x]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
0 answers
15 views

ABDKMath64x64 function works in local brownie tests and remix kovan deployment, but transaction reverts when trying it on kovan testnet

Me and my team are quite dumbfounded by this issue we have with one of the utility functions we wrote in our contract that make use of the ABDK64x64 library, the code of which can be found below: In ...
user avatar
  • 1
0 votes
0 answers
4 views

Upgrade a contract mapping struct

I have an upgradable contract (openzeppelin): contract MyContract is OwnableUpgradeable { ... struct MyStruct { uint a; uint b; } ... mapping(address => ...
user avatar
0 votes
1 answer
16 views

How to spend a specific amount of ether and send it to the smart contract (from msg sender)?

i am able to send eth (with a payable function ) to the my contract but what i really need is that when the user interact with the contract it takes a specific amount on the msg sender and add it to ...
user avatar
  • 5
0 votes
0 answers
22 views

"Error": "Failed to decode output: Error: data out-of-bounds

I've got this strange error in Solidity's Remix: "error": "Failed to decode output: Error: data out-of-bounds (length=36, offset=64, code=BUFFER_OVERRUN, version=abi/5.5.0)" It ...
user avatar
  • 101
0 votes
0 answers
9 views

Smart contract compile with empty bytecode when using Interface

Given Solidity ^0.8.13 file X.sol, contains an interface of contract Y and contract X // SPDX-License-Identifier: MIT pragma solidity ^0.8.13; interface YI{ // This is the interface of contract Y ...
user avatar
  • 101
0 votes
0 answers
80 views

I deployed an contract , have total supply but no token holder

// SPDX-License-Identifier: GPL-3.0 pragma solidity ^0.8.12; library SafeMath { function mul(uint256 a, uint256 b) internal pure returns (uint256) { if (a == 0) { return 0; ...
user avatar
0 votes
2 answers
25 views

Why am I NOT able to interact with ALL of my smart contract functions via my HTML GUI?

I have noticed something very strange... I have a smart contract with two functions. I am able to interact with all of them (In Remix, Web3 Provider Environment, pragma solidity ^0.8.2) perfectly well....
user avatar
  • 107
0 votes
0 answers
10 views

NFT lending protocol , repay function reverts second time it is used

So, I am writing this contract wherein you can collateralize your NFT asset for usdc and after you repay, you can get your assets back. The borrow function is as under , which is running fine: // ...
user avatar
1 vote
1 answer
13 views

Solhint: Why should I avoid multiple calls of "send" in a single transaction?

function withdrawAll() public payable onlyOwner { uint256 _each = address(this).balance / 4; require(payable(t1).send(_each), "Account is being paid out"); require(payable(t2)....
user avatar
0 votes
0 answers
44 views

Solidity: Transfer token including tax and sell tokens function

When sending tokens, a tax is applied and that tax is sent to the smartcontract address. I want to immediately execute a command to swap the tax amount for ETH(native). Can someone help me with a ...
user avatar
  • 1
1 vote
1 answer
59 views

How to write an unchecked for loop?

I would like to write a for loop like this: for (uint256 i = 0; i < length; unchecked { i += 1 }) { // ... } But unfortunately this does not compile (fails with an error "expected primary ...
user avatar
0 votes
0 answers
16 views

Unable to understand solidity code

I was confused how this smart contract is sending requested loan amount back to this smart contract again by calling flashLoan. Reference this challange of Damn VUlnerable HERE // SPDX-License-...
user avatar
0 votes
0 answers
13 views

Why a transaction function that modifies array state variable returns an invalid length (NaN) back in JS?

I want to know why a function I made that .push an element in the array then immediately followed by return the .length would result in a NaN back in JavaScript (truffle test)? Originally, I intended ...
user avatar
0 votes
0 answers
20 views

How to call a function `foo(string calldata str[])` from another contract on-chain

Is there is a way to call a function foo(string calldata str[]) from on-chain? My understanding of calldata is that is it a read-only datatype and intended to be used with data received from a ...
user avatar
  • 103
0 votes
1 answer
23 views

Declaration error identifier not found or not unique , can someone help

pragma solidity ^0.8.4; import '@openzeppelin/contracts/token/ERC721/IERC721.sol'; import '@openzeppelin/contracts/access/Ownable.sol'; contract NewMintContract is ERC721, Ownable { uint256 ...
user avatar
0 votes
1 answer
15 views

broken for loop

can someone let me know what i got wrong in this for loop, if you need the full code let me know. function calculateSplitPercent() public { for(uint256 i = 0; i >= uniqueIdCounter; i++) { ...
user avatar
0 votes
0 answers
22 views

Need help with buy and sell fee for erc20 contract

I've been looking into making my own token but I got stuck on implementing the buy and sell fees that's why I am here on stack exchange for help. the code I have at the moment should be okay but I'm ...
user avatar
0 votes
2 answers
42 views

Implementing Luhn's Algo in Solidity?

Is it possible (I believe so, especially with strings.lib) to implement Luhn's Algorithm (the math function that confirms all 16 digits of a credit card are valid) in a solidity function without ...
user avatar
  • 473
0 votes
1 answer
83 views

Storage, Memory and Calldata

1- Why is it only memory when using Value Types as parameters in functions? For example, would it be absurd to set it as calldata? 2- When we define state variables, they are stored in storage. Why ...
user avatar
0 votes
1 answer
32 views

0x Protocol - Can I use for selling an NFT and get back an ERC-20 token example BUSD on BSC?

I'm using 0x Protocol for my project. And I want to use BUSD as asset that taker must pay to maker. In 0x's document describes we can use native token BNB or WBNB, but not clear about if we can use ...
user avatar
0 votes
1 answer
17 views

tell me why encodePacked not working

pragma solidity 0.8.13; contract A { function callBFunction( address _address) public returns (bool) { bytes4 sig = bytes4(keccak256("bFunction()")); (bool success,) = ...
user avatar
0 votes
0 answers
36 views

solidity smart contract problem

hey guys I'm stick in my project I have 2 problem in this project I need that how join in this project pay 100 usdt and my site pay 30 usdt for 3 peopel that before this guy invite him. For example I ...
user avatar
0 votes
1 answer
25 views

>= won't work correctly

contract MyIfElse { uint256 public revealState = 0; bool public isNowRevealed = false; function addToRevealState () private { revealState++; } function isRevealed () ...
user avatar
  • 107
1 vote
1 answer
97 views

Catching custom error

I want to catch a custom defined error in my Foundry tests. Before I was using require and the following code worked: try pathRegistry.swap(WETH, LUSD, amountIn, type(uint256).max) { ...
user avatar
0 votes
1 answer
62 views

How to transfer ERC1155 data(Ownership) mapping from one smart contract to another?

I am developing an NFT Marketplace where I am distributing free NFTs(out of 3 defined categories, Diamond,Gold,Silver). I have developed a dropsite smart contract for this distribution. The dropsite ...
user avatar
0 votes
1 answer
157 views

Error: VM Exception while processing transaction: reverted with panic code 0x32 (Array accessed at an out-of-bounds or negative index)

In the process of updating sushiswap contracts to solidity 8 I run into this issue while running this test accompanied by this contract. Here is the error in full: Set Should revert if ...
user avatar
  • 1
0 votes
1 answer
28 views

Difference between a state array initialized using literlas and another state array initialized using the "new" operator?

What is the difference between arr_0 and arr_1 Both are initialized to have 4 items (all initialized to zero). Both seem to support push and pop operations as well contract Test { uint8[] ...
user avatar
0 votes
0 answers
25 views

Arithmetic operation underflowed or overflowed outside of an unchecked block - Sushiswap Fork [duplicate]

I am working with this user: Arithmetic Overflow Error to fork sushiswap and update the contracts to solidity 8. I am running into some overflow/underflow errors when running my tests. I have resolved ...
user avatar
  • 1
0 votes
0 answers
108 views

Arithmetic Overflow Error

We're forking and updating sushiswap contracts. Right now, I'm trying to correct an overflow arithmetic error in the Masterchef Contract. We have tried using an uncheck{...} in the following function ...
user avatar
0 votes
1 answer
28 views

What does `_inner` mean in a Struct?

I was looking at the EnumerableSet.sol contract from OpenZeppelin and I saw this: struct Bytes32Set { Set _inner; } What does _inner mean? Is it a copy of the following? struct Set { // ...
user avatar
0 votes
0 answers
21 views

Convert string into uint256 [duplicate]

Can anyone explain how can we convert a string type value in solidity ^0.8.12 into uint256? An example will be appreciated.
user avatar
  • 1
0 votes
0 answers
99 views

Solidity transaction "reverted" when contract is called by another contract

This deposit function works perfectly. However, when I attempt to call this function from another contract (through an interface), it does all the right transactions, but then reverts at the end, ...
user avatar
  • 53
0 votes
1 answer
131 views

Error from brownie compile with IERC721.sol

I am getting an error from brownie compile and I can't figure out why it wont import one of the openzeppelin contracts when all the others import ok. here is my brownie-config.yaml # https://eth-...
user avatar
  • 1
0 votes
0 answers
42 views

Struct containing a nested mapping cannot be constructed

I am getting the following error (See Screenshot) regarding this fetchFlightStatus in my smart contract function below (using solidity ^0.8.0). It says.... "Struct containing a (nested) mapping ...
user avatar
0 votes
0 answers
15 views

Forcibly Remove Governance Tokens

In the event of a bad actor in a DAO, is it possible to forcibly remove governance tokens? Specifically, I'm looking to remove governance tokens if a critical action (eg insurance payout) is not ...
user avatar
0 votes
1 answer
171 views

call setApprovalForAll of ERC721 contract from other contract fail

I'm trying to call from MyContract the setApprovalForAll of some ERC721 contract. When user call approveTransfer in my contract, the transaction is fail with "code": -32603, "message&...
user avatar
  • 3
0 votes
0 answers
27 views

How to interact with a deployed smart contract using the etherscan API key

I want to interact with a deployed smart contract on etherscan.io using the ABI and I'm wondering how can make a fetch call in my code editor to get the ABI, use that ABI to create an instance of that ...
user avatar
  • 169
0 votes
1 answer
31 views

Avoid Duplicate Addresses in Array

address[] public players; mapping(address => bool) private activePlayers; I want to avoid duplicate players to enter in players array, so i want to understand if i create a such mapping with ...
user avatar
0 votes
0 answers
29 views

Unable to assign dynamic array to Struct field

I have a struct where a field (whitelist) is a dynamic array of addresses: struct Project { string name; address[] whitelist; } mapping(uint => Project) public projects; function setProject(...
user avatar
  • 133
0 votes
1 answer
50 views

contract execution failed for already deployed ERC20 contract in Rinkeby

I am newbie to the smart contract development & have developed a smart contract that can transfer ERC20 tokens to multiple addresses in single transaction. I test it by creating new Tokens & ...
user avatar
0 votes
0 answers
49 views

How to improve the precision of calculation

I have to compute percentages in solidity but I encounter rounding errors. I did some experimentation and I was surprised that these two expressions did not yield the same result 1e21 * 1e18 / 1005 / ...
user avatar
  • 1,931
0 votes
0 answers
30 views

How do I access a smart contracts method that is **msg.sender** sensitive?

I successfully deployed a smart contract via the Remix Web3 Provider Environment. My deployed contract has two public view methods of interest, namely the: viewAllGifts() method, and the viewMyGifts() ...
user avatar
  • 107
0 votes
1 answer
248 views

Convert contract ETH to WETH via function call

I'm attempting to write a simple solidity contract that can: receive ETH convert ETH to WETH display ETH balance display WETH balance ETH operations appear to work as expected however whenever I try ...
user avatar
  • 3
0 votes
1 answer
112 views

0x api - swapping ERC20 with ETH/WETH fails on Ropsten

Currently using IDENTICAL example from 0x starter guide. Steps taken deployed contract onto ropsten network Deposited test eth to the smart contract. Then tried swapping to some ERC20's successfully:...
user avatar
  • 101
0 votes
0 answers
153 views

Using UniSwap to swap WETH for DAI on ethereum rinkeby 'execution reverted: AS'

Using the boilerplate code on Uniswap website to swap WETH for DAI. Contract calling this function has WETH and sets: _amountIn = IERC20(_asset).balanceOf(address(this)): and passes this into function ...
user avatar
  • 1
0 votes
2 answers
276 views

Call A Smart Contract Function With Another Deployed Smart Contract Address As "msg.sender " From Hardhat Test

I have The Following Function in my Smart Contract function functionName(uint256 param1, address param2) external override { require(msg.sender == marketContract, "...
user avatar
0 votes
0 answers
46 views

How to remove the last element of a string in Solidity

I am trying to get better at strings and bytes manipulation. But the general lack of built-in functions is making my life much harder than it should. Basically, I tried to write a solidity function ...
user avatar
  • 530
0 votes
0 answers
29 views

^0.8.0 BUG: Updating balance with uint64(msg.value) past uint64 ether storing capacity causes a loss

The issue: If you deposit lets say 20 ether right off the bat the program with accept the transaction and not consider the fact that its actually storing much less than those 20 ethers. Here's an ...
user avatar
  • 1
0 votes
1 answer
274 views

Type struct storage ref[] ref is not implicitly convertible to expected type struct memory

In my function, while using my mapping to reference to an array, I keep getting the error message below: TypeError: Type struct etherGifter.CryptoGift storage ref[] storage ref is not implicitly ...
user avatar
  • 107
1 vote
0 answers
30 views

Compiler error when calling a function that returns a 12-member tuple

I'm importing an interface from @uniswap/v3-periphery—specifically, the INonfungiblePositionManager interface—and I'm attempting to call the positions function from my contract. This function returns ...
user avatar
  • 308