Questions tagged [contract-invocation]

Questions regarding the act of calling or interacting with (a.k.a. invoking) a contract on the Ethereum blockchain by a user or another contract on the blockchain. Includes both local invocation by call and global invocation by transaction.

Filter by
Sorted by
Tagged with
145
votes
2answers
28k views

What is the difference between a transaction and a call?

What is the difference between a transaction and a call? In some interfaces, I can interact with contracts via calls or via transactions. What is the difference between the two, and can contracts also ...
71
votes
9answers
12k views

Can contracts pay the gas instead of the message sender?

Is it possible for a contract to pay the gas costs (or part of it) that result from the contract being called? Or does the sender of a message always pay the resulting gas costs no matter what?
60
votes
2answers
19k views

Difference between CALL, CALLCODE and DELEGATECALL

CALL and CALLCODE take the same number of operands (in the execution stack). For the exception flag being pushed on top of the stack: 0 means exception, 1 means successful execution. CALL is easy to ...
41
votes
3answers
34k views

How to call a contract method using the eth_call JSON-RPC API

Ok, so I'm trying to call a contract method using the methods provided by the Ethereum JSON RPC interface. The JSON RPC is running on an Ubuntu machine. Unfortunately, I can't really get a result back ...
27
votes
1answer
13k views

How does the delegatecall method work to call to another contract's method?

I'm trying to figure out how to use the delegatecall method on a contract address in a contract to call a function in a separate contract. I know Libraries are the higher level interface to use but I ...
26
votes
4answers
6k views

Does every node execute the contract code for each transaction?

This question was asked on Reddit a while ago: When a node sends a transaction to the network and has the receiver as a contract, does every node execute the contract bytecode with the inputs to ...
25
votes
2answers
9k views

'internal' keyword in a function definition in Solidity

Does the internal keyword in a function definition such as: function doSomeThing(uint _param) internal {...} work similar to designating a method as private in other languages and thus makes the ...
23
votes
3answers
23k 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 ...
23
votes
3answers
17k views

Calling function from deployed contract

I want to know how to instantiate an existing contract deployed on the blockchain using its address. e.g: contract A { function f1() {} } A is deployed on the blockchain, and in contract B I ...
22
votes
2answers
11k views

How can you call a payable function in another contract with arguments and send funds?

