Contract Invocation – Managing Multiple Function Calls in Smart Contracts

contract-invocation

My question is mainly to know if what I want to achieve is possible or not, unfortunately I cannot find (understand?) my answer elsewhere.

I have no experience with Solidity, and very little with Ethereum, I just managed to call a function from a smart contract in a transaction with an ETH client (go-ethereum). I have not deployed the contract, it is a public DeFi smart contract.

So far, I've successfully called a function from the smart contract with its parameters and get its response.
The goal is to call several functions, simultaneously but in a defined order, each with its own parameters, from the same smart contract, and ideally in the same transaction.

  • Is it possible to call multiple functions (with parameters) and get all responses within one single Ethereum transaction ?

  • If not, is it possible to do it by another way, like deploy my own smart contract to do the job ?

  • Is there a way to guarantee the order in which these functions will be executed by the smart contract (I mean the final target smart contract, not mine if I ever need to deploy one) ?

  • To reach this goal, is there a directly related question or potential solution that I would not have thought of ?

Best Answer

One transaction is always one call from an EOA (Externally Owned Account) to either another EOA (Ether transfer) or to one single smart contract.

So what you can do is create your own contract which does what you need. So your contract creates a reference to other contracts and calls them in specific order. Here are some references on how to do that: https://medium.com/@blockchain101/calling-the-function-of-another-contract-in-solidity-f9edfa921f4c and https://www.reddit.com/r/ethereum/comments/58x16k/how_do_i_call_a_deployed_contracts_method_in/ (note that the syntax of the code changes quite fast so the syntax is the examples might not be fully correct anymore)

The order of execution is strictly defined in a single transaction - there is no parallelism. So first the first line of code is executed, then the second and so on. If the first line fails the second line (mostly) doesn't even get executed.

Related Topic