Type
CONTRACT
Validation date
2023-12-11 05:53:13 UTC
Fee
0.5492801 UCO

Code (1.01 KB)

@version 1

condition triggered_by: transaction, on: provision(_evm_contract, _url), as: [
previous_public_key: (
   # Transaction is not yet validated so we need to use previous address
  # to get the genesis address
  previous_address = Chain.get_previous_address()
  Chain.get_genesis_address(previous_address) == 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801
 )
]

actions triggered_by: transaction, on: provision(evm_contract, url) do
  next_code = """
    @version 1

  # Automate the refunding after the given timestamp
  actions triggered_by: datetime, at: 1702281120 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.64675

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: refund(), as: [
    timestamp: timestamp >= 1702281120
  ]

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.64675

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x6B2FD712D136758C976337651B1B0EE45855E417FA72DA7CDE2BD96513521395,
    address: (
      valid? = false

      abi_data = Evm.abi_encode("status()")
      tx = [to: "#{evm_contract}", data: "0x\#{abi_data}"]
      request = [jsonrpc: "2.0", id: "1", method: "eth_call", params: [tx, "latest"]]

      headers = ["Content-Type": "application/json"]
      body = Json.to_string(request)

      res = Http.request("#{url}", "POST", headers, body)
      if res.status == 200 && Json.is_valid?(res.body) do
        response = Json.parse(res.body)
        result = Map.get(response, "result")
        
        if result != nil do
          decoded_abi = Evm.abi_decode("(uint)", result)
          # Withdrawn status is 1
          valid? = List.at(decoded_abi, 0) == 1
        end
      end

      valid?
    )
  ]

  actions triggered_by: transaction, on: reveal_secret(secret) do
    Contract.set_type "transfer"
    Contract.add_uco_transfer to: 0x000089DFCC99ACA4A7A4E82D7DF608F2A9E1B072B808A4E03BF35FE7895D7D0F5AF4, amount: 0.64480975
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.00194025

    Contract.set_code ""
  end

  """

  Contract.set_code next_code
end

Content (0 B)

State (0 B)

Movements (0)

Ownerships (1)

  • Secret shared with 1 key

    Encoded secret

    05DB5CC9B233BAD2348B9337353D0E16E5866CACD28A7B868CA043F6C609280B5F134FEED9D6E763FF04028F84BB24BEFDEEE33DE6BF32243C51CB7F

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000139B7E2FAD11AEA3758104AF4A112D366CA32C6BD9DD8629687977509750910B6

Previous signature

3103D2CF26316BF88724E47D6751D3038BB7E68ADDCE5BB0DA3C9FECE126D6CCDF6C4739B86B0053D0B92D54A97CC434EF26CA802347AA38EA7B1A3599875902

Origin signature

30440220200A0B0E7F62018B8746E54A18A063856808D38CF6E96DA78137248352F892FA022037CD9232680FB87B610B57029003B236A00ECF31FC5BB1483063B774E774AD88

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

002476BB161BFBD21A2048B20AD3219C05C29FB5428BAC42B88A8B5F2654B3DBC5

Coordinator signature

E9C4669249F707C5571A7DF8110BE37A8F41272F795552695FB2F53A4194E1CFDAC052CD39E9AC6F128456C9693C2E66ECA4851F0C36E52845D2170CD6058109

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

83A1C23F57EF509E41A2B19AAE439EC3EF01147DAF97425E135D9CEB75CBBF54744EC4BAEFF522EA84B791D6D9939C43E13C4AB5A7CC91FFE87ECD16D56D9203

Validator #2 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #2 signature

69BC2B716FAD632E573538543E26BC4262A72E30C1190ABC5C7FC53D122690FEAC2152A5EFF014BA2070983DE1D30E7B5800F3D02CD8980DF797556CFEB8A409