Questions tagged [contract-debugging]
questions for finding and squashing bugs in smart contracts and decentralized development
649
questions
1
vote
1
answer
48
views
How to transfer an NFT from a contract address to a wallet address
In a local test environment, I am able to compile this implementation of the ERC721 token standard, deploy it, mint an NFT and transfer it (using the transferFrom function) to the following deployed ...
0
votes
1
answer
22
views
How to query estimatedGas for an ERC20 transaction?
This is the json-rpc call I make
{
"jsonrpc": "2.0",
"method": "eth_estimateGas",
"params": [
{
"from": "...
0
votes
0
answers
20
views
How to verify and publish contract source code created from contract
I hope to help me about some mistake.
I take this all work in bsctestnetwork.
I created stablePool contract from stablePoolFactory contract.
So I need to verify and publish this contract, i.e ...
0
votes
3
answers
45
views
Pushing a contract to an array in another contract
I am new to Solidity, and I have a small problem.
For exemple I have these 2 contracts
contract Dog {
string name;
constructor(string _name){
name = _name;
}
}
contract Human {
...
0
votes
0
answers
15
views
Disburse Dividends to individual address?
So I have a contract where dividends are disbursed to all holders. This works great. But i am trying to add a function where in certain scenarios specific holders get a "bonus" of dividends ...
0
votes
1
answer
22
views
Stuck and need another pair of eyes. Return value from decimal
Been banging my head on this for a bit. Working on a smart contract and have things working except this last piece. Basically a number is generated (ex. 111), this number is used in Uniswap as a ...
5
votes
1
answer
844
views
Ethereum stuck in the smart contract
I deployed a beta version of an NFT project, however, some people who were not in the whitelist got their eth stuck in the smart contract, now I need to refund them by withdrawing the eth in the smart ...
0
votes
1
answer
12
views
Solidity 0.8.7, warning on compiler
how do I debug this so the compiler isn't showing any warnings? or is there nothing wrong with it
from solidity:
Warning: Function state mutability can be restricted to view
--> FireworkToken.sol:...
0
votes
0
answers
18
views
How to resolve "TypeError: Type address is not implicitly convertible to expected type address payable"? (Solidity 0.8.13) [duplicate]
I am trying to execute the below smart contract for hotel booking however, there is a type error stating "address is not implicitly convertible to expected type address payable". Please help ...
0
votes
1
answer
23
views
Creating an efficient development enviroment + workflow for dApp development
What I want to do is create an efficient workflow for rapidly developing, and testing dapps on different chains LOCALLY.
I thought about using Remix IDE, with testing environments for each respective ...
0
votes
1
answer
24
views
"Insufficent allowance"
Looking for assistance on what I'm doing wrong.
I have a simple ERC20 contract I built from scratch for practice interacting with a simple vendor contract that allows someone to buy and sell tokens. ...
0
votes
2
answers
51
views
How to push elements in an array within a function?
Can anyone help me figure out the issue with this function in the code?
function getVerifiedProposals(uint index) public returns (string[] memory, string[][] memory, address, uint[] memory) {
...
0
votes
1
answer
113
views
TypeError: Overriding function changes state mutability from "view" to "nonpayable"
I have 2 issues.
None of my constructor values are set when the contract is deployed. All functions that call for name, symbol, decimals, and totalSupply.
2a. The functions name(), symbol(), ...
0
votes
0
answers
8
views
Can transactions be jurisdictional illegal?
Lets say you find a bug that allows you to get all funds of a smart contract via a normal transaction. Would such transaction be illegal / considered stealing? Since Ethereum says "code is law&...
0
votes
0
answers
98
views
ERC721 Contract: Adding Contract Level Metadata?
I am trying to implement contract level metadata so "description", "image", external_link": etc show up on marketplaces, particularly OpenSea.
I have done an extensive search ...
0
votes
1
answer
28
views
Function returns undefined
I have a very simple function in my Solidity contract, that I'm trying to test its return value with Hardhat.
function mintNFT(address _recipient) public returns (uint256)
{
uint256 ...
0
votes
0
answers
36
views
Error: Invalid number of parameters for "getBalance". Got 0 expected 1!
I am very new to web3. I am trying to call the method
const web3 = new Web3(window.ethereum);
const networkId = await web3.eth.net.getId();
let nftContract = new web3.eth.Contract(
...
0
votes
0
answers
18
views
Step through debugger for brownie?
Brownie produces the trace on an transaction. Does anybody know of a tool that allows for step-through-debugging given that trace? (similar how the remix debugger works?)
0
votes
2
answers
46
views
How to debug a contract binary without source code?
I'm trying to debug a transaction on BSC network, the contract is not written by myself and it's not open source, is it possible to debug the transaction at assembly level?
I tried the "Remix ...
0
votes
0
answers
17
views
revert InvalidCalldata error VRFCoordinator
I am using a clone of the pancakeSwap lottery and attempting to use a write function. I keep getting an error in the BSC testnet VRFCoordinatorV2 contract saying revert InvalidCalldata();. The ...
0
votes
2
answers
65
views
Contract "NFTMarket" should be marked as abstract (when implementing IERC721Receiver interface along with ReentrancyGuard)
I've read other similar questions but none of them applies to my smart contract current setup.
Currently I have a working smart contract that only implements ReentrancyGuard.
Here below an snippet of ...
0
votes
0
answers
65
views
Brownie: replacement transaction underpriced
I have a stuck transaction in brownie, when I try to deploy another contract I have this error:
ValueError: replacement transaction underpriced
my deployment code is like this:
dev = accounts.add(...
0
votes
2
answers
38
views
Wrong address rertun when I call ownerof with delegatecall
I am trying to call the function "ownerof" of a contract but it return me something like that : ...
1
vote
0
answers
51
views
Store variables from Inline Assembly and use them after the block?
Unlike almost all examples of inline assembly usage, I would not like to immediately return the function after doing something in the assembly block.
Rather, I would like to save the result to some ...
0
votes
1
answer
239
views
Set data for call(), delegatecall(), etc, in Yul / inline assembly?
It seems that almost all the examples of external calls are simple proxies, which do something like this:
assembly {
// Copy msg.data. We take full control of memory in this inline ...
0
votes
1
answer
190
views
ERC1155 total Supply not showing?
I want to be able see the total supply of each token. I have imported the extension and followed the erc1155 documentation with regards to totalSupply, however when deploying on Remix and calling ...
0
votes
0
answers
555
views
Uncaught (in promise) Error: Internal JSON-RPC error. { "code": -32000, "message": "Execution reverted", "data": "0x" }
After getting the contract I tried to call a function from the deployed contract Address. But it is giving me the following error:
Uncaught (in promise) Error: Internal JSON-RPC error.
{
"code&...
3
votes
2
answers
3k
views
ProviderError: Error: Transaction reverted: function selector was not recognized and there's no fallback function
I'm trying to call a function[propose] from Openzeppelin governor.sol. The function is like this...
function propose(
address[] memory targets,
uint256[] memory values,
bytes[] ...
0
votes
0
answers
14
views
balances another contract
i want write the balance from another contract my brother wallet he forget the password and i want to return the balance to me agin contract name Token
mapping(address => uint) public balances;
...
0
votes
1
answer
27
views
very important interface
I have a problem, can anyone help me?
I want to change the value in another contract
another contract name Token
i want change example balances[msg.sender] = 0;
this a code
pragma solidity ^0.8.2;
...
0
votes
0
answers
18
views
Revealing NFTs on ECR721 contract before sold out?
https://rinkeby.etherscan.io/address/0x59C78c4a2313964b5360bCe9644513Bb8e5ABC30
This is my eth test contract for my NFT project. I am struggling to figure out how to reveal the NFTs when they are not ...
1
vote
1
answer
164
views
Member "push" not unique after argument-dependent lookup in address payable[] storage ref
using array of address payable in a struct and then when I try to push anything in that array I am getting this error.
Here is the code
pragma solidity ^0.8.0;
contract CrowdFunding {
uint256 ...
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 ...
0
votes
0
answers
113
views
How to decode data from an ABI function call?
I want to get the appropriate data out when let's say I click Swap or Approve on a Dapp. I have been researching and have come across how to decode data from the hex that the dapp sends to my wallet. ...
0
votes
0
answers
19
views
delegatecall, but with modifying the Caller contract state?
Example: EOA -> Caller Contract -> Target Contract
As far as I can tell, delegatecall differs from normal calls in two very important ways:
Call context is preserved, msg.value and msg.sender ...
0
votes
1
answer
12
views
How do require statements affect previously computed logic
If I have a function that changes the state of the contract, and further down in the same function, there is a require statement. What happens to the contract state if something fails to pass the ...
0
votes
0
answers
11
views
Does deposit function can't have argument in a contract?
I tested these two functions in a contract:
First function:
function deposit() public payable {
require(msg.value > 0, "Must send ETH.");
emit LogDeposit(msg.value, msg....
0
votes
1
answer
157
views
Cannot Import Lottery from Brownie even after successfull Compilation
I am trying to deploy the Lottery Contract but it doesn't seem to work since Brownie throws an error, ImportError: cannot import name 'Lottery' from 'brownie' . I have already compiled the Contract ...
0
votes
1
answer
68
views
What does this decompiled NFT contract source code mean?
Decompiled the bytecode of a ERC-1155 contract using EtherScan, which gave the following result. It's fairly short, which is unexpected for an NFT, so line-by-line what does this code even mean, given ...
0
votes
0
answers
31
views
The state of the contract does not change
I deployed the contract on my private geth network for testing.
pragma solidity ^0.4.26;
contract MyContract {
mapping (address => uint) private balances;
function depositFunds() public ...
0
votes
1
answer
15
views
How would I sign my metamask wallet to this contract I wrote?
contract Forwarder {
address constant private receiver = 123456;
function() public payable {
// Forward the received ether to receiver, as well as some gas,
// which the ...
0
votes
0
answers
50
views
Cannot verify contract on Polygon
I created a contract on ethereum remix using Metamask with polygon. when i try to verify contract below error message shown. how to fix this?
Error! Invalid constructor arguments provided. Please ...
0
votes
2
answers
122
views
Unable to Publish Source: API Request Timeout in Brownie while Publishing Source
While working and deploying the FundMe.sol Patric Collins tutorial on FreeCodeCamp. I stumbled upon the following error generated while trying to publish the source when using
FundMe.deploy({"...
0
votes
0
answers
55
views
How to debug smart contract delegatecall?
I am building an app that requires contact A to interact with a remote contract B. I am using solidity delegatecall function. After running it, I am seeing "Although one or more Error Occurred [...
0
votes
1
answer
167
views
Web3 - Best practive for calling onlyOwner view from backend
from my backend, I want to call the following onlyOwner function from my deployed smart contract:
function isValid(address _address)
public
view
onlyOwner
returns (bool)...
0
votes
0
answers
21
views
How can I extract Ethereum contract information
Is there any way to extract this contract related information using an API.
1.abi
2.address
3.base
4.code
5.created_at
6.dynamic
7.factory
8.id
9.name
10.namespace
11.updated_dt
0
votes
0
answers
253
views
Hardhat console.log doesn't work in VSCode Remix extension
I installed the VSCode Remix Extension and I compiled(successfully) and deployed this contract:
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.6;
// tried also with the commented line ...
0
votes
1
answer
81
views
ganache modify code of smart contract after fork?
Ganache has recently introduced the ability to fork from a live blockchain at a particular block number. https://github.com/trufflesuite/ganache/releases/tag/v7.0.0
After forking, I would like to be ...
1
vote
2
answers
871
views
How to initialize an array inside the function and push items into it?
How to initialize an array inside the function and push items into it? I'm not gonna initialize outside the function.
Here's my code:
function tokenOfOwner(address owner) public virtual returns (...
0
votes
0
answers
44
views
How to listen for events in a well-known contract (Compound cDai) called by my contract
I don't know how to debug the situation where I wrote a contract (MyDeFiProject) which calls a well-known contract developed by someone else (in this case Compound cDai on Rinkeby). The transaction ...