Type
CONTRACT
Validation date
2023-12-14 04:36:23 UTC
Fee
0.53648782 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: 1702535700 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 1.9692045

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x8910195F09270A4BDC70180C89115F89F7137CFA174147BF5F4FD81CA58139E4,
    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: 0x0000A66E9C4FA87C868BF49B1336D3C2E318F1D0FD20A44CD10BDD3464329B97F474, amount: 1.96329689
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 0.00590761

    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

    5473433B8E06B8DFCE885C892170E0CDD25341EB08B4F2E287D7206A67C6EFBB014D43ED3588E896A7F031F76F47C1A538E4872B7DCD1DAC5D30C512

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001ED95BAF932301DF3452BCB62CA281AD8415017B7C5CE03F12E6D15EBC38E298F

Previous signature

52A86E1395BB13444D2C1104B6B1570D1C2687063E0BB6202615C6B65142828728D7B8DC248B059957EC9FC5856B70059A54CCF6DB8A7E12E499556AE65C8807

Origin signature

304502210090389A8449521A96E867A3F63664A2CAC78177D770C5D466BEB7D287A44BBAD7022012A793EC84584BE7EBBE16CBFF0BCA992A8F2AFB68AB96C7D54A0012A96DF29A

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0022D4067A528320ECEB453440E8464FC8E44516C8298147F280DD7D3CB9EA0D71

Coordinator signature

3197C03386436FF26457F12598D741BF1E9BC093D005E3BD87C03D192B264B849C7F3F2F310B493F906A10C10A39F1596599FEFD38C36300E630C6596FFDDC04

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

4A8F01AE507DB6315233FCFD34111271DCC5E9F9F5B1E2F1198BFEF62989A24C81A33BC8BAF5FD08BB4C9546BDBF2CCFFB382AB33E0A6CB46E5BD3B9EB9E7707

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

928604F858F2BFB95DB09DC2113AEC9ED546D73C4FBE8BF8AB482B9EF36C23FABDE1709055E8E63A164A8699ACB8835C29E5230465FF6024086A1B2FC455900B