I read the following in a research paper: Short Paper: Formal Verification of Smart Contracts


contracts are “instantiated” by the account creating transaction; this will allocate the properties of the contract in the global storage and call the constructor (the method with the same name as the contract).

  1. What does the above mean?
  2. Does it mean that we don’t have the main method in Solidity?

  3. And also does it mean that we can’t load the contract within EVM/block chain as for example we load compiled java code into JVM by using “java contract” where suppose contract is a compiled java code & for that reason we need some external process like Truffle to push the contract into the EVM/block chain?


  • You don't need Solidity, you can write your contract entirely in Assembly. Would knowing that make you change anything in your question?
    – Nulik
    Sep 23, 2018 at 22:47
  • Thanks. So it talks about transaction. But its a special type of transaction which stores the properties of contract (like methods? like data such as balance?) on to the block chain. But transaction is same thing as method calling. So when we create account, methods are outside block chain?
    – zak100
    Sep 24, 2018 at 4:38
  • No, all transactions are of the same type, there is no special transaction type. All that a transaction does, is transfer funds to destination address and if the destination address has some code, it starts and instance of the EVM , loads that code on to the EVM and runs that code from PC=0 until the end. Check how 8086 microprocessor works, that's the model where the EVM was copied from. Constructors, methods, variables ... all of this is the invention of the developers to make programming easier. And Truffle is an Ethereum client, that generates transactions, with geth you can do the same
    – Nulik
    Sep 24, 2018 at 12:14

1 Answer 1

  1. This means that a contract (address on the blockchain w/ code & state associated with it) is always created by another address (could be an external address or another contract).

  2. There is no main function in Solidity. Every (non-abstract) contract has a constructor (which if not specified is just a no-op function) which is called as part of a contract being deployed. You can use this to set up state and trigger any associated actions. The constructor is specified using:
    constructor (...args...) { ... } .

  3. You can load the code (bytecode) associated with a contract on-chain, although this isn't very useful. Sometimes this is used to check that an address is not actually a contract (by checking the contract code size is 0). You contract can create a new contract (using the new operator) provided the creating contract has access to the bytecode needed to deploy the new contract (usually in Solidity this means declaring the contract to be created as part of the contract doing the creating).

  • <code>new </code> operator is used to deploy the contract?
    – zak100
    Sep 25, 2018 at 13:13
  • And if we don't use new like: <code> contract Malicious { uint balance; MyBank bank = MyBank(0xdeadbeef8badf00d...);.......}</code> (a) then we can start a transaction or call other methods of MyBank using the instance bank. (b) What the address in the call to MyBank(...) constructor refers to (c) Does the transaction necessary involve calling of WithDraw(..) and Deposit(..) function? Thanks both of you for your time. @Nulik.
    – zak100
    Sep 25, 2018 at 13:29
  • In code like: MyBank bank = MyBank(0xabc) you're saying that there already exists a MyBank contract at 0xabc, and I'd like to wrap it in the MyBank ABI (which must be accessible at the point this code is executed) so that I can call functions on it.
    – Adam Dossa
    Sep 25, 2018 at 17:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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