Podcast #128: We chat with Kent C Dodds about why he loves React and discuss what life was like in the dark days before Git. Listen now.

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?
41
votes
3answers
35k 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 ...
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 ...
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 ...
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.
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 ...
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 ...
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 ...
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 ...
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(...
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 ...
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_) { ...
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() { ...
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: ...
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
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?
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 ...
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)...
8
votes
1answer
765 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 ...
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?
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?
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 ...
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{ ...
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
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 ...
2
votes
2answers
9k views

web3.eth.call. How can I set “data” param?

I deployed my first contract by using browser-solidity to make bytecode and web3.eth.sendRawTransaction to deploy. The following is the transaction and the deployed contract code. https://ropsten....
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 ...
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....
1
vote
1answer
2k views

How can I connect my HTML user interface to my Ethereum private chain?

I'm trying to learn smart contract development and test my contracts. Before, I used truffle, Metamask and testrpc to test my contracts; and it took care of how to interact my HTML page to the local ...
6
votes
1answer
669 views

Can you execute a contract twice in one block? [duplicate]

If you call a contract with two different tx from different account, can they be executed and mined in the same block? If yes how do you guarantee order and concurrency integrity like deadlocks?
1
vote
1answer
351 views

On which node smart contract get executed

I have a general question in my mind please do correct me if i am thinking wrong . Suppose if i deploy the smart contract on the ethereum blockchain having a functionality to pay some tokens at ...
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 ...
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 { ... } ...
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 ...
7
votes
2answers
701 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 ...
6
votes
1answer
3k views

Call contract and send value from Solidity

I have a pre-deployed contractA with known ABI. I would like to call function func1(string,string) in the contractA (and pass the arguments) from a new contractB and send some value at the same time. ...
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)....
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 ...
3
votes
2answers
5k views

How do I “Add Data” to a send transaction in Solidity

In myetherwallet, there is an +Advanced: Add Data Section where I can add data to the transaction. How can I add this same data in a transaction I make in Solidity?
3
votes
4answers
920 views

How to detect from web3 if method exists on a deployed contract?

Suppose a contract has been deployed and I don't have its source code or ABI. From web3, I would like to know if the contract has a method with a given signature. (An example application would be a ...
1
vote
2answers
631 views

How do I deploy a contract, then send and retrieve a string from it?

I wish to store strings on-chain. From what I understand so far, I need to set up a contract, then I can send transactions (with a string) to that contract which will be stored. Is this the best way ...
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: ...
2
votes
2answers
2k views

Query multiple smart contracts' public data

I have a smart contract that holds the details of a person. Each new person gets a new smart contract that they 'own'. I have a regulator/ admin who wants to see the number of such smart contracts ...
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 ...
5
votes
2answers
3k views

Understanding nameReg.call(“register”, “MyName”) style call between contracts

Here's an example from solidity docs on Address type methods(call method specifically): address nameReg = 0x72ba7d8e73fe8eb666ea66babc8116a41bfb10e2; nameReg.call("register", "MyName"); ...
4
votes
3answers
965 views

Race conditions when calling remote contracts

Below I extracted the logic which calls a remote contract to calculate the amount of tokens to withdraw funds. contact Example { mapping (address => uint256) balances; ERC20 token = ...; // ...
6
votes
3answers
1k views

Can any information beside the address be encoded into QR code?

I want to create a contract. I want to generate a QR code to invoke this contract. I want to present this QR code to a user. Is there a way to embed any additional information into the QR code (...
2
votes
3answers
790 views

How to get token holders via json RPC

So I want to get the token holders of a token like this: https://ropsten.etherscan.io/token/0xfa68d281e7ff1a8e9393428ba0abe8961cf342cb#balances Via my Ethereum node. I tried: https://github.com/...
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'...