Type
CONTRACT
Validation date
2023-10-25 14:15:30 UTC
Fee
0.63676508 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: 1698250380 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 9.95e-5

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x8AF31C05827DB18097F7F956D95E7569F7E2670816B173FA9C374DB015B41525,
    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: 0x00008DD40CD42287A3C8282065F5BCA7259AC7014CD73109B570E946A977687C7BD0, amount: 9.921e-5
  Contract.add_uco_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 2.9e-7

    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

    229B7D353169E236D1A071AA99A1494781E09A34E08EE80B73D4E705AC8514AEEA06BDD938648435A3CC4081275452D3E49B477492555D8A5D860AE9

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001ABF43971EA2875473961D1937C9285B543B491C835DDF5AE2E1E77E65F120E00

Previous signature

E3C8570FC678536C83D3DE7A2DAF0F553E7396729FB9DCB745194EDCD806615CEDBE8EBF1CA9497FCDE8B58D5E485BDCE4FC1DBE35C01406C42F0D8182E08501

Origin signature

304402205F72964DF5A89AA23F0EF6718FB3012BBD855CC6311968E1FF48997AD05896950220072DC7D733C6292EB5718A9514144742F384A2168D27FDD3AFD15A43E9DA6E3C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

007C0B748EE5A8517AC4364E4F108C11ADD2ED0D9DF54832E7B17AC116A672B480

Coordinator signature

FD0511BB18A433EA936208F67DFCE9A2D2393B6BF9DA938CE6F15BB9AE8CE2026E0595808AF5F5290749AB5D178FBBC8408DBD1EB409BB9A17993DE189A7E905

Validator #1 public key

00018A312AFA617E98B343D09AD2E73F0AB661DB0A59FB986D5DB8CE7664E14C25FC

Validator #1 signature

DD712C1C2B9718168049D451FBC60F65FC1A761ED65FB50EB96E568089674B98BD8F9D063CE4ECB9C6B178FE47B5CE758C4D0FF79BE07CEE9BB4471CD9F9CE07

Validator #2 public key

0001500FBE298B79FFBDD5CCA1798F30FD88A53D26EC39DE5DDE1F4137B032A4BC34

Validator #2 signature

514C77CFC88277173A0DA8DDB3B9510FC3BCB6FF2A2D4A55A3793A54E0F472E3C36D1180E7BD8E65D5CF0A31B73B3BA504398A5A3956705457113DEDEDB16505