Type
CONTRACT
Validation date
2023-12-08 07:01:10 UTC
Fee
0.48712365 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: 1702026000 do
    Contract.set_type "transfer"
    # Send back UCO to bridge pool
  Contract.add_uco_transfer to: 0x000018D60115ECE0C7558A46B4693749BF6BEAB524FDDCCF9B10B910619E4EE08801, amount: 0.995

    Contract.set_code ""
  end

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

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

    Contract.set_code ""
  end

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

    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

    FE385BEF98ADC6C92E64F412AB248D9F3D1CC79570A29B5F5A6E85C5BF26CD21B002DB30B42A1C57065931C4BBBE5EC5B9FFB0147F80BB52C7963837

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

0001F4B77AC6301E8A60A56A2A580BECDA0BC735C9F22E0927C5EF15A81AA9930E5F

Previous signature

7C1D4F1336ADD92F4B8DA45E0F1A474EDA4EEE66FC61B15E8E1D8DE5440CBD8FD75F46E8548C3451E7F9B56E241E74BD6BE8D95ADBA9BFF292A4AABFE6FC5400

Origin signature

30440220395B82C9B54ED3032D2CFCB713C5327FCA4750F3728767B1251629CF4913348902207581DE744148CF1C00F71ECF39D29AEC1881A26CD395ECC437AEE28C8205B5FD

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00C6C9626042DF6A4B30E7D32FB30506F2E8F57704EA0B2A577109B6FDEA4204F0

Coordinator signature

11586CA9E6DA41B7C367A5C4C01D14F5A80084E7AA6B025C6A9378804862ADC35E2E5DB12D041EC5EDEFCD5F1CF34A4A344690B515B7365B6929058B59DEFA05

Validator #1 public key

000151C124A6211CD402FD1CFE560C5DB51ED0CBEF44B09B21A41206028E7E5942BF

Validator #1 signature

6100E30592DE69D502E2D52B744AC2B080BEE62D5EAAA740EBCE6FBE2CEA855A98F8A6E1E62BCE202CC79C8FD8E7905CE62EC6C6C6D82A75C9570E2EFC83930F

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

CE77619BA5A8DA7EDCF8DD3F1F7C76F83ED75C893D0697E6C4DF4EB37F513D78A33CD82C0D314BA832115FAC4A738B519A313367AFAEBA9D40572A8EA85DB506