Questions tagged [contract-debugging]

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

Filter by
Sorted by
Tagged with
98
votes
8answers
42k 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?
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 ...
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?
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?
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(...
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?
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 ...
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?
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?
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(...
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 ...
21
votes
3answers
27k 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
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
24k 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?...
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 ...
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; ...
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 ...
4
votes
1answer
1k views

How can I split my Contract up into different smaller ones?

I am learning the Solidity language and I have been experimenting on the Ropsten Testnet, I have tried several things with a contract I created, yet everytime I try to create it, remix solidity IDE ...
3
votes
2answers
5k views

No visibility specified. Defaulting to “public”. function Ownable() {}

I'm trying to learn how to create tokens using Solidity/MIST. I have modified a pre existing contract on a functioning token but I am having an error whenever I insert it into Ropsten. The contract ...
5
votes
1answer
11k views

Getting 'invalid opcode' error

First of all, sorry for the code in Portuguese, this was a choice of the team and I had no saying on that. I'm writing a Billet Manager, the code is as follows: contract GerenciadorBoletos { ...
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 ...
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() ...
5
votes
1answer
108 views

Getting event history takes a really long time or doesn't work at all

I'm having trouble getting a history of events. I'm unsure if I am misunderstanding how events work, if I'm coding wrong, or if it has anything to do with the recent Ethereum attacks slowing down the ...
4
votes
2answers
390 views

Reproducing stack depth attack

Victim contract allows one time withdraw only. I want to attack it using stack depth attack to withdraw everything it has. I've tried different things, but can't get the desired result. Here's where I'...
3
votes
1answer
461 views

How to explain string serialization when invoking contract method?

On Ropsten testnet I have deployed a contract like this: // creation of contract object var aContract = web3.eth.contract([{"constant":true,"inputs":[{"name":"","type":"address"}],"name":"...
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 ...
5
votes
1answer
109 views

Validating a contract before sending ethers to it

This is a partially philosophical question, by an Ethereum newbie. When calling a contract, you send ethers to it. Before that, you checked of course that the contract does something interesting/...
4
votes
1answer
12k views

get array.length without a getter from other contract?

Is there a way to get length of an array in an other contract without a getter? pragma solidity ^0.4.11; contract MyContractA { uint[] public myArray; function MyContractA() { ...
3
votes
1answer
1k views

Error During Token Contract Execution

Getting an error in executing a token contract: An error occurred during contract execution: invalid jump destination (PUSH1) 2 http://testnet.etherscan.io/vmtrace?txhash=...
2
votes
1answer
4k views

Testing contracts with truffle

I'm trying to write tests for contracts using truffle; I have opened an issue here. The workflow is as follows: mkdir truffle_testing truffle init rm -r tests/* contracts/* build/* Next, I create ...
2
votes
1answer
136 views

Is it possible for contract to use different amount of gas for the same function?

I have contract Collector with function sendCoins to external wallet, but some times this function works, sometime not. I have no loops in contract, just one send and that's all - so I thought it ...
2
votes
0answers
109 views

Minimal contract testing setup using truffle

This question is a follow up onto this one. I have tried following the suggestion in the answer of adding a done() method that fires when an error occurs (an exception is raised) but it doesn't when I ...
1
vote
1answer
2k views

calling simple function from another contract

I'm running into issues calling the function y() in the contract pullother. The input for the function y() is the output of the function g(). When I call y() using this input the output is blank ('' ...
0
votes
1answer
547 views

msg value get low level call error [duplicate]

function enter() payable { if (msg.value < 10 finney) { msg.sender.send(msg.value); return; } I am getting return value from low-level calls in Mist wallet. Solidity ...
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; ...
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(...
10
votes
1answer
549 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; } ...
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 ...
8
votes
1answer
988 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 ...
7
votes
1answer
299 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?
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 ...
2
votes
1answer
3k views

Error encountered during contract execution [Bad jump destination]

When calling to start() function in a Smart Contract, transaction fails with this message: Warning! Error encountered during contract execution [Bad jump destination] According to Error During ...
1
vote
1answer
274 views

Implementation of an Allowance Crowdsale. Token Interface / _prevalidatePurchase-/_delivertokens-function

I am new to solidity coding and after I created some basic contracts as well as a ERC20 token contract I wanted to create a crowdsale contract. Now I am stuck and I have a question regarding the ...
1
vote
1answer
492 views

Unable to replicate tx.origin attack

I was reading the solidity docs and decided to replicate tx.origin attack . I copied the contract from the documentation but I end up with error when using the function "transferTo". Check the remix ...
13
votes
1answer
639 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 ...
9
votes
1answer
715 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 ...
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(...
4
votes
1answer
853 views

Symbolic decoding of a transaction for Solidity

I have a Solidity contract source code and a raw transaction (hex) from blockchain. Is it possible for me to decode the transaction to its symbolic format, so I can see what contract methods are ...
1
vote
2answers
3k views

Accessing a mapping within a struct via Truffle console

This question was asked here but I thought I would make it a little more clear. Is it possible to access the funders mapping (bolded) via Truffle console in the code below ? This is taken from the ...