Questions tagged [solidity-0.8.x]

The tag has no usage guidance.

Filter by
Sorted by
Tagged with
0 votes
1 answer
34 views

How To Withdraw From A Smart Contract

I have a smart contract with the below method: function send(address payable _to) public payable isOwner{ (bool sent, bytes memory data) = _to.call{value: msg.value}("");...
amelongo's user avatar
0 votes
1 answer
32 views

quoteExactInputSingle is returning error

I'm working on solidity code that uses pancakeswapV3 quoter contract to call quoteExactInputSingle. Here is the code snippet function AnalyseTnx(address tokenPath0,address tokenPath1,uint256 amtIn)...
Biruk Damte's user avatar
1 vote
0 answers
20 views

Calling Mint And Change Balance From Another Smart Contract

My Project is about a Token in which the Holder can disable their token at the Old Address and Receive a New Minted token. It uses 2 different contacts. I put the functions in the BBB contract and ...
Suka Kasu's user avatar
1 vote
2 answers
31 views

Optimizing Gas Costs and Replacing For Loops in Solidity Function with Large Dataset

I have a Solidity smart contract with a function drawLottery that processes a large dataset of potentially 1 million tickets. The function contains several for loops for iterating through the tickets ...
PraveenMatheesha's user avatar
1 vote
1 answer
29 views

Weak RNG vulnerability proving

Hi guys I am auditing a smart contract and I found a WeakRNG in order to prove it I have written 2 smart contracts which simulate the work of this function( a bit ) here is the 1 a have changed block....
NeoRusI's user avatar
  • 11
0 votes
1 answer
41 views

Solidity: How to decode / trace / search custom error byte code

I ran into this Custom Error during my Foundry test: [FAIL. Reason: Custom Error cd786059:(0xF628...)] and I had no idea about what it means... then I figured out where it went wrong after tracing ...
Russo's user avatar
  • 1,764
1 vote
1 answer
19 views

How to cache the result of an inherited function before overriding it

contract A { function getUINT() public virtual view returns (uint) { return 100000; } } contract B is A { uint trycache; uint public trycache2 = getUINT(); // still 200000 ...
Ashraile's user avatar
1 vote
1 answer
23 views

Call or assignment expected. Getting this error while upgrading solidity version

I am not aware of the Assembly code. I copied the ERC1820 registry contract from here. This is written in 0.5.3. When I tried to compile it with 0.8.0 it gave me this error : I know it's because of ...
Serenity's user avatar
0 votes
1 answer
28 views

local initialization

I was working in this solidity code. here is the code sample from my project interface customeInterface { function token0() external view returns (address); function token1() external view ...
Biruk Damte's user avatar
0 votes
1 answer
35 views

can eth_call simulate approve and transfer?

I have a solidity contract that contains a logic to approve and transfer balance, swap and flashloan. But when i use eth_call to call my function that perform swap, it reverts. I tried by ...
Biruk Damte's user avatar
0 votes
1 answer
29 views

transaction fails when i use address[] memory

i was practicing on BSC testnet and my solidity code is // SPDX-License-Identifier: MIT pragma solidity 0.8.0; interface IUniswapV2Pair { function factory() external view returns (address); ...
Biruk Damte's user avatar
0 votes
1 answer
16 views

Hardhat deploy same contract to multiple addresses fails

I need to deploy the same contract to multiple wallets and I have this shell script. #!/bin/bash set -x contractName=MyContract network=sepolia npm cache clean --force yarn hardhat clean yarn hardhat ...
pigfox's user avatar
  • 125
1 vote
1 answer
24 views

how to revert transaction excuted by low level call

Hello ethereum community. I'm experimenting with low level calls and i want to revert the transaction made by low level call, if i didn't get the desired result. Is it possible? (bool success, ) = ...
Biruk Damte's user avatar
0 votes
3 answers
132 views

Despite calculation I get contract creation code storage out of gas

My smart contract is deployed on https://sepolia.etherscan.io/tx/0x1b1742a3ff2ac160d5f245ab91828fcc56a803cb3826b6cbdb9f3cb2f293ba66 Once deployed I get contract creation code storage out of gas error ...
pigfox's user avatar
  • 125
0 votes
1 answer
13 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
1 answer
63 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
2 votes
1 answer
74 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
37 views

Smart contract deployment pending forever

I have a smart contract that is compiled and deployed using Remix and verified on Sepolia testnet. https://sepolia.etherscan.io/verifyContract-solc?a=0xA3Bc4ac115CF4C57b507797731F43c14Ff6A2A6c&c=...
pigfox's user avatar
  • 125
0 votes
0 answers
18 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
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
0 answers
14 views

What happens if you divide a uint256 by a uint88 using divU64?

I am looking at the following function. It takes a uint256 (ercDebtSocialized) and uses safemath divU64 to divide it by a uint88. I assume this would just throw an error? I unfortunately cannot test ...
auditor_chick's user avatar
1 vote
1 answer
57 views

Two people calling this function at exactly the same time

I was looking at Rocket Pool's docs on interacting with other contracts and they included a simple example function that another protocol could use to accept deposits of ETH, forward it to RP, and get ...
auditor_chick's user avatar
0 votes
2 answers
35 views

Can a function call itself?

Can a function call itself...specifically, I am looking at this code and I can't figure out how this could work properly...the parameter vault would be the first parameter in the line that calls ...
auditor_chick's user avatar
1 vote
1 answer
16 views

Can you return something only some of the time with a function in solidity?

I am looking at a function that says it returns two uints, but the return statement is inside an else statement, so obviously there are conditions under which nothing would be returned. Can you have ...
auditor_chick's user avatar
0 votes
1 answer
16 views

Revert inside a for loop

If there is a revert inside a for loop that is inside a function, and the revert is triggered, will the whole function revert?
auditor_chick's user avatar
0 votes
0 answers
13 views

How to find issue with a bare bone token bridge

Basically, I want to setup a very simple token bridge try to bridge some custom tokens between BSC testnet & Goerli testnet. For BSC testnet, I created 2 solidity code: TokenBSC.sol & ...
Yong Dong Zhang's user avatar
0 votes
0 answers
48 views

How to import code into a contract

I have a contract that needs to be compiled with solc so I can get Go bindings. $ tree . ├── openzeppelin ├── Swap.sol └── @uniswap pragma solidity >0.7.0 < 0.9.0; import { IUniswapV2Pair } ...
pigfox's user avatar
  • 125
0 votes
1 answer
77 views

Performance and Gas Implications: uint vs int in Solidity Memory Variables

I am working on a Solidity smart contract and am considering the use of uint and int data types for memory variables. I have specific use-cases like reverse looping, where using int seems to produce ...
Eugene1111's user avatar
1 vote
1 answer
26 views

Smart contract always returns the same hash even when provided with different input

I created a basic smart contract and Im using ganache locally but when i call it with different inputs it always returns the same value, has anyone come across this before ? contract....
Kravitz's user avatar
  • 447
1 vote
1 answer
55 views

Calling performUpkeep(zeroBytes) results in 'function returned an unexpected amount of data'

I'm doing the blockchain course by Patrick Collins on FreeCodeCamp and I'm really enjoying it. Unfortunately I got stuck at my unit test in lesson 9 and after reading a lot of discussions on Github, I ...
r-byes's user avatar
  • 11
1 vote
0 answers
50 views

How to merge two arrays, and remove the duplicated elements sametime with solidity?

// SPDX-License-Identifier: MIT pragma solidity ^0.8.4; contract BatchData { function getArray1() internal view returns (address[] memory) { address[] memory arr = new address[](3); arr[0] ...
Noldorin Zhang's user avatar
0 votes
2 answers
27 views

What is the purpose of the constructor?

contract Constructor { string public name; // I thought constructor will prevent the name to change but after deployed the contract, calling the function resulted in changing the name????? ...
Majed Alshaikhi's user avatar
2 votes
0 answers
15 views

How to inherite modifier into multiple contracts ? Best practice?

I have a project with severals contracts. To put some security, I've created a "onlyContract" modifier on a Roles contract so some functions in diferents contracts can only be called if the ...
noubidev's user avatar
1 vote
2 answers
46 views

Is it possible to define interface getters for arrays of structs?

Given a state variable defined like this: struct Segment { uint256 foo; uint256 bar; } Segment[] public override segments; Is it possible to define a getter in an interface? I've tried this ...
Paul Razvan Berg's user avatar
0 votes
0 answers
18 views

Where can I find the exact Solc compiler version in Docker?

I am using Docker to compile my solidity contracts with the following commands. Unable to find image 'ethereum/solc:0.8.18' locally 0.8.18: Pulling from ethereum/solc 60bfd3cb9459: Pull complete ...
pigfox's user avatar
  • 125
0 votes
1 answer
342 views

transaction would cause overdraft

I am only borrowing 25% of my wallet balance and I get transaction would cause overdraft on Main net. The code works on Sepolia test net. Any ideas of what causes this? I get an instance ...
pigfox's user avatar
  • 125
0 votes
1 answer
74 views

Cancelled value + Error encountered during contract execution [execution reverted]

I have a failed transaction, Etherscan link, with the following errors: Warning! Error encountered during contract execution [execution reverted] Value: 0.000000000000066666 ETH ($0.00) - [CANCELLED] ...
pigfox's user avatar
  • 125
0 votes
2 answers
24 views

Not able to store value on mapping

// SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.0; contract Lending { // calculating the value of loan on the basis of collateral uint256 LTV = 20; mapping(address => ...
soumyadeep.eth's user avatar
0 votes
0 answers
60 views

Getting overflow error for number 10000000000000000

function withdraw (uint _collateralVal) public payable{ // eligibleAmt = super.requestForLoan( _collateralVal*10**18); payable(msg.sender).transfer( _collateralVal); emit withdrawEvent(msg.sender,...
soumyadeep.eth's user avatar
1 vote
1 answer
37 views

Solidity modifier attachment expression onlyOwner vs onlyOwner() | any difference?

Can I use onlyOwner() and onlyOwner modifier calls interchangeably in Solidity? Is there any particular difference between these 2 functions below considering that address owner; constructor() { ...
Mila A's user avatar
  • 264
0 votes
1 answer
19 views

Getting an error when trying to deploy a smart contract from another smart contract

This is my smart contract contract Pool{ constructor( address _baseToken, address _quotetoken, uint _sellTax, uint _buyTax ) { quotetoken = ERC20(...
Adokiye 's user avatar
0 votes
0 answers
16 views

Upgradeable Proxy Pattern - using from other contract

I am trying to use the upgradable proxy pattern in mi contracts and at the end, i can call the setters ok, but the getters are not working. I have Clients that has a count value storage, a getCount ...
Maite Ibarburu's user avatar
0 votes
1 answer
12 views

Member "getNumber" not found or not visible after argument-dependent lookup in uint256

I was trying to check something I saw in the tutorial on the simpler example. In the tutorial it was: using My_PriceConverter for uint256; I tried to check it using simple contract and library ...
joaszek's user avatar
  • 11
0 votes
1 answer
276 views

Invalid opcode in smart contract ( solidity ) while using ganache-cli

The inbox.sol file is - //SPDX-License-Identifier: UNLICENSED pragma solidity ^ 0.8.9; contract Inbox { string public message; function myInbox(string memory initialMessage) public { ...
Swetha N's user avatar
0 votes
2 answers
24 views

Despite funding: The transaction has been reverted to the initial state. Reason provided by the contract

I have the contract below and it even fails with $10 sent in Gas. TX link Clicking the swap button in Remix on Sepolia chain, the console shows. [vm]from: 0x5B3...eddC4to: Asset.swap(address,address,...
pigfox's user avatar
  • 125
1 vote
1 answer
261 views

Web3ContractError: The number of arguments is not matching the methods required number. You need to pass 0 arguments

The below is my inbox.test.js file code: const assert = require('assert'); const ganache = require('ganache-cli'); const {Web3} = require('web3'); const web3 = new Web3(ganache.provider()); const {abi,...
Swetha N's user avatar
0 votes
1 answer
37 views

Failed contract execution in function swap()

I am using sepolia test network and have 0.621 SepoliaETH in Metamask. This is my contract: // SPDX-License-Identifier: MIT pragma solidity ^0.8.0; import "./Token.sol"; contract Swap { ...
pigfox's user avatar
  • 125
0 votes
0 answers
93 views

abi: cannot use invalid as type array as argument

I am using go-ethereum to deploy a smart contract. This is how I create the contractABI contractABI, err := abi.JSON(strings.NewReader(getAbi())) if err != nil { log.Fatal(err) } ...
pigfox's user avatar
  • 125
2 votes
1 answer
258 views

Do we need OpenZeppelin's Counter with Solidiity 8 any more?

According to Solidity documentation: Prior to Solidity 0.8.0, arithmetic operations would always wrap in case of under- or overflow leading to widespread use of libraries that introduce additional ...
Alexander Herranz's user avatar
0 votes
2 answers
115 views

Hardhat test error, missing argument in contract constructor

okay, I have edited my test file and now I am getting an entirely different error. ERROR 1) BCCasino tests "before each" hook for "..should deploy correctly": ...
Shawngilbert107's user avatar

1
2 3 4 5
7