Type
CONTRACT
Validation date
2023-11-16 23:40:39 UTC
Fee
0.61370055 UCO

Code (1.06 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) == 0x00008DD22E7496E86901E9B276A1BE6F9512EB09980CC04C7B76495EF37D5666A709
 )
]

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: 1700185200 do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code ""
  end

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

  actions triggered_by: transaction, on: refund() do
    Contract.set_type "transfer"
    # Burn the non withdrawed tokens
  Contract.add_token_transfer to: 0x00000000000000000000000000000000000000000000000000000000000000000000, amount: 0.04975, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    Contract.set_code ""
  end

  condition triggered_by: transaction, on: reveal_secret(secret), as: [
    content: Crypto.hash(String.to_hex(secret)) == 0x07AA0A48EFC1090A4353E1C99F794BA0267847B0538A24D5CC3F5B2BD9F3F54F,
    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_token_transfer to: 0x00006AFF130BEB6BE9B02B80FFC13DB5EABFB0A7D167BAFC9F2DF8F141D7755FB39F, amount: 0.04960075, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827
  Contract.add_token_transfer to: 0x0000749d250560bf06c079832e0e9a24509b1e440a45c33bd9448b41b6a056fc6201, amount: 1.4925e-4, token_address: 0x0000288BF6F0E12457B125DC54D2DFA4EB010BE3073CF02E10FB79B696180F55B827

    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

    487544EAB727BFBF386315F2FD78ED5A375C305285816DC778A44BF11684D6BFE69DE0CED9EBDC137315F1474793AB7304F73C00AA8E11C707E6E025

    Authorized keys

    • 00017877BCF4122095926A49489009649603AB129822A19EF9D573B8FD714911ED7F

Contract recipients (1)

Inputs (0)

Contract inputs (0)

Unspent outputs (1)

Proofs and signatures

Previous public key

00015BFA28B84B1780AF4B5286E91DAFB37C15BF87C4313217D494DC8E00FA1B639D

Previous signature

4C6BDA00AA290F48A0CF98AF24286BEC9B07FF236088E468794FE0A11CFF642C1B86524991AA58E57FB4852BE829EDB1379E68A18157D5D0374380711F204602

Origin signature

30450221008D0BF61B71EAAA34A572B6444525CB3172A8F9BCC4227F09CAAD31BDA02CD0EE0220030FB4C40F4D3BB6CA6014640EC83FF99BBE90FC0313B5899B73EAC8922C652C

Proof of work

010104AB41291F847A601055AEDD1AF24FF76FA970D6441E2DCA3818A8319B004C96B27B8FEB1DA31A044BA0A4800B4353359735719EBB3A05F98393A9CC599C3FAFD6

Proof of integrity

00E0819E01D8082B1F806E86EB4A1862A3B6F300BB2038840E136AA617AECE5A9F

Coordinator signature

B8185BC8C1F1DFA0230E18F684C9150258E1866A5FC0E4D8D540F64763F761F8DAF26F7052C176EE27F2A109F8ED983AF5D5A1C8A442FD377F72ADE42EBA2E01

Validator #1 public key

00011B58ED42235461734EAF253BD97A80B92899ABCC3BE680D44B6825DD2A88A947

Validator #1 signature

CE1068B6E2A82157F89F8E48D3480AFD3A6A6FF5A305B0785B618AB4C4F82B3CADC24BF4F0D86AF108312EAF23DEC3D6AADD4C3FCAEEE72329343F7B13D02B06

Validator #2 public key

0001B0A94804BF8ECC9897075C6207FF63EF4D339F57A0349888E6B77CD47DB53EF3

Validator #2 signature

010502A10B6B311A84D5E021285C011A38B75C5731497B32F997E2456E0A81C796BC7678EEE2A97C425138540213CD9603C8D2394FAB0BF4B004729F3DDA9D0F