I have a contract named Call: contract Call { ... function () payable { // TODO: Call the call function in the main contract // and forward all funds (msg.value) sent to this contract ...
22
votes
2answers
15k views

How do I know how much gas to use when calling a contract?

When I am calling (sending a transaction to) a contract how do I determine how much gas to use? Is there a way to calculate this upfront & what happens if I send too much / too few gas?
21
votes
2answers
6k views

Do I need a compiled contract just to get the ABI definition?

Why do I need a compiled version of the contract just to get the ABI definition? Seems like the contract address should be enough. Im very confused because I am simply trying to run a contract ...
20
votes
3answers
4k views

Pass a function as a parameter in Solidity

Can you pass a function as a parameter in Solidity? My guess: There is the concept of address in Solidity, but they represent contracts. Contracts can have fallback functions, but I don't think you ...
20
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(...
18
votes
2answers
16k views

How can I return multiple strings from a contract function?

In solidity it's obvious how to get a single string returned from a function. But, I'd like to have the smart contract return multiple string values. Is there a way to do this?
18
votes
4answers
9k views

How does one contract send ether to another contract with more than 2300 gas?

I want one contract to collect a certain amount of finney before sending it to another contract, but I can't simply send in with C2.send(thisMuch). function() { Dividend m = Dividend(dividendAddr)...
18
votes
2answers
4k views

Contract reading a string returned by another contract

I have 2 contracts, Parents and Child which has a public string variable - name. contract Child { string public name; function child (string _name){ name = _name; } } Parents ...
17
votes
3answers
5k views

send VS call - differences and when to use and when not to use

Can somebody please explain the differences between using a send and call for contracts and when to use and not use these different methods? For example : msg.sender.send(number); msg.sender....
17
votes
1answer
1k views

What is the order and concurrency behavior of multiple calls to a contract in a single transaction?

Suppose a contract has three call APIs that have side effects. What's the behavior if I try to: Call all three APIs from one address (i.e. issue three transactions if from nodejs). Are all three ...
16
votes
2answers
2k views

What happens when a smart contract gets several similar calls in the same block?

What happens when a smart contract gets several similar calls in the same block? Consider for instance this greeter: contract greeter { string name; function setName(string name_) { ...
16
votes
6answers
12k views

Encoding/Decoding contract ABI data

How to encode and decode ABI data? Can someone show me an example with web3js library?
16
votes
1answer
6k views

How much does it cost to use a contract?

Still new to ethereum and would like to know the price for a contract.
15
votes
3answers
18k views

Call function on another contract

I've created a contract called "Name" which I've deployed to the testnet. this function just register some text for the user and display it back. My contract is: contract Name is mortal{ ...
13
votes
2answers
1k views

Can Solidity constant functions be arbitrarily complex?

Non-constant functions are limited in computational complexity by the block gas limit. I assume, but am not sure, that this does not apply to constant functions. Are constant functions in any way ...
12
votes
1answer
2k views

What does `call.value` mean and how did it allow the attack to The DAO?

I'm trying to get some sense from the hysteria around the attack performed to The DAO smart contract. I understand the high level explanations, but I'd like to grasp how this attack was performed. I'...
11
votes
2answers
787 views

What happens when two smart contracts recursively call each other?

As I understand it, a smart contract can "call" other smart contracts. So what happens when two smart contracts call each other in a recursive loop? Does the whole network break down and die?
11
votes
2answers
3k views

How do I change the owner of an ENS domain using MyEtherWallet?

Does anyone know the exact procedure for doing this? It looks quite straightforward, but I'm unwilling to try it out without confirmation from someone who's done it already.
10
votes
2answers
6k views

How to list all the contracts currently on the blockchain?

I know one way to interact with contracts is, in the geth interface, to use the command: eth.contract(ABI).at(Address) But for this I will need to know the ABI and address of the contract in advance....
10
votes
2answers
3k views

Is it possible to call Ethereum API from a Software Application without running an ETH node?

I was wondering if it's possible to make a call to Ethereum blockchain from a software application on my computer without having to run an ethereum node ? for example, I want to make calls from a ...
9
votes
1answer
1k views

RPC error “invalid or missing value for params” when calling contract constant void functions

My contract has a function defined like this: {"constant":true,"inputs":[],"name":"queryNumEscrows","outputs": [{"name":"","type":"uint256"}],"payable":false,"type":"function"} Having no inputs. Its ...
8
votes
2answers
1k views

Are Transactions originating from one account mined in nonce order?

Discussion in another thread raises an interesting point. how many transactions could be included in a new block from the same account? Since miners can opt to omit a known transaction from the ...
8
votes
1answer
760 views

Getting complete state of a smart contract

From the yellow paper, I figured out that a contract has 4 components 1. nonce, 2. balance, 3. code, 4. storage. To know about the current state of a smart contract we need to know the all these ...
8
votes
1answer
4k views

Basic example of interaction between 2 contracts?

What is a basic example of one contract invoking a method in another (non-calling) contract? Would the address of the contract having that method always need to be hardcoded?
8
votes
3answers
2k views

How to send some ether to all token holders?

I created contract A which generates and sends my tokens. I would like to send some ether to each token holder from another contract B. So how to find all token holders from contract B?
8
votes
2answers
3k views

Syntax for calling contract state changing methods

I've been struggling a bit with calling methods that change the state of the contract. Take, for example, the following contract: contract C { uint[] numbers; function initNumbers() { ...
8
votes
1answer
609 views

Why is my TX failing due to lack of gas even though the correct amount of gas was supplied?

Caveat: I tried to provide links to my transactions and addresses in etherscan.io, but I "need at least 10 reputation to post more than 2 links." I have an account that I want to sweep. I want to ...
8
votes
2answers
3k views

How to estimate the cost to call a Smart Contract method?

After succesfully deployed this Smart Contract on Ethereum testnet https://testnet.etherscan.io/address/0x27c042342C9ba937214117e11A4970A6145034cB is it possible to calculate how much gas is going ...
8
votes
1answer
355 views

Check if a contract implements specific ABI using JSON-RPC

In my Python web service, I'd like to confirm if a contract supports specific ABI (certain call methods). I am running get and communicating over JSON RPC. What are steps to for this? I am guessing ...
7
votes
2answers
2k views

Who gets the fee from contract call?

Basically you don't need to pay fee for contract call, but if a contract method does lots of work, you need to add gas in contract call to prevent DoS attack like this: contract.method.call({gas: ...
7
votes
2answers
6k views

How can I connect to public chain using web3?

I have used web3 to interact with my private chain by using : web3.setProvider(new web3.providers.HttpProvider("http://localhost:8012")); But How can I connect to Public Network using web3? I am ...
7
votes
2answers
700 views

Is there any limitation for the number of the return values from Solidity functions?

Answer of this question (https://ethereum.stackexchange.com/a/3590/4575) says that: "I am not allowed to return dynamic arrays from Solidity functions yet." On the other hand, Solidity supports ...
7
votes
4answers
2k views

How to specify gas/value when making a call using abstract contracts?

How does one specify gas or value making a call this way: contract AbstractB { function getX() returns(uint); } contract A { function makeCall(address addressB){ AbstractB(addressB)....
7
votes
3answers
3k views

Reading values from a contract: When do I need transactions?

Since reading on the Blockchain does not need performance of other nodes, I wonder how I can get values from a Smart Contract without any transactions. I have created a little example contract: ...
7
votes
1answer
8k views

What's a fallback function when using address.send(…)?

This code is in my contract: contract A { address x = 0x1234...; x.send(10); } What would fallback function in the contract at address 0x1234... look like? contract B { ... } ...
7
votes
2answers
4k views

Do I have to unlock my account in geth to call a web3.eth.sign() in JavaScript?

I have: A geth account Access to web3 API I want to: Invoke the function, web3.eth.sign(coinbase, sha) If I put this in a javascript file sign.js, and I call node.js, will it sign my message? Or ...
7
votes
2answers
1k views

Is it possible to call another contract from a contract maintaining the msg.sender of the original caller?

Imagine that Alice calls a contract method C1 and that method calls another method in contract C2. Regularly msg.sender equals the Alice Account in the C1 method. And msg.sender equals the C1 ...
7
votes
1answer
3k views

How does EtherDelta work?

I'm still learning Solidity and contract development. I have never used EtherDelta. I know it can be used for trading different tokens, but I would like to understand the following two things: How ...
7
votes
2answers
131 views

How does one know that one's contract has been executed?

What is the mechanism to know whether miners/validators have indeed executed one's contract, instead of just blindly validating it?
7
votes
4answers
2k views

Calling function of external contract and passing bytecode

I am trying to understand different methods of invoking functions of another smart contract (which is already deployed on the blockchain). Please see example below (call data/bytecode based on using ...
7
votes
1answer
1k views

I created a wallet contract, sent ether to it and now cannot send to another account

While experimenting. I creating a wallet contract. Here is the address: https://etherscan.io/address/0xC23501aB1E8E5C5EDB0fFA83C5A4DcFb9c31a355 I sent some ether to it. Now I want to send the ether ...