Type
CONTRACT
Validation date
2023-12-11 07:05:34 UTC
Fee
0.55359078 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: 1702285440 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.597

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    55715E040A15F0208692BB6C3EE0342D1D717B1D2D5C0704746285B523720ED5CA82B8ACE775A9AF35EC1540947614F233FEFEB6FEEF14EE79FF70C4

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001A920E77912CA790D8F1EAE3CB4557559E1B5082E7AB9787EB5F9D8673C78805D

Previous signature

0E7C94FBCC58DC72C50479B6C6FBFD3261244EAF13D6A13DAF8D2A95B517350307405F166D4E74EAAD86D43D28B9F94AD2007E2527E018B411613BB3E06BC700

Origin signature

3045022100E59EB3299CE2317013F77A38AEFE7AE2476CCA4D2CBF59C5F4205E6A3E55602B022041F00F82FE8D66D3AD54571BD7C2FFEDC805530554D6385A43BF8F4E001A9158

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

0097838541A31695C6F3D0360496B64327A7E0C0749EA662FFE9B304CE48005D7F

Coordinator signature

AFA318B45236F58FF54A1E821D73DCF21324A7D849FDFC7F79514A7CEF8E7EDD77BF88AA5DE6FD0181A4A05C3980D0C26F55DD272E0B7E5AD68720A158287509

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

287D4D31948DA8017C5CA44E719C70208DB07278CB94ACD16EDB79922456DA3504D22C42C5EFC4CD0C8BF9C242E68A09B47FA1BC2AA17D3818E77F25522E8402

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

5BFA2B5D2699F37B24E86D1A4FC494340B0B7788985A74834F591653FA08E8B2CF1E7E8C24F33771536CFEDA560BA8753AE215B4B7A9CCE0CB0D6C267CAE7E0F