2

As we know, Bitcoin has something called Script, that could implement some simple form of smart contract. It could enable us to use signed but not propagated transactions to implement off-chain systems, like lightening network.

Now the question is, is there a similar capability in Ethereum transactions? Instead of calling a function of a smart contract, can we execute some form of scripts to validate the transaction to achieve same benefits?

EDIT

It seems that the question is asked so unclear. So I'll try to ask it another way.

In Ethereum, we can call a contract by a transaction. So first we have to deploy a contract into the blockchain, and then call it using another transaction.

Now the question is: Is it possible to execute some codes that is not deployed to the blockchain, but is stored inside the transaction itself?

As I said, this is possible in Bitcoin, using the Script of the transaction, that enables a lot of exciting features. I'm trying to find a way to do the same in Ethereum.

I hope it is clear this time.

  • There are two interpretations of what you've asked above; perhaps you can edit your question a bit to help clarify. But as Thomas Jay Rush mentions below, you can perform off-chain transactions in Ethereum; a real-world example of this is Raiden which allows the creation of on-chain payment channels to manage off-chain transactions. – lungj Mar 18 '18 at 17:03
1

The original poster is inquiring if Ethereum has transaction based scripting/opcodes that, in a manner similar to bitcoin, could be used to script single transactions to execute opcodes without use of a smart contract. So that the transaction itself can function in a scripted/dynamic manner (eg; multisig, small computations, etc) and there be no need for a contract.

The direct answer is unfortunately no. Though there isn't many use cases transactional scripting would provide for, that just publishing a contract and using it anytime you would send the SCRIPT transaction couldn't do more cost effectively. So the question would be why don't you want to use contracts for settlement?

Similar to how LN functions, you can still exchange data in an off-chain 'channel' then eventually post the end result to the chain. However unlike bitcoin the final settlement will need to occur in a smart contract instead of a transaction SCRIPT.

Raiden for example is comparable to LN but implemented on ethereum.

You can still sign data off chain and communicate it foregoing the need for on-chain transactions, but in the end something needs to resolve those changes in balance/state. The only thing you could easily accomplish without a contract or third party software service intermediary(that essentially fills the role the contract would) is sending transaction signatures back and forth which just arn't being submitted to the network then submit them all at the end, but that has limited use and many caveats and security/trust concerns for the few uses it does facilitate.

0

If I understood right, you're asking whether you can have a smart contract which does things without being called. If that's the case, then the answer is no. Contracts never do anything without calling them so they can't run things in the "background".

Outside the contract (and outside the blockchain) you can of course do all sorts of things. You can validate transactions and so on (even if I'm unsure what you mean with 'validating' transactions).

0

I think the question here is whether or not you can sign a transaction off-chain and use that signed transaction for other purposes (also off-chain). You may do this. I think you would use this RPC call for that: https://github.com/ethereum/wiki/wiki/JSON-RPC#eth_sign. (Someone can confirm that.)

If you're asking if you can 'change the state' inside a smart contract without interacting with the smart contract (i.e without sending a transaction to the contract), then the answer is "no." The only way to change the state of a smart contract is to send it a valid transaction (or send some other smart contract a valid transaction that causes an 'internal' message call which changes the state).

  • Sorry bro, but your answer is completely unrelated to the question. – Ahmad Mar 18 '18 at 17:42
  • Perhaps you could clarify the question. Other responder also seems to have had a bit of trouble. – Thomas Jay Rush Mar 18 '18 at 17:45
  • I just did that. – Ahmad Mar 18 '18 at 17:50
0

When you create a new contract, the constructor of the contract will be executed. The constructor usually returns the contract bytecode, but you can call selfdestruct to avoid creating a contract.

You can 'abuse' of this feature to execute a smart contract without creating it first. But it has some limitations, the constructor will be executed in behalf of the new contract (not the sender), you can call already existing contracts but you cannot call yourself (the contract will not exists until the conctructor finishes).

A nice trick of this feature is that you can execute two transactions atomicaly, ie both succeed, or if one of them fails both will be reversed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.