Skip to content
Julian Konchunas edited this page Aug 31, 2020 · 1 revision

Solidity to Ligo quirks and solutions

Since Solidity is vastly different from Ligo in paradigm and philosophy we may need to address some problems and difference in approaches.

Constructor

We should convert constructor into local code to be compiled using Ligo compile-storage. This code should be executed only once when contract is deployed since that is whole premise of constructor in Solidity. If we leave constructor in code of contract as usual function anyone could easily execute it and reset contract to initial state.

View functions

Contract in Ligo should always return list of operations and state change. It is unclear how to return plain values from contract methods from outside. Proposal as of now is to create separate shell script which fetches current contract state from blockchain, compiles some view function Ligo code and executes it locally practically imitating view functions. Still unclear how to call view functions from other contracts

Events

Events are simply not supported in Ligo. We may strive to emulate them using dummy transactions so clients can catch these transactions as events

Foreign calls

Foreign calls are going to be invoked using transaction to other contract. This transaction is going to be action wrapping record containing arguments for foreign contract call. It will also provide action for passing back return value by passing current contract call.

Mutability

TBD

State emulation

Whole state should be stored as an object and returned from main function

Router

Since it is impossible to call separate functions in one contract from outside we are going to create router type and records for every function call like it is done in NFT token proposed interface https://nft.stove-labs.com/ .

Using for directive

Solidity using directive like using ExactMath for uint is being inlined. For example, your code n.exactAdd(1); will be transalated as exactMath_exactAdd(n, 1n) because there is no other way to do so in LIGO.

Clone this wiki locally