Type
CONTRACT
Validation date
2023-12-11 05:07:19 UTC
Fee
0.54850421 UCO

Code (1 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: 1702278360 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.995

    Contract.set_code ""
  end

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

  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.995

    Contract.set_code ""
  end

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

    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

    C07FECB9429FDA6AFAB57826264FE4CEE89A850F839D3EBC3500FBF5914723ECCCF070A7504E875388FD201310F74645191BFE1DAD311A6A6A3B1B7C

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001984CA731F1FFCF6454AD41ED722A81DF8A221D226499998224B8BD39F052A3D5

Previous signature

BE3579654D57564FFC9734A8A6269F7F9A68DA67F830CD4542BA143C5C20103B69A2269438F7B59E2C609E70C043C8FF1C461B7BDD5A27728FC8DD1E1BB72F0F

Origin signature

3045022100E5231473B47E1F67B5C1DF92530484AFA5E9CAEEAFE2B557E2EEA82493373BC9022063C760001DF3CAEE5D2CB6A93DB7D76FA5644325379EB943903C6517624C4B3C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00CF5418EBFE2D5B22E59A3CFD750D1A5A45C3719BB1AF2EF886F138CB2F9FD795

Coordinator signature

18F7165328FB391637DBD1FCE5E24E0C6F3B13B36AD77ECB39090734F54946BA1E318483F8423A80BACEC5DE3D826729DFA325C1DED32EC31D6F56BBC90D2E0F

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

3E2756A9E32EB7C8F71548198A846A63B73EF6F58EA42937E769562AA46E0BD6BA0B782036C716EDC7AB96EDEC0466B00AC265B6A30A82A07272EB869C56200F

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

9BAC96577F6AD2D1F693F2708DAF23EB1AC728CDA7CBA9F15DD5D4FBF612AA695F218E209856F9FC91F88F5C5D6C7E79F1CACE14D93640527DEE713388F83504