SUSY Gateway (Gravity)

SUSY gateway:

Overview:

LU-Port has already implemented on waves and eth chains:

To work with another TargetChain (ERGO) we have to see the following functionality of IB port:

  1. ERGO SC must support external call of “attachEventData” with parameters:
  • Token ID (optional since different tokens will have their own gateways)
  • Amount
  • Receiver

Only one from 5 admin accounts have a chance to call this method.

  1. After attachEventData Receiver must receive its amount of wrapped tokens
  2. Holder of wrapped tokens has to have an ability to send tokens to the gateway address and this should trigger API (rpc) call.

For all statements 1-3 there must be an API (open and public).

Solidity example of IB (issue/burn port):

Ergo Solution

As Ergo is UTXO blockchain with in which contracts are focused on checking on-chain work done off-chain, Ergo solution for 1-2) would be quite different from Ethereum (as usually):

  • create a lot of UTXOs (e.g. 50) with e.g. swETH tokens locked with a contract
  • the lock contract is waiting for amount and receiver to be provided in context extension, checking admin signature and also that asked amount of swETH unlocked indeed. Something like:

{
val amount = getVarLong.get
val receiver = getVarGroupElement.get

val selfOut = OUTPUTS(0)
val selfAmt = ((SELF.tokens(0)._2 - selfOut.tokens(0)._2) == amount) && selfOut.tokens(0)._1 == fromBase64(“swETHtokenid”)
val selfScript = selfOut.propositionBytes == SELF.propositionBytes
val rcvOut = OUTPUTS(1)
val rcvScript = rcvOut.propositionBytes == proveDlog(receiver).propBytes
val rcvAmt = (rcvOut.tokens(0)._2 == amount) && selfOut.tokens(0)._1 == fromBase64(“swETHtokenid”)

val adminApproval = PK(“9eg2Rz3tGogzLaVZhG1ycPj1dJtN4Jn8ySa2mnVLJyVJryb13QB”) || PK(“9eg2Rz3tGogzLaVZhG1ycPj1dJtN4Jn8ySa2mnVLJyVJryb13QB”) || PK(“9eg2Rz3tGogzLaVZhG1ycPj1dJtN4Jn8ySa2mnVLJyVJryb13QB”) || PK(“9eg2Rz3tGogzLaVZhG1ycPj1dJtN4Jn8ySa2mnVLJyVJryb13QB”) || PK(“9eg2Rz3tGogzLaVZhG1ycPj1dJtN4Jn8ySa2mnVLJyVJryb13QB”)

selfAmt && selfScript && rcvScript && rcvAmt &&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UnozdEdvZ3pMYVZaaEcxeWNQajFkSnRONEpuOHlTYTJtblZMSnlWSnJ5YjEzUUIiKQoKICBzZWxmQW10ICYmIHNlbGZTY3JpcHQgJiYgcmN2U2NyaXB0ICYmIHJjdkFtdCAmJiBhZG1pbkFwcHJvdmFsCn0=

For 3) we can have offchain component just and script which is checking that the only one output is merging all the input swETH tokens and output script is from above.

3 Likes

Nice, this doesn’t seem too complicated overall even in the UTXO model.

2 Likes