Questions tagged [contract-debugging]

questions for finding and squashing bugs in smart contracts and decentralized development

Filter by
Sorted by
Tagged with
94
votes
8answers
41k views

What is an ABI and why is it needed to interact with contracts?

ABI is referenced in many places including the official Ethereum website. What is an ABI and why is it necessary to use?
39
votes
8answers
20k views

How to quickly test a Solidity function?

There are snippets and functions of Solidity code provided on this Ethereum Stack Exchange and other sites. What are ways to quickly test them, possibly debug a little, and play around?
33
votes
5answers
17k views

How can I debug a smart contract?

When developing my smart contract, how can I debug it? Are there any debugging, testing tools or simulators that I can use to examine my code?
28
votes
1answer
16k views

How to update a deployed smart contract? [duplicate]

I've started developing smart contracts with Truffle and when I edit a contract I always redeploy it by adding another migration script. There are two things that I wonder about: Is this the way it ...
27
votes
10answers
10k views

How can you handle an expected throw in a contract test using truffle and ethereum-testRPC?

Is it possible to write a test using truffle that attempts to confirm that a throw occurs in a contract? For example, if I had a contract with function... contract TestContract { function testThrow(...
24
votes
3answers
24k views

How to get return values when function with argument is called?

I am writing below a simple contract which stores all results of questionnaires for each ID. contract answer{ mapping(address => mapping(string => bool)) voters; struct qList { uint ...
21
votes
2answers
5k views

Oracle (oraclize.it) with Truffle and Testrpc

As I understood in the blockchain, it is "not" possible to interact with webservices outside the blockchain. This must be done over oracles in order to verfiy that the request is secure, and the state ...
21
votes
3answers
26k views

What does “intrinsic gas too low” mean?

I'm running the Mist wallet, and I've deployed this contract to testnet (from https://ethereum.stackexchange.com/a/179/520) : contract Notary{ struct Document { uint timestamp; ...
21
votes
3answers
23k views

What's the Solidity statement to print data to the console?

Sometimes it would be really helpful to be able to see string representations of variable values in the Geth console, like of argument values in functions. Can I somehow print them to the Geth console?...
21
votes
1answer
6k views

What are *C*, *E* and *S* properties in message call return object?

(JS) var contract = web3.eth.contract(abiDefinition).at(address); contract.test(value, gotResult); function gotResult(error, result) { if(!error) { console.log(...
21
votes
2answers
8k views

Throw vs. Return

We're trying to figure out whether to use return or throw in Solidity when a condition fails and we don't assume user maliciousness. Here's the pros and cons we've figured so far: Why use throw Any ...
18
votes
6answers
12k views

Best way to test a smart contract

I just want to deploy and call a simple sample smart contract only for testing purpose. Do I need to download the entire ethereum blockchain? Its too huge and takes too long to download. Can someone ...
15
votes
5answers
4k views

How do I know when I've run out of gas programmatically?

This keeps coming up on the gitter forums so I thought I'd ask and answer this question: How do you know when you've run out of gas?
14
votes
1answer
5k views

What Ethereum blockchain explorers exist?

What blockchain explorers exist and What special features do they have? Are they open-source? How reliable are they (approximate uptime in %)? Is there a testnet version?
14
votes
3answers
739 views

How come I need to specify a higher gasLimit than estimateGas?

If a contract call predictably requires 41043 of gas to be processed as estimated by estimateGas, how come I need to specify gasLimit of ~70000 to be processed?
13
votes
2answers
4k views

Is it impossible to use an array of strings as the argument to solidity function?

If I try to define a function using an array of strings as an argument, solc gives me the following error: Error: Internal type is not allowed for public or external functions. function test(...
13
votes
1answer
3k views

How to make external contract function calls from one contract to another?

I'm having a hard time understanding the documentation for making an external function call from one contract to another. In this tutorial there is an example: contract InfoFeed { function info() ...
13
votes
1answer
638 views

oraclize 'VM Exception: invalid JUMP'

Here is my smart contract that uses oraclize to buy bitcoin with ether. pragma solidity ^0.4.0; import "https://github.com/oraclize/ethereum-api/oraclizeAPI_0.4.sol"; contract BuyBitcoin is ...
12
votes
2answers
5k views

What does a “bad JUMPDEST” error mean?

When I send a transaction to call my contract, it's causing a bad JUMPDEST error. The Ethereum wiki says this error is caused when a JUMP instruction jumps to a location that wasn't marked as a jump ...
12
votes
5answers
5k views

Sorting an Array of integer with Ethereum

I'm trying to have a simple array of integer sorted in Solidity but i couldn't find any real ressources so instead i'm trying to do it "the hard way" but so far with very little success. Is anyone ...
11
votes
1answer
563 views

Constructor not working properly

After I mine the following contract giving the array [true, true, true] as _bools I would expect [true, true, true] to be returned by getBools(). Instead [false, true, true] is returned. Is there ...
10
votes
1answer
548 views

Bad jump array solidity and data location

I'm having a strange issues with an array inside a struct. I will copy you the example code, so that you can understand: Foo[] public foos; struct Foo { uint fooX; uint[] fooArray; } ...
10
votes
2answers
1k views

Is it possible to preload contracts in the genesis block?

Here's the setup I'm trying to use: A genesis.json with the alloc field set to include code. "alloc": { "0000000000000000000000000000000000000001": { "code": "...
9
votes
2answers
2k views

How to pass struct mappings to solidity functions?

I have two mappings (uint => customStruct) called listA and listB. I want to run both through a single function to perform operations on the contents. How do I pass this type into a function so ...
9
votes
2answers
3k views

access struct from mapping in a different contract

I want to access / modify data from a contract from another contract. If you could help me understand the error that would be great! I get the following error: Untitled1:33:8: Error: Indexed ...
9
votes
1answer
713 views

How to avoid/detect multiple internal transaction out-of-gas side effects?

Following an issue I opened in github, this bothers me. The operation described in the issue, which happened during following avsa's tutorial on creating a DAO, generated two internals transactions as ...
9
votes
1answer
2k views

Custom balance accounts testrpc?

I am setting up unit tests with for my contracts using truffle. I am using also testrpc, but having accounts with 2.123...... *10^37 Wei is not very helpful to visualise and debug things. I am trying ...
9
votes
2answers
334 views

Why do I get serialization errors in calling events?

I have put some events in my contracts like this event TokenTransfer(address indexed sender,address indexed receiver,uint32 indexed num_tokens); event ExceptionEvent(uint16 indexed retcode,address ...
8
votes
1answer
977 views

How to map EVM trace to contract source?

In other words, how to get "classic stacktrace" of failed transaction? E.g. we have a trace (don't look at "Missing opcode 0xfd" - its the revert instruction) and the contract solidity source. How ...
8
votes
2answers
6k views

Type inaccessible dynamic type is not implicitly convertible to expected type

pragma solidity ^0.4.4; import "./strings.sol"; contract XFinance { using strings for *; address addr; uint coin; Shipment shipment; function XFinance(uint balance) { coin=balance; ...
8
votes
1answer
1k views

Check if msg.value is even?

I'm trying to check whether the amount send by an account is even. For now, I have the code below but when I send only 1 ETH, it doesn't not come back. Seems odd (pun intended :p ) uint amount; ...
8
votes
3answers
4k views

Mist: “No data is deployed on the contract address!”

I'm testing a contract on testnet using Mist. When I deploy it, it says "No data is deployed on the contract address!". And then it doesn't appear on the contracts section. What does it mean?
8
votes
4answers
5k views

The contract code couldn't be stored, please check your gas amount

I know this issue was discussed before several times, but I cant get the solution to my problem from any of the answers, My contract got deployed fine before adding the following function, function ...
8
votes
1answer
602 views

What is the most correct way to test modifiers?

As per the title, which testing method is most correct for modifiers? Something like testing via inheritance and creating a function specifically designed to test modifiers or testing via a framework ...
7
votes
1answer
297 views

Tracing back tripped require() to a source code line

What would be the process to map failed transactions (require, throw, etc.) back to the source code line where they occurred? Any examples of such yet?
7
votes
1answer
95 views

Is Coin a reserved word?

If I try to compile the following example code in Mix it doesn't work. As soon as I change the name from Coin to Coins it starts working as supposed? Is this a bug or a feature? contract Coin { //...
7
votes
1answer
1k views

What is the best way to send multiple transactions without running out of gas for seeding?

I'm having an issue where sending a single transaction work but sending multiple doesn't. I'm attempting to Seed my contract with data using using web3.js and it works fine. mycontractinstance....
7
votes
2answers
604 views

Wait for next block when testing with TestRPC

I'm running some tests over my contract using TestRPC and Mocha. I'm writing a debt manager. My data structure has a field called validity, which is semantically a date that determines until when ...
6
votes
1answer
2k views

Simple contract on private network is never mined

I'm trying to run the crowdsale example from the Frontier docs on a private network and local blockchain. I can create the contract, but do not seem to be able to mine it. You can see a gist of the ...
6
votes
1answer
722 views

What do the response values of a Parity `trace_transaction` call actually represent?

Parity implements a really useful trace module for deep diving into blocks and transactions. One particular method trace_transaction allows you to investigate the EVM execution paths of a transaction....
6
votes
2answers
2k views

How do I serialize an array of strings in Solidity?

Since I can't seem to get my contract to return a string array in any of its methods, I'm just going to serialize the array and return it as a string or bytes. I've tried various for loop methods to ...
6
votes
1answer
2k views

Passing ether with call to Solidity function

I have deployed a contract to testnet which appears to function. I have a function named contribute which gets the ether from the msg.value. The function is below and doesn't take any arguments. I ...
6
votes
1answer
2k views

Using Oraclize to assign value to another contracts variable

I'm using oraclize to get the price feed using this code: import "oraclizeAPI.sol"; contract PriceFeed is usingOraclize{ uint public BTCUSD; function PriceFeed(){ oraclize_setProof(...
6
votes
1answer
3k views

geth: view all current contracts on a private testnet?

How can I query a list of all current contracts with geth? Is there a way to see the contracts' class names?
6
votes
2answers
6k views

Where can I find test-ether for the Kovan Test Network?

I have tried getting some using my github account but my account got flagged immediately and the program wasn't recognizing my account (Since it wasn't public due to being flagged). Are there any ...
6
votes
1answer
1k views

Problem setting uint value to zero

I made a little smart contracts with solidity browser, This is my code: pragma solidity ^0.4.0; contract Test { struct User { string name; string surname; uint active; ...
6
votes
1answer
248 views

Truffle debug on function call show null variables

With a truffle version of 4.1.0, using truffle debug on a call of my contract function below: function Deposit (uint256 timeout, bytes32 hash, address recipient) public payable returns (...
6
votes
1answer
617 views

Why is this a potential violation of Checks-Effects-Interaction pattern?

That's what Remix is telling me. Now when I look at the documentation as to what this means it seems to be talking about, as I understand it, recursively entering a control flow (if): Ether ...
5
votes
2answers
882 views

Is there an API which allows to download source code of contracts?

I am doing research into the security of smart contracts and was hoping to gather a dataset containing smart contract source codes. I was wondering if there is an API which allows this. At etherscan ...
5
votes
3answers
1k views

How to properly catch events using MochaJs

Good day, I'm using mochajs to test my Solidity code using truffle and testrpc. In my contract I got the following event and function: contract store{ event MoneyIn (address _from, uint256 ...