Type
CONTRACT
Validation date
2023-12-02 15:16:33 UTC
Fee
0.52286992 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: 1701537300 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 199

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    3D1B775DE43DAE8FFD6BD77ADC364A913604BD2A87179D63AE5DE786EC366749298F16974F42ABF0DE8384F8C43032BA79CECA68681039830AA70DDF

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001CE66D78D7BE4605E14EE4F56AAC2B9DA2F8311783953B2C85809DBCE80C01C98

Previous signature

19ADCDA81AB4CDC818BD512EB38C3D8695E9BBAFB080E3A48012B15EB0A64156F2A0CE7BC61DBAEEA333FED06F71EEC454D978EB124D29740BF60C1EE1AA3F08

Origin signature

304402201D51E90757CBE872C2F9C5DC0FA130283F9CC103DE510AFB76CB03F6A535C58E022075AAF2D11DE31179B200721A9F62B692C20D3E1FF3A8670CFE9B1A662532B796

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00684DF9136DAABE5C49132D33D24817585F63DBBD22AF2410CD4C0CA65A4B94AF

Coordinator signature

14BC80C230EC9D9256FBD5F29676139E17FFAC22B05637A5D3534E61F41598512F38CB4206735DCCDF5EACB0440F6DA4BB370328C46E7A653D13AE2F8E4F870A

Validator #1 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #1 signature

F873E06CD7571B98F723B6A3C20D7311BF64349DE603D398397F374D005A5091CCD6C1BBDBDC4D9D808818C4BE26A99B8B4B840A0764A56A04BA0DE008F22E0F

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

E3EAE179B203ABDBE347494D0010069DC2406F61867C7136DD5B31CB008ADBDD82687B394B14435F135C84136F22F7D930DEC95979E16C9EBF19BEC00709A00A