Type
CONTRACT
Validation date
2023-12-05 17:30:54 UTC
Fee
0.52327706 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: 1701804540 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 158.603

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    3737AC8EB926374805C139D141FB63EE46B5863813522D65D7E2BC00C11BA3B419B20B62F70A52805F77CB3F9C978E4FF96A333E6ED6303EF62A6D83

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

000102F48FD00C67973F9D18AA5179926A0BBED08262B3C7B862A1B3D73B08C35E3E

Previous signature

44BB9735CDFAF564820716DCEDCED0C87BBC03E876D1364FFA680E0C777AEA8A129379717D31628172B1132AF8109B62D15D761233229B42B1503B5B39A3C60E

Origin signature

3044022006A5F823D6E0DA1CBD3B60B1164AD7A06B5B8E96A1CA37AD211B3A1442B3C13E022003131EE7CAB93884ED956D674B4A44ED834AABBD3666DE125338D9C695A2DF0B

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

001AF32206674B3D5408CAC6B7FF0E847E1798222DA2A90F420AF83CC2E3BF0F5B

Coordinator signature

A80B3B6F8734446E1459C0A81F5241255D3DFFB809C87531C7E383CB2D555CCCBAE7EC0D5991F198742BDC863F8FBE17B7863E9E472AB6EDD84B4DE1A14BBE0C

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

A763B35FD52E52F46CEB2311AA8B493B94A0D7D4150A09F00D969E027C04DDF3845475F30AE669A7B6071A8A8509870D84EDB0AA3BB8A9AD67EBC0486ED4F800

Validator #2 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #2 signature

52BAEAB7289223560D30E6BF7B6E366AABEAFCE48CA4369D4489ADA56EDDD20073EEC84DEC73B512F77B73432B2483A1D0C24CB921B8E3FB762C2F615ADF7306