Type
CONTRACT
Validation date
2023-12-09 06:31:10 UTC
Fee
0.51879184 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: 1702110600 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 2.0895

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    0B9C7FF73A17DC3871B0B3E2280824465075A79D31CFF6A088141D1A7DF562A88FC38E2A9FD18B73DA7BAFDD96BA237903315835ECE4FB2415702522

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001989850DFC557B5D09DED1421E4813AA234D0D11483BD3434F0EF5F37DB252ADC

Previous signature

195E9CDA06B27165FA2242D4E8F5A014AB8F17ACF856D18E6DDCB4F5FFD67DB1F1A5D0F0CBFA6B45109C472DD1A4648A4D897161BCE6862524592D77803D900B

Origin signature

3045022100DC83AD2676FC6DCF3EB0506DA96549AB195E74D35CB5C6D135576A8F4CF1F5AF022041765DE112975287565B0B02A6858D0B884DD4A4A09A1135DFA858BA361C88CA

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

006B3F105049C953F676FE24B22C6B5A2BA08DDB2B97D84E5D70D901F75D750171

Coordinator signature

8DB96A4F9F06C26B753C2DD4D06B43E3B4D01B1B61B1409036F43934376333989EBA039591306613907E306C94006E9CCEDCD9FBF4DD42BE3BFF6355DC82C603

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

75D82FB857B1D864B61D4B7674A94A582C722BF23CE0AD148E09D391217D1621BC8EBD8CB1DC410F63200EBE6A0DF8BA05952A8499BD3BD6A333D4F4486E9109

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

1DAE1AE686320EB112180A2E9A5840ECB0E19B586A8B3D62641FFE26E16F52BBBEA0FA57514E5AB6F2C5C512F505108BCAE3FB1A9DFDF8FF875DC92C1A30C504