Type
CONTRACT
Validation date
2023-12-09 13:27:54 UTC
Fee
0.50223366 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: 1702135620 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 4.975

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    732509FAF109F5DE5C30DD7F3E1D7B892158A28132ADA69B2579DA389D0357CA0AFD574232071B170BDD2B2FC72A65889B825FE96AB2C90542DA14AB

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00019DAC6CEB16CA680ED5D833604E734D6A49BDC1249740F8B621B4B3C55230BDC6

Previous signature

96F0E8532E4DC4F1DC557E54CE49802BDE7F3EA55CB7DEDE72F074B2D9F0BE7FB6356F344A33A606775BC3BBEE27A0B87EF3A03AD3E5CE0EB81428F603310A0A

Origin signature

304502210099517F0F124B4A001016380EA63EA67F80B057C243DD260A8BD0760C42273F4302207F88265B75B53E76B242A62B4150A15F1CC037A455BB3F7742091A211F95FF68

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

003E0E9334B720E2283E9E246F2FA8B57C5C89F4A640E4A5B4A8F9C8C95CBD0D21

Coordinator signature

179A1F3D545D0C844CFFBFBF6A4BE81241F6B79736FD5F5302DDB4706759A40581397B0D434009EC424F16CEBAC29668DE5BCF6D5DA5D31E403E865CB021FF09

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

BEF2CB7FB0AE77D653D8AE06DFF80A9047FDD942981C183B32E68C2307415C0095D71E8D49F1B26713C31F41F91504D9929D84A3E9A1B30B861F15E87BB30C0B

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

FE49459F3E6410D84614E028EEA2C131F0AC5AC51AAA8E3C707CD12BA5E4697CCAF9648439904B7D4D582BABE41E66E9A5CDEA0D8836E8BC738182FE0288110